Skip to content

Commit f2300d3

Browse files
authored
Make sure build command tests has no ordering requisite (#1213)
* Make sure build command tests can has no ordering requisite Right now the clean command test relies on the build command test to complete. That's not behaviour we want. Ideally tests should be able to run in isolation. Issue: #1184 * Retain the old test lay out - Add in per test tear down and required test step for clean command test
1 parent b87f8f3 commit f2300d3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

test/integration-tests/commands/build.test.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ suite("Build Commands", function () {
3535
let folderContext: FolderContext;
3636
let workspaceContext: WorkspaceContext;
3737
let settingsTeardown: () => Promise<void>;
38+
let buildPath: string;
3839
const uri = testAssetUri("defaultPackage/Sources/PackageExe/main.swift");
3940
const breakpoints = [
4041
new vscode.SourceBreakpoint(new vscode.Location(uri, new vscode.Position(2, 0))),
@@ -44,6 +45,7 @@ suite("Build Commands", function () {
4445
workspaceContext = await activateExtension();
4546
await waitForNoRunningTasks();
4647
folderContext = await folderInRootWorkspace("defaultPackage", workspaceContext);
48+
buildPath = path.join(folderContext.folder.fsPath, ".build");
4749
await workspaceContext.focusFolder(folderContext);
4850
await vscode.window.showTextDocument(uri);
4951
settingsTeardown = await updateSettings({
@@ -58,6 +60,13 @@ suite("Build Commands", function () {
5860
await deactivateExtension();
5961
});
6062

63+
teardown(() => {
64+
// Remove the build directory after each test case
65+
if (fs.existsSync(buildPath)) {
66+
fs.rmSync(buildPath, { recursive: true, force: true });
67+
}
68+
});
69+
6170
test("Swift: Run Build", async () => {
6271
// A breakpoint will have not effect on the Run command.
6372
vscode.debug.addBreakpoints(breakpoints);
@@ -69,10 +78,12 @@ suite("Build Commands", function () {
6978
});
7079

7180
test("Swift: Clean Build", async () => {
72-
const buildPath = path.join(folderContext.folder.fsPath, ".build");
81+
let result = await vscode.commands.executeCommand(Commands.RUN);
82+
expect(result).to.be.true;
83+
7384
const beforeItemCount = fs.readdirSync(buildPath).length;
7485

75-
const result = await vscode.commands.executeCommand(Commands.CLEAN_BUILD);
86+
result = await vscode.commands.executeCommand(Commands.CLEAN_BUILD);
7687
expect(result).to.be.true;
7788

7889
const afterItemCount = fs.readdirSync(buildPath).length;

0 commit comments

Comments
 (0)