Skip to content

Commit

Permalink
initial round of PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sezna committed Dec 13, 2024
1 parent 7d2aadc commit ac8bfd7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
13 changes: 12 additions & 1 deletion compiler/qsc_frontend/src/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,18 @@ impl With<'_> {
None
}
},
Ok(hir::Attr::Test) => Some(hir::Attr::Test),
Ok(hir::Attr::Test) => {
// verify that no args are passed to the attribute
match &*attr.arg.kind {
ast::ExprKind::Tuple(args) if args.is_empty() => {}
_ => {
self.lowerer
.errors
.push(Error::InvalidAttrArgs("()".to_string(), attr.arg.span));
}
}
Some(hir::Attr::Test)
}
Err(()) => {
self.lowerer.errors.push(Error::UnknownAttr(
attr.name.name.to_string(),
Expand Down
23 changes: 6 additions & 17 deletions vscode/src/testExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import {
log,
ProgramConfig,
QscEventTarget,
IProgramConfig,
} from "qsharp-lang";
import { getActiveQSharpDocumentUri } from "./programConfig";
import { IProgramConfig } from "../../npm/qsharp/lib/web/qsc_wasm";
import { getTarget } from "./config";
import { toVsCodeRange } from "./common";
import { isQsharpDocument, toVsCodeRange } from "./common";

function localGetCompilerWorker(
context: vscode.ExtensionContext,
Expand Down Expand Up @@ -55,19 +55,14 @@ async function getProgramConfig(): Promise<IProgramConfig | null> {

/**
* Constructs the handler to pass to the `TestController` that refreshes the discovered tests.
* if `shouldDeleteOldTests` is `true`, then clear out previously discovered tests. If `false`, add new tests but don't dissolve old ones.
*
*/
function mkRefreshHandler(
ctrl: vscode.TestController,
context: vscode.ExtensionContext,
shouldDeleteOldTests: boolean = true,
) {
return async () => {
if (shouldDeleteOldTests) {
for (const [id] of ctrl.items) {
ctrl.items.delete(id);
}
for (const [id] of ctrl.items) {
ctrl.items.delete(id);
}
const programConfig = await getProgramConfig();
if (!programConfig) {
Expand Down Expand Up @@ -150,11 +145,7 @@ export async function initTestExplorer(context: vscode.ExtensionContext) {
};

function updateNodeForDocument(e: vscode.TextDocument) {
if (e.uri.scheme !== "file") {
return;
}

if (!e.uri.path.endsWith(".qs")) {
if (!isQsharpDocument(e)) {
return;
}
}
Expand Down Expand Up @@ -196,7 +187,7 @@ function startWatchingWorkspace(
context: vscode.ExtensionContext,
) {
return getWorkspaceTestPatterns().map(({ pattern }) => {
const refresher = mkRefreshHandler(controller, context, true);
const refresher = mkRefreshHandler(controller, context);
const watcher = vscode.workspace.createFileSystemWatcher(pattern);
watcher.onDidCreate(async () => {
await refresher();
Expand All @@ -209,8 +200,6 @@ function startWatchingWorkspace(
await refresher();
});

// findInitialFiles(controller, pattern);

return watcher;
});
}
Expand Down
3 changes: 3 additions & 0 deletions wasm/src/test_explorer.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use qsc::{
compile,
hir::{Attr, PatKind},
Expand Down

0 comments on commit ac8bfd7

Please sign in to comment.