Skip to content

Update Known Q# Tests Cases on QIR Profile Change #2373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions language_service/src/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ impl Compilation {

self.package_store = new.package_store;
self.user_package_id = new.user_package_id;
self.test_cases = new.test_cases;
self.compile_errors = new.compile_errors;
}
}
Expand Down
66 changes: 66 additions & 0 deletions language_service/src/state/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,72 @@ async fn target_profile_update_fixes_error() {
);
}

#[tokio::test]
async fn target_profile_update_updates_test_cases() {
let errors = RefCell::new(Vec::new());
let test_cases = RefCell::new(Vec::new());
let mut updater = new_updater(&errors, &test_cases);

updater.update_configuration(WorkspaceConfigurationUpdate {
target_profile: Some(Profile::Unrestricted),
package_type: Some(PackageType::Lib),
..WorkspaceConfigurationUpdate::default()
});

updater
.update_document(
"single/foo.qs",
1,
r#"@Config(Base) @Test() operation BaseTest() : Unit {}"#,
)
.await;

expect![[r#"
[
TestCallables {
callables: [],
},
]
"#]]
.assert_debug_eq(&test_cases.borrow());

// reset accumulated test cases after each check
test_cases.borrow_mut().clear();

updater.update_configuration(WorkspaceConfigurationUpdate {
target_profile: Some(Profile::Base),
..WorkspaceConfigurationUpdate::default()
});

expect![[r#"
[
TestCallables {
callables: [
TestCallable {
callable_name: "foo.BaseTest",
compilation_uri: "single/foo.qs",
location: Location {
source: "single/foo.qs",
range: Range {
start: Position {
line: 0,
column: 32,
},
end: Position {
line: 0,
column: 40,
},
},
},
friendly_name: "foo.qs",
},
],
},
]
"#]]
.assert_debug_eq(&test_cases.borrow());
}

#[tokio::test]
async fn target_profile_update_causes_error_in_stdlib() {
let errors = RefCell::new(Vec::new());
Expand Down
Loading