From ac8bfd7a24c793a4a537523a8b3605da66fb79d3 Mon Sep 17 00:00:00 2001 From: sezna Date: Fri, 13 Dec 2024 14:16:21 -0800 Subject: [PATCH] initial round of PR feedback --- compiler/qsc_frontend/src/lower.rs | 13 ++++++++++++- vscode/src/testExplorer.ts | 23 ++++++----------------- wasm/src/test_explorer.rs | 3 +++ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/compiler/qsc_frontend/src/lower.rs b/compiler/qsc_frontend/src/lower.rs index 4df5d49526..67c3cb6309 100644 --- a/compiler/qsc_frontend/src/lower.rs +++ b/compiler/qsc_frontend/src/lower.rs @@ -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(), diff --git a/vscode/src/testExplorer.ts b/vscode/src/testExplorer.ts index 459abebdb5..ff45d0333a 100644 --- a/vscode/src/testExplorer.ts +++ b/vscode/src/testExplorer.ts @@ -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, @@ -55,19 +55,14 @@ async function getProgramConfig(): Promise { /** * 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) { @@ -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; } } @@ -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(); @@ -209,8 +200,6 @@ function startWatchingWorkspace( await refresher(); }); - // findInitialFiles(controller, pattern); - return watcher; }); } diff --git a/wasm/src/test_explorer.rs b/wasm/src/test_explorer.rs index 695a938ab4..c7c5a8e344 100644 --- a/wasm/src/test_explorer.rs +++ b/wasm/src/test_explorer.rs @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + use qsc::{ compile, hir::{Attr, PatKind},