Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e54a0b2

Browse files
Fix up settings tests and add test for cwd relative path support
1 parent 87bf958 commit e54a0b2

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

‎test/TestEnvironment.code-workspace

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"settings": {
99
"git.openRepositoryInParentFolders": "never",
1010
"csharp.suppressDotnetRestoreNotification": true,
11-
"extensions.ignoreRecommendations": true
11+
"extensions.ignoreRecommendations": true,
1212
}
1313
}

‎test/core/settings.test.ts

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,20 @@ import {
1313
validateCwdSetting
1414
} from "../../src/settings";
1515
import path from "path";
16+
import { ensureEditorServicesIsConnected } from "../utils";
1617

1718
describe("Settings E2E", function () {
19+
async function changeCwdSetting(cwd: string | undefined): Promise<void> {
20+
await changeSetting("cwd", cwd, vscode.ConfigurationTarget.Workspace, undefined);
21+
}
22+
23+
async function resetCwdSetting(): Promise<void> {
24+
await changeCwdSetting(undefined);
25+
}
26+
1827
describe("The 'getSettings' method loads the 'Settings' class", function () {
28+
before(resetCwdSetting);
29+
1930
it("Loads without error", function () {
2031
assert.doesNotThrow(getSettings);
2132
});
@@ -29,29 +40,30 @@ describe("Settings E2E", function () {
2940

3041
describe("The 'changeSetting' method", function () {
3142
it("Updates correctly", async function () {
32-
await changeSetting("helpCompletion", CommentType.LineComment, false, undefined);
43+
await changeSetting("helpCompletion", CommentType.LineComment, vscode.ConfigurationTarget.Workspace, undefined);
3344
assert.strictEqual(getSettings().helpCompletion, CommentType.LineComment);
3445
});
3546
});
3647

3748
describe("The 'getEffectiveConfigurationTarget' method'", function () {
3849
it("Works for 'Workspace' target", async function () {
39-
await changeSetting("helpCompletion", CommentType.LineComment, false, undefined);
50+
await changeSetting("helpCompletion", CommentType.LineComment, vscode.ConfigurationTarget.Workspace, undefined);
4051
const target = getEffectiveConfigurationTarget("helpCompletion");
4152
assert.strictEqual(target, vscode.ConfigurationTarget.Workspace);
4253
});
4354

4455
it("Works for 'undefined' target", async function () {
45-
await changeSetting("helpCompletion", undefined, false, undefined);
56+
await changeSetting("helpCompletion", undefined, vscode.ConfigurationTarget.Workspace, undefined);
4657
const target = getEffectiveConfigurationTarget("helpCompletion");
4758
assert.strictEqual(target, undefined);
4859
});
4960
});
5061

5162
describe("The CWD setting", function () {
52-
beforeEach(async function () {
53-
await changeSetting("cwd", undefined, undefined, undefined);
54-
});
63+
// We're relying on this to be sure that the workspace is loaded.
64+
before(ensureEditorServicesIsConnected);
65+
before(resetCwdSetting);
66+
afterEach(resetCwdSetting);
5567

5668
const workspace = vscode.workspace.workspaceFolders![0].uri.fsPath;
5769

@@ -60,20 +72,26 @@ describe("Settings E2E", function () {
6072
});
6173

6274
it("Uses the default when given a non-existent folder", async function () {
63-
await changeSetting("cwd","/a/totally/fake/folder",undefined,undefined);
75+
await changeCwdSetting("/a/totally/fake/folder");
6476
assert.strictEqual(await validateCwdSetting(undefined), workspace);
6577
});
6678

6779
it("Uses the given folder when it exists", async function () {
6880
// A different than default folder that definitely exists
6981
const cwd = path.resolve(path.join(process.cwd(), ".."));
70-
await changeSetting("cwd",cwd,undefined,undefined);
82+
await changeCwdSetting(cwd);
7183
assert.strictEqual(await validateCwdSetting(undefined), cwd);
7284
});
7385

7486
it("Uses the home folder for ~ (tilde)", async function () {
75-
// A different than default folder that definitely exists
76-
await changeSetting("cwd", "~", undefined, undefined);
87+
await changeCwdSetting("~");
88+
assert.strictEqual(await validateCwdSetting(undefined), os.homedir());
89+
});
90+
91+
it("Resolves relative paths", async function () {
92+
// A different than default folder that definitely exists and is relative
93+
const cwd = path.join("~", "somewhere", "..");
94+
await changeCwdSetting(cwd);
7795
assert.strictEqual(await validateCwdSetting(undefined), os.homedir());
7896
});
7997
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /