Skip to content

Commit 7549763

Browse files
committed
fix: patch test VS Code after download to suppress macOS windows
The hide-test-vscode.sh script was running before VS Code was downloaded, so the LSUIElement patch had no .app bundles to apply to. Now: - runExtensionTests.ts calls downloadAndUnzipVSCode() first, then patches - CI splits UI tests into setup -> patch -> run - hide script also covers ExTester's test-resources/ directory - Removed redundant pre-patch calls from npm scripts Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent 36d7aaf commit 7549763

4 files changed

Lines changed: 30 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,14 @@ jobs:
6060
- name: Install dependencies
6161
run: npm ci
6262

63-
- name: Patch test VS Code to run as background app
64-
run: bash scripts/hide-test-vscode.sh
65-
6663
- name: Run VS Code extension tests
6764
run: npm run test:all
6865

66+
- name: Setup UI test VS Code
67+
run: npx extest setup-tests --code_version max --extensions_dir .vscode-test/extensions
68+
69+
- name: Patch test VS Code to run as background app
70+
run: bash scripts/hide-test-vscode.sh
71+
6972
- name: Run UI tests
70-
run: npm run test:ui
73+
run: npx extest run-tests './out-uitest/test/ui/*.test.js' --extensions_dir .vscode-test/extensions

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@
110110
"compile-uitests": "tsc -p ./tsconfig.uitest.json",
111111
"watch": "tsc -watch -p ./",
112112
"test:unit": "node --test ./out-test/test/unit/*.test.js",
113-
"test:extension": "bash scripts/hide-test-vscode.sh && node ./out-test/test/suite/runExtensionTests.js",
113+
"test:extension": "node ./out-test/test/suite/runExtensionTests.js",
114114
"test:ui": "npm run compile && npm run compile-uitests && extest setup-and-run './out-uitest/test/ui/*.test.js' --code_version max --extensions_dir .vscode-test/extensions",
115115
"test": "npm run compile && npm run compile-tests && npm run test:unit",
116-
"test:all": "npm run compile && npm run compile-tests && bash scripts/hide-test-vscode.sh && npm run test:unit && npm run test:extension",
116+
"test:all": "npm run compile && npm run compile-tests && npm run test:unit && npm run test:extension",
117117
"vscode:prepublish": "npm run compile",
118118
"package": "vsce package",
119119
"check": "npm run test && npm run package"

scripts/hide-test-vscode.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
# background apps (no Dock icon, no Cmd+Tab, no focus stealing).
44
# Safe to run multiple times; skips already-patched bundles.
55
# No-op on Linux/Windows.
6+
#
7+
# Covers:
8+
# .vscode-test/ — @vscode/test-electron downloads
9+
# $TMPDIR/test-resources/ — vscode-extension-tester (ExTester) downloads
610

711
set -euo pipefail
812

@@ -13,8 +17,12 @@ fi
1317
patched=0
1418
shopt -s nullglob
1519

20+
# ExTester uses $TEST_RESOURCES or $TMPDIR/test-resources
21+
extest_dir="${TEST_RESOURCES:-${TMPDIR:-/tmp}/test-resources}"
22+
1623
for plist in \
17-
.vscode-test/*/Visual\ Studio\ Code*.app/Contents/Info.plist; do
24+
.vscode-test/*/Visual\ Studio\ Code*.app/Contents/Info.plist \
25+
"$extest_dir"/*/Visual\ Studio\ Code*.app/Contents/Info.plist; do
1826
[ -f "$plist" ] || continue
1927

2028
if plutil -extract LSUIElement raw "$plist" >/dev/null 2>&1; then

test/suite/runExtensionTests.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
import * as path from "node:path";
2-
import { runTests } from "@vscode/test-electron";
2+
import { execSync } from "node:child_process";
3+
import { downloadAndUnzipVSCode, runTests } from "@vscode/test-electron";
34

45
async function main(): Promise<void> {
56
const extensionDevelopmentPath = path.resolve(__dirname, "../../..");
67
const extensionTestsPath = path.resolve(__dirname, "./index.js");
78

9+
// Download VS Code FIRST so the .app bundle exists on disk
10+
const vscodeExecutablePath = await downloadAndUnzipVSCode();
11+
12+
// Patch the downloaded bundle to suppress Dock icon / window focus on macOS
13+
execSync("bash scripts/hide-test-vscode.sh", {
14+
cwd: extensionDevelopmentPath,
15+
stdio: "inherit",
16+
});
17+
818
await runTests({
19+
vscodeExecutablePath,
920
extensionDevelopmentPath,
1021
extensionTestsPath,
1122
launchArgs: [

0 commit comments

Comments
 (0)