Skip to content
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

Update test callable discovery to work within the language service #2095

Open
wants to merge 71 commits into
base: main
Choose a base branch
from

Conversation

sezna
Copy link
Contributor

@sezna sezna commented Jan 7, 2025

This PR rewrites #2059 to trigger test discovery from within the language server, as opposed to externally in an entirely separate context. Please read the description in that PR for more detail.

It also adds tests for LS state in both the Rust-based LS tests and the JS-based basics.js npm API tests.

@sezna sezna requested a review from ScottCarda-MS as a code owner January 7, 2025 20:37
@sezna sezna changed the base branch from alex/testHarness to main January 7, 2025 23:41
Copy link
Member

@minestarks minestarks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not done looking at all the files, posting all my comments for today.

compiler/qsc/src/lib.rs Outdated Show resolved Hide resolved
wasm/src/test_discovery.rs Outdated Show resolved Hide resolved
wasm/src/test_discovery.rs Outdated Show resolved Hide resolved
wasm/src/language_service.rs Outdated Show resolved Hide resolved
npm/qsharp/src/language-service/language-service.ts Outdated Show resolved Hide resolved
npm/qsharp/src/compiler/compiler.ts Outdated Show resolved Hide resolved
wasm/src/language_service.rs Show resolved Hide resolved
Copy link
Member

@minestarks minestarks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finished looking. I really like the overall approach. Also I assume integration tests are coming up in a different PR.

compiler/qsc_passes/src/test_attribute.rs Outdated Show resolved Hide resolved
compiler/qsc_passes/src/test_attribute/tests.rs Outdated Show resolved Hide resolved
language_service/src/state.rs Outdated Show resolved Hide resolved
language_service/src/state/tests.rs Outdated Show resolved Hide resolved
vscode/src/language-service/activate.ts Show resolved Hide resolved
vscode/src/language-service/testExplorer.ts Outdated Show resolved Hide resolved
library/signed/src/Tests.qs Outdated Show resolved Hide resolved
vscode/src/language-service/testExplorer.ts Show resolved Hide resolved
library/signed/src/Tests.qs Show resolved Hide resolved
language_service/src/protocol.rs Outdated Show resolved Hide resolved
@minestarks
Copy link
Member

@sezna hitting this odd bug where you can't navigate to the test case after it fails.

test-explorer

@swernli
Copy link
Collaborator

swernli commented Jan 13, 2025

I ran into an issue where if I open a notebook that includes Q# cells the test explorer loses its content and can't get it back until a full window reload:

Screen.Recording.2025-01-13.at.10.40.09.AM.mov

@sezna
Copy link
Contributor Author

sezna commented Jan 22, 2025

Just FYI @minestarks @swernli that test-disappearing bug is fixed and this is all green again.

@sezna sezna requested a review from minestarks January 23, 2025 16:47
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { ITestDescriptor } from "../../lib/node/qsc_wasm.cjs";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be imported as part of the following import list.


async onTestCallables(callables: ITestDescriptor[]) {
try {
const event = new Event("testCallables") as LanguageServiceEvent & Event;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this and onDiagnostics (line 278 above) now be the specific event type? (e.g. LanguageServiceDiagnosticEvent above and the TestCallables version here)

QscEventTarget,
VSDiagnostic,
log,
ProgramConfig,
TargetProfile,
LanguageServiceDiagnosticEvent,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this rename it'll likely be a breaking change for QCOM. We'll need to ensure we communicate this when they take a new drop.

@@ -58,7 +60,35 @@ impl LanguageService {
)
.expect("callback should succeed");
};
let mut worker = self.0.create_update_worker(diagnostics_callback, host);

let test_callables_callback = test_callables_callback
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the initial call done on line 40 for the diagnostics callback unnecessary then? (Mine thinks it might be)

@billti
Copy link
Member

billti commented Jan 23, 2025

When a test case fails and I click on it to go to the test source, I get the below error.

Interestingly, when the test passes, it seems to work fine!

image

@billti
Copy link
Member

billti commented Jan 23, 2025

The 'Run Tests' button is not running any tests. When I click Run on the items in the tree view it works, but this button doesn't.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants