Skip to content

Commit 1da96c5

Browse files
author
Dave Bartolomeo
committed
Allow languageId: scopes in tests
1 parent de38b1f commit 1da96c5

2 files changed

Lines changed: 43 additions & 6 deletions

File tree

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
---
22
lockVersion: 1.0.0
33
dependencies:
4-
codeql-javascript:
5-
version: 0.5.1
4+
codeql/javascript-all:
5+
version: 0.6.3
6+
codeql/javascript-queries:
7+
version: 0.6.3
68
codeql/regex:
7-
version: 0.0.9
9+
version: 0.0.14
10+
codeql/suite-helpers:
11+
version: 0.5.3
812
codeql/tutorial:
9-
version: 0.0.6
13+
version: 0.0.11
14+
codeql/typos:
15+
version: 0.0.18
16+
codeql/util:
17+
version: 0.0.11
18+
codeql/yaml:
19+
version: 0.0.3
1020
compiled: false

extensions/ql-vscode/test/vscode-tests/test-config.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
ConfigurationTarget,
44
workspace,
55
WorkspaceConfiguration as VSCodeWorkspaceConfiguration,
6+
Uri,
67
} from "vscode";
78
import { readFileSync } from "fs-extra";
89
import { join } from "path";
@@ -151,14 +152,40 @@ const packageConfiguration: Record<
151152
const pkg = JSON.parse(
152153
readFileSync(join(__dirname, "../../package.json"), "utf-8"),
153154
);
154-
return pkg.contributes.configuration.properties;
155+
return {
156+
...pkg.contributes.configuration.properties,
157+
// `debug.saveBeforeStart` is a core VS Code setting, but we depend on its value in these tests.
158+
// We'll set it here to the value that we expect.
159+
"debug.saveBeforeStart": {
160+
default: "nonUntitledEditorsInActiveGroup",
161+
},
162+
};
155163
})();
156164

157165
export const vsCodeGetConfiguration = workspace.getConfiguration;
158166
export let vscodeGetConfigurationMock: jest.SpiedFunction<
159167
typeof workspace.getConfiguration
160168
>;
161169

170+
function acceptScope(scope: ConfigurationScope | null | undefined): boolean {
171+
if (!scope) {
172+
return true;
173+
}
174+
175+
if (scope instanceof Uri) {
176+
return false;
177+
}
178+
179+
// Reject any scope that has a URI property. That covers `WorkspaceFolder`, `TextDocument`, and any
180+
if (scope.uri !== undefined) {
181+
return false;
182+
}
183+
184+
// We're left with only `{ languageId }` scopes. We'll ignore the language, since it doesn't matter
185+
// for our tests.
186+
return true;
187+
}
188+
162189
export const beforeEachAction = async () => {
163190
const defaultConfiguration = new DefaultConfiguration(packageConfiguration);
164191

@@ -176,7 +203,7 @@ export const beforeEachAction = async () => {
176203
section?: string,
177204
scope?: ConfigurationScope | null,
178205
): VSCodeWorkspaceConfiguration => {
179-
if (scope) {
206+
if (!acceptScope(scope)) {
180207
throw new Error("Scope is not supported in tests");
181208
}
182209

0 commit comments

Comments
 (0)