Skip to content

Commit 75b16b3

Browse files
committed
Make VS Code test windows invisible on macOS
- Add scripts/hide-test-vscode.sh: patches downloaded test VS Code bundles with LSUIElement=true so they run as background apps (no Dock icon, no Cmd+Tab, no focus stealing) - Wire the patch into test:extension and test:all npm scripts - Add --disable-gpu and --disable-gpu-sandbox to runExtensionTests.ts - npm run check remains unchanged (unit tests only, no VS Code) Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
1 parent 68abaf1 commit 75b16b3

3 files changed

Lines changed: 38 additions & 3 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@
109109
"compile-uitests": "tsc -p ./tsconfig.uitest.json",
110110
"watch": "tsc -watch -p ./",
111111
"test:unit": "node --test ./out-test/test/unit/*.test.js",
112-
"test:extension": "node ./out-test/test/suite/runExtensionTests.js",
112+
"test:extension": "bash scripts/hide-test-vscode.sh && node ./out-test/test/suite/runExtensionTests.js",
113113
"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",
114114
"test": "npm run compile && npm run compile-tests && npm run test:unit",
115-
"test:all": "npm run compile && npm run compile-tests && npm run test:unit && npm run test:extension",
115+
"test:all": "npm run compile && npm run compile-tests && bash scripts/hide-test-vscode.sh && npm run test:unit && npm run test:extension",
116116
"vscode:prepublish": "npm run compile",
117117
"package": "vsce package",
118118
"check": "npm run test && npm run package"

scripts/hide-test-vscode.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
# Patch all downloaded test VS Code .app bundles on macOS to run as
3+
# background apps (no Dock icon, no Cmd+Tab, no focus stealing).
4+
# Safe to run multiple times; skips already-patched bundles.
5+
# No-op on Linux/Windows.
6+
7+
set -euo pipefail
8+
9+
if [[ "$(uname -s)" != "Darwin" ]]; then
10+
exit 0
11+
fi
12+
13+
patched=0
14+
shopt -s nullglob
15+
16+
for plist in \
17+
.vscode-test/*/Visual\ Studio\ Code*.app/Contents/Info.plist; do
18+
[ -f "$plist" ] || continue
19+
20+
if plutil -extract LSUIElement raw "$plist" >/dev/null 2>&1; then
21+
continue
22+
fi
23+
24+
plutil -insert LSUIElement -bool true "$plist"
25+
patched=$((patched + 1))
26+
echo "Patched: $plist"
27+
done
28+
29+
if [[ $patched -eq 0 ]]; then
30+
echo "No test VS Code bundles to patch"
31+
fi

test/suite/runExtensionTests.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ async function main(): Promise<void> {
88
await runTests({
99
extensionDevelopmentPath,
1010
extensionTestsPath,
11-
launchArgs: [extensionDevelopmentPath]
11+
launchArgs: [
12+
extensionDevelopmentPath,
13+
"--disable-gpu",
14+
"--disable-gpu-sandbox"
15+
]
1216
});
1317
}
1418

0 commit comments

Comments
 (0)