diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 6afcac3c3..4ffd2739e 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -45,8 +45,10 @@ jobs: tests: name: ${{ contains(github.event.pull_request.labels.*.name, 'full-test-run') && 'Full Test Run' || 'Test'}} + needs: package uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main with: + needs_token: true # Linux linux_exclude_swift_versions: '[{"swift_version": "nightly-6.1"},{"swift_version": "nightly-6.2"},{"swift_version": "nightly-main"}]' linux_env_vars: | @@ -55,6 +57,8 @@ jobs: NVM_DIR=/usr/local/nvm CI=1 FAST_TEST_RUN=${{ contains(github.event.pull_request.labels.*.name, 'full-test-run') && '0' || '1'}} + VSCODE_SWIFT_VSIX_ID=${{needs.package.outputs.artifact-id}} + GITHUB_REPOSITORY=${{github.repository}} linux_pre_build_command: . .github/workflows/scripts/setup-linux.sh linux_build_command: ./scripts/test.sh # Windows @@ -62,6 +66,9 @@ jobs: windows_env_vars: | CI=1 FAST_TEST_RUN=${{ contains(github.event.pull_request.labels.*.name, 'full-test-run') && '0' || '1'}} + VSCODE_SWIFT_VSIX_ID=${{needs.package.outputs.artifact-id}} + VSCODE_SWIFT_VSIX=vscode-swift.vsix + GITHUB_REPOSITORY=${{github.repository}} windows_pre_build_command: .github\workflows\scripts\windows\setup.ps1 windows_build_command: scripts\test_windows.ps1 enable_windows_docker: false diff --git a/.vscode-test.js b/.vscode-test.js index ad3faf00d..49ee95ac6 100644 --- a/.vscode-test.js +++ b/.vscode-test.js @@ -70,6 +70,9 @@ module.exports = defineConfig({ extensionDevelopmentPath: vsixPath ? [`${__dirname}/.vscode-test/extensions/${publisher}.${name}-${version}`] : undefined, + env: { + VSCODE_TEST: "1", + }, mocha: { ui: "tdd", color: true, @@ -106,6 +109,9 @@ module.exports = defineConfig({ extensionDevelopmentPath: vsixPath ? [`${__dirname}/.vscode-test/extensions/${publisher}.${name}-${version}`] : undefined, + env: { + VSCODE_TEST: "1", + }, mocha: { ui: "tdd", color: true, @@ -130,6 +136,9 @@ module.exports = defineConfig({ files: ["dist/test/common.js", "dist/test/unit-tests/**/*.test.js"], version: process.env["VSCODE_VERSION"] ?? "stable", launchArgs: launchArgs.concat("--disable-extensions"), + env: { + VSCODE_TEST: "1", + }, mocha: { ui: "tdd", color: true, diff --git a/src/TestExplorer/TestRunner.ts b/src/TestExplorer/TestRunner.ts index 1555e7f46..e64a4066f 100644 --- a/src/TestExplorer/TestRunner.ts +++ b/src/TestExplorer/TestRunner.ts @@ -23,6 +23,7 @@ import { execFile, getErrorDescription, IS_PRODUCTION_BUILD, + IS_RUNNING_UNDER_TEST, } from "../utilities/utilities"; import { createSwiftTask } from "../tasks/SwiftTaskProvider"; import configuration from "../configuration"; @@ -244,7 +245,7 @@ export class TestRunProxy { } private clearEnqueuedTest(test: vscode.TestItem) { - if (IS_PRODUCTION_BUILD) { + if (IS_PRODUCTION_BUILD && !IS_RUNNING_UNDER_TEST) { // `runState.enqueued` exists only for test validation purposes. return; } diff --git a/src/utilities/utilities.ts b/src/utilities/utilities.ts index a3b6c8933..af7b3efbf 100644 --- a/src/utilities/utilities.ts +++ b/src/utilities/utilities.ts @@ -36,6 +36,13 @@ export const IS_PRODUCTION_BUILD = process.env.NODE_ENV === "production"; */ export const IS_RUNNING_IN_CI = process.env.CI === "1"; +/** + * Whether or not the code is being run as part of a test suite. + * + * This will NOT be removed when the extension is packaged into a VSIX. + */ +export const IS_RUNNING_UNDER_TEST = process.env.VSCODE_TEST === "1"; + /** * Get required environment variable for Swift product *