-
Notifications
You must be signed in to change notification settings - Fork 84
Add integration tests for build commands #1185
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
Changes from all commits
690f49d
6476307
240dc39
da75453
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This source file is part of the VS Code Swift open source project | ||
| // | ||
| // Copyright (c) 2024 the VS Code Swift project authors | ||
| // Licensed under Apache License v2.0 | ||
| // | ||
| // See LICENSE.txt for license information | ||
| // See CONTRIBUTORS.txt for the list of VS Code Swift project authors | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| export enum Workbench { | ||
| ACTION_DEBUG_CONTINUE = "workbench.action.debug.continue", | ||
| ACTION_CLOSEALLEDITORS = "workbench.action.closeAllEditors", | ||
| ACTION_RELOADWINDOW = "workbench.action.reloadWindow", | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This source file is part of the VS Code Swift open source project | ||
| // | ||
| // Copyright (c) 2024 the VS Code Swift project authors | ||
| // Licensed under Apache License v2.0 | ||
| // | ||
| // See LICENSE.txt for license information | ||
| // See CONTRIBUTORS.txt for the list of VS Code Swift project authors | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| import * as vscode from "vscode"; | ||
| import * as fs from "fs"; | ||
| import * as path from "path"; | ||
| import { expect } from "chai"; | ||
| import { folderContextPromise, globalWorkspaceContextPromise } from "../extension.test"; | ||
| import { waitForNoRunningTasks } from "../../utilities"; | ||
| import { testAssetUri } from "../../fixtures"; | ||
| import { FolderContext } from "../../../src/FolderContext"; | ||
| import { WorkspaceContext } from "../../../src/WorkspaceContext"; | ||
| import { Commands } from "../../../src/commands"; | ||
| import { makeDebugConfigurations } from "../../../src/debugger/launch"; | ||
| import { Workbench } from "../../../src/utilities/commands"; | ||
| import { continueSession, waitForDebugAdapterCommand } from "../../utilities/debug"; | ||
| import { SettingsMap, updateSettings } from "../testexplorer/utilities"; | ||
|
|
||
| suite("Build Commands", function () { | ||
| let folderContext: FolderContext; | ||
| let workspaceContext: WorkspaceContext; | ||
| let settingsTeardown: () => Promise<SettingsMap>; | ||
| const uri = testAssetUri("defaultPackage/Sources/PackageExe/main.swift"); | ||
| const breakpoints = [ | ||
| new vscode.SourceBreakpoint(new vscode.Location(uri, new vscode.Position(2, 0))), | ||
| ]; | ||
|
|
||
| suiteSetup(async function () { | ||
| workspaceContext = await globalWorkspaceContextPromise; | ||
| await waitForNoRunningTasks(); | ||
| folderContext = await folderContextPromise("defaultPackage"); | ||
| await workspaceContext.focusFolder(folderContext); | ||
| await vscode.window.showTextDocument(uri); | ||
| settingsTeardown = await updateSettings({ | ||
| "swift.autoGenerateLaunchConfigurations": true, | ||
| }); | ||
| await makeDebugConfigurations(folderContext, undefined, true); | ||
| }); | ||
|
|
||
| suiteTeardown(async () => { | ||
| await settingsTeardown(); | ||
| await vscode.commands.executeCommand(Workbench.ACTION_CLOSEALLEDITORS); | ||
| }); | ||
|
|
||
| test("Swift: Run Build", async () => { | ||
| // A breakpoint will have not effect on the Run command. | ||
| vscode.debug.addBreakpoints(breakpoints); | ||
|
|
||
| const result = await vscode.commands.executeCommand(Commands.RUN); | ||
| expect(result).to.be.true; | ||
|
|
||
| vscode.debug.removeBreakpoints(breakpoints); | ||
| }); | ||
|
|
||
| test("Swift: Clean Build", async () => { | ||
| const buildPath = path.join(folderContext.folder.fsPath, ".build"); | ||
| const beforeItemCount = fs.readdirSync(buildPath).length; | ||
|
|
||
| const result = await vscode.commands.executeCommand(Commands.CLEAN_BUILD); | ||
| expect(result).to.be.true; | ||
|
|
||
| const afterItemCount = fs.readdirSync(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. | ||
| // After executing the clean command the build directory is guranteed to have less entry. | ||
| expect(afterItemCount).to.be.lessThan(beforeItemCount); | ||
michael-weng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }); | ||
|
|
||
| test("Swift: Debug Build @slow", async () => { | ||
| vscode.debug.addBreakpoints(breakpoints); | ||
| // Promise used to indicate we hit the break point. | ||
| // NB: "stopped" is the exact command when debuggee has stopped due to break point, | ||
| // but "stackTrace" is the deterministic sync point we will use to make sure we can execute continue | ||
| const bpPromise = waitForDebugAdapterCommand( | ||
| "Debug PackageExe (defaultPackage)", | ||
| "stackTrace", | ||
| workspaceContext | ||
| ); | ||
|
|
||
| const result = vscode.commands.executeCommand(Commands.DEBUG); | ||
| expect(result).to.eventually.be.true; | ||
|
|
||
| await bpPromise.then(() => continueSession()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we're hitting breakpoints, crossing into smoke level, let's create a smoke suite and put that there
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought that's what @slow do right now?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. still should split into separate suite. Is it actually slow or just trying to keep out of CI build?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are we trying to achieve to split this into a separate suite? Is it for dependency management? Given the test run fast and this is a command that should probably always work, I am not sure if we want keep this out of CI.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will leave this for until long term approach is decided |
||
| vscode.debug.removeBreakpoints(breakpoints); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.