Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address some issues found when running test locally #1217

Merged
merged 5 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/test/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"-Xswiftc",
"-DTEST_ARGUMENT_SET_VIA_TEST_BUILD_ARGUMENTS_SETTING"
],
"lldb.verboseLogging": true
"lldb.verboseLogging": true,
"swift.backgroundCompilation": false
}
17 changes: 5 additions & 12 deletions test/integration-tests/commands/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ import {
folderInRootWorkspace,
updateSettings,
} from "../utilities/testutilities";
import { pathExists } from "../../../src/utilities/filesystem";

suite("Build Commands", function () {
// Default timeout is a bit too short, give it a little bit more time
this.timeout(30 * 1000);

let folderContext: FolderContext;
let workspaceContext: WorkspaceContext;
let buildPath: string;
const uri = testAssetUri("defaultPackage/Sources/PackageExe/main.swift");
const breakpoints = [
new vscode.SourceBreakpoint(new vscode.Location(uri, new vscode.Position(2, 0))),
Expand All @@ -45,7 +46,6 @@ suite("Build Commands", function () {
workspaceContext = ctx;
await waitForNoRunningTasks();
folderContext = await folderInRootWorkspace("defaultPackage", workspaceContext);
buildPath = path.join(folderContext.folder.fsPath, ".build");
await workspaceContext.focusFolder(folderContext);
await vscode.window.showTextDocument(uri);
const settingsTeardown = await updateSettings({
Expand All @@ -59,13 +59,6 @@ suite("Build Commands", function () {
},
});

teardown(async () => {
// Remove the build directory after each test case
if (await pathExists(buildPath)) {
await fs.rm(buildPath, { recursive: true, force: true });
}
});

test("Swift: Run Build", async () => {
// A breakpoint will have not effect on the Run command.
vscode.debug.addBreakpoints(breakpoints);
Expand All @@ -80,14 +73,14 @@ suite("Build Commands", function () {
let result = await vscode.commands.executeCommand(Commands.RUN);
expect(result).to.be.true;

const buildPath = path.join(folderContext.folder.fsPath, ".build");
const beforeItemCount = (await fs.readdir(buildPath)).length;

result = await vscode.commands.executeCommand(Commands.CLEAN_BUILD);
expect(result).to.be.true;

const afterItemCount = (await fs.readdir(buildPath)).length;
// This test will run in order after the Swift: Run Build test,
// where .build folder is going to be filled with built artifacts.
// .build folder is going to be filled with built artifacts after Commands.RUN command
// After executing the clean command the build directory is guranteed to have less entry.
expect(afterItemCount).to.be.lessThan(beforeItemCount);
});
Expand Down
45 changes: 22 additions & 23 deletions test/integration-tests/commands/dependency.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,27 @@ suite("Dependency Commmands Test Suite", function () {
// 15 seconds for each test should be more than enough
this.timeout(15 * 1000);

suite("spm Resolve Update Contract Tests", function () {
suite("spm Update Contract Tests", function () {
let folderContext: FolderContext;
let workspaceContext: WorkspaceContext;

activateExtensionForSuite({
async setup(ctx) {
workspaceContext = ctx;
await waitForNoRunningTasks();
folderContext = await folderInRootWorkspace("defaultPackage", workspaceContext);
await workspaceContext.focusFolder(folderContext);
},
});

test("Contract: spm update", async function () {
// Contract: spm update
const result = await vscode.commands.executeCommand(Commands.UPDATE_DEPENDENCIES);
expect(result).to.be.true;
});
});

suite("spm Resolve Contract Tests", function () {
let folderContext: FolderContext;
let workspaceContext: WorkspaceContext;

Expand Down Expand Up @@ -100,10 +120,7 @@ suite("Dependency Commmands Test Suite", function () {

// This will now pass as we have the required library
const { exitCode, output } = await executeTaskAndWaitForResult(tasks);
if (exitCode !== 0) {
console.warn("Exit code non zero, command output:\n", output);
}
expect(exitCode).to.equal(0);
expect(exitCode, `${output}`).to.equal(0);
expect(output).to.include("defaultpackage");
expect(output).to.include("not used by any target");
}
Expand Down Expand Up @@ -135,23 +152,5 @@ suite("Dependency Commmands Test Suite", function () {

await assertDependencyNoLongerExists();
});

test("Contract: spm update", async function () {
// This test is flaky, test in CI setting when the below change get merged in and find
// out exactly where the command fails.
// https://github.com/swiftlang/vscode-swift/pull/1194
this.skip();
await useLocalDependencyTest();

// Contract: spm update
let result = await vscode.commands.executeCommand(Commands.UPDATE_DEPENDENCIES);
expect(result).to.be.true;

// Clean up
result = await vscode.commands.executeCommand(Commands.UNEDIT_DEPENDENCY, item);
expect(result).to.be.true;

await assertDependencyNoLongerExists();
});
});
});
Loading