Skip to content

Fix test explorer tests in nightly build #1689

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

Merged
merged 2 commits into from
Jul 4, 2025
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
7 changes: 7 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -55,13 +57,18 @@ 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
windows_exclude_swift_versions: '[{"swift_version": "nightly-6.1"},{"swift_version": "nightly-6.2"},{"swift_version": "nightly"}]'
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
Expand Down
9 changes: 9 additions & 0 deletions .vscode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/TestExplorer/TestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions src/utilities/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
Loading