Skip to content

Commit

Permalink
esm - port over unit test changes (microsoft#225711)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero authored Aug 15, 2024
1 parent bc94102 commit 02fcc99
Show file tree
Hide file tree
Showing 13 changed files with 2,501 additions and 75 deletions.
77 changes: 51 additions & 26 deletions build/azure-pipelines/darwin/product-build-darwin-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ parameters:
type: boolean
- name: VSCODE_RUN_SMOKE_TESTS
type: boolean
- name: VSCODE_BUILD_ESM
type: boolean
default: false

steps:
- script: yarn npm-run-all -lp "electron $(VSCODE_ARCH)" "playwright-install"
Expand All @@ -17,34 +20,56 @@ steps:

- ${{ if eq(parameters.VSCODE_RUN_UNIT_TESTS, true) }}:
- ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}:
- script: ./scripts/test.sh --tfs "Unit Tests"
displayName: Run unit tests (Electron)
timeoutInMinutes: 15

- script: yarn test-node
displayName: Run unit tests (node.js)
timeoutInMinutes: 15

- script: yarn test-browser-no-install --sequential --browser chromium --browser webkit --tfs "Browser Unit Tests"
env:
DEBUG: "*browser*"
displayName: Run unit tests (Browser, Chromium & Webkit)
timeoutInMinutes: 30
- ${{ if eq(parameters.VSCODE_BUILD_ESM, true) }}:
- script: ./scripts/test-esm.sh --tfs "Unit Tests"
displayName: Run unit tests (Electron) [ESM]
timeoutInMinutes: 15
- script: yarn test-node-esm
displayName: Run unit tests (node.js) [ESM]
timeoutInMinutes: 15
- script: yarn test-browser-esm-no-install --sequential --browser chromium --browser webkit --tfs "Browser Unit Tests"
env:
DEBUG: "*browser*"
displayName: Run unit tests (Browser, Chromium & Webkit) [ESM]
timeoutInMinutes: 30
- ${{ if eq(parameters.VSCODE_BUILD_ESM, false) }}:
- script: ./scripts/test.sh --tfs "Unit Tests"
displayName: Run unit tests (Electron)
timeoutInMinutes: 15
- script: yarn test-node
displayName: Run unit tests (node.js)
timeoutInMinutes: 15
- script: yarn test-browser-no-install --sequential --browser chromium --browser webkit --tfs "Browser Unit Tests"
env:
DEBUG: "*browser*"
displayName: Run unit tests (Browser, Chromium & Webkit)
timeoutInMinutes: 30

- ${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}:
- script: ./scripts/test.sh --build --tfs "Unit Tests"
displayName: Run unit tests (Electron)
timeoutInMinutes: 15

- script: yarn test-node --build
displayName: Run unit tests (node.js)
timeoutInMinutes: 15

- script: yarn test-browser-no-install --sequential --build --browser chromium --browser webkit --tfs "Browser Unit Tests"
env:
DEBUG: "*browser*"
displayName: Run unit tests (Browser, Chromium & Webkit)
timeoutInMinutes: 30
- ${{ if eq(parameters.VSCODE_BUILD_ESM, true) }}:
- script: ./scripts/test-esm.sh --build --tfs "Unit Tests"
displayName: Run unit tests (Electron) [ESM]
timeoutInMinutes: 15
- script: yarn test-node-esm --build
displayName: Run unit tests (node.js) [ESM]
timeoutInMinutes: 15
- script: yarn test-browser-esm-no-install --sequential --build --browser chromium --browser webkit --tfs "Browser Unit Tests"
env:
DEBUG: "*browser*"
displayName: Run unit tests (Browser, Chromium & Webkit) [ESM]
timeoutInMinutes: 30
- ${{ if eq(parameters.VSCODE_BUILD_ESM, false) }}:
- script: ./scripts/test.sh --build --tfs "Unit Tests"
displayName: Run unit tests (Electron)
timeoutInMinutes: 15
- script: yarn test-node --build
displayName: Run unit tests (node.js)
timeoutInMinutes: 15
- script: yarn test-browser-no-install --sequential --build --browser chromium --browser webkit --tfs "Browser Unit Tests"
env:
DEBUG: "*browser*"
displayName: Run unit tests (Browser, Chromium & Webkit)
timeoutInMinutes: 30

- ${{ if eq(parameters.VSCODE_RUN_INTEGRATION_TESTS, true) }}:
- script: |
Expand Down
82 changes: 55 additions & 27 deletions build/azure-pipelines/linux/product-build-linux-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ parameters:
- name: PUBLISH_TASK_NAME
type: string
default: PublishPipelineArtifact@0
- name: VSCODE_BUILD_ESM
type: boolean
default: false

steps:
- script: yarn npm-run-all -lp "electron $(VSCODE_ARCH)" "playwright-install"
Expand All @@ -33,36 +36,61 @@ steps:
- ${{ if eq(parameters.VSCODE_RUN_UNIT_TESTS, true) }}:
- ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}:
- script: ./scripts/test.sh --tfs "Unit Tests"
env:
DISPLAY: ":10"
displayName: Run unit tests (Electron)
timeoutInMinutes: 15

- script: yarn test-node
displayName: Run unit tests (node.js)
timeoutInMinutes: 15
- ${{ if eq(parameters.VSCODE_BUILD_ESM, true) }}:
- script: ./scripts/test-esm.sh --tfs "Unit Tests"
env:
DISPLAY: ":10"
displayName: Run unit tests (Electron) [ESM]
timeoutInMinutes: 15
- script: yarn test-node-esm
displayName: Run unit tests (node.js) [ESM]
timeoutInMinutes: 15
- script: yarn test-browser-esm-no-install --browser chromium --tfs "Browser Unit Tests"
env:
DEBUG: "*browser*"
displayName: Run unit tests (Browser, Chromium) [ESM]
timeoutInMinutes: 15
- ${{ if eq(parameters.VSCODE_BUILD_ESM, false) }}:
- script: ./scripts/test.sh --tfs "Unit Tests"
env:
DISPLAY: ":10"
displayName: Run unit tests (Electron)
timeoutInMinutes: 15
- script: yarn test-node
displayName: Run unit tests (node.js)
timeoutInMinutes: 15
- script: yarn test-browser-no-install --browser chromium --tfs "Browser Unit Tests"
env:
DEBUG: "*browser*"
displayName: Run unit tests (Browser, Chromium)
timeoutInMinutes: 15

- script: yarn test-browser-no-install --browser chromium --tfs "Browser Unit Tests"
env:
DEBUG: "*browser*"
displayName: Run unit tests (Browser, Chromium)
timeoutInMinutes: 15

- ${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}:
- script: ./scripts/test.sh --build --tfs "Unit Tests"
displayName: Run unit tests (Electron)
timeoutInMinutes: 15

- script: yarn test-node --build
displayName: Run unit tests (node.js)
timeoutInMinutes: 15

- script: yarn test-browser-no-install --build --browser chromium --tfs "Browser Unit Tests"
env:
DEBUG: "*browser*"
displayName: Run unit tests (Browser, Chromium)
timeoutInMinutes: 15
- ${{ if eq(parameters.VSCODE_BUILD_ESM, true) }}:
- script: ./scripts/test-esm.sh --build --tfs "Unit Tests"
displayName: Run unit tests (Electron) [ESM]
timeoutInMinutes: 15
- script: yarn test-node-esm --build
displayName: Run unit tests (node.js) [ESM]
timeoutInMinutes: 15
- script: yarn test-browser-esm-no-install --build --browser chromium --tfs "Browser Unit Tests"
env:
DEBUG: "*browser*"
displayName: Run unit tests (Browser, Chromium) [ESM]
timeoutInMinutes: 15
- ${{ if eq(parameters.VSCODE_BUILD_ESM, false) }}:
- script: ./scripts/test.sh --build --tfs "Unit Tests"
displayName: Run unit tests (Electron)
timeoutInMinutes: 15
- script: yarn test-node --build
displayName: Run unit tests (node.js)
timeoutInMinutes: 15
- script: yarn test-browser-no-install --build --browser chromium --tfs "Browser Unit Tests"
env:
DEBUG: "*browser*"
displayName: Run unit tests (Browser, Chromium)
timeoutInMinutes: 15

- ${{ if eq(parameters.VSCODE_RUN_INTEGRATION_TESTS, true) }}:
- script: |
Expand Down
65 changes: 43 additions & 22 deletions build/azure-pipelines/win32/product-build-win32-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ parameters:
- name: PUBLISH_TASK_NAME
type: string
default: PublishPipelineArtifact@0
- name: VSCODE_BUILD_ESM
type: boolean
default: false

steps:
- powershell: yarn npm-run-all -lp "electron $(VSCODE_ARCH)" "playwright-install"
Expand All @@ -22,30 +25,48 @@ steps:

- ${{ if eq(parameters.VSCODE_RUN_UNIT_TESTS, true) }}:
- ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}:
- powershell: .\scripts\test.bat --tfs "Unit Tests"
displayName: Run unit tests (Electron)
timeoutInMinutes: 15

- powershell: yarn test-node
displayName: Run unit tests (node.js)
timeoutInMinutes: 15

- powershell: node test/unit/browser/index.js --sequential --browser chromium --tfs "Browser Unit Tests"
displayName: Run unit tests (Browser, Chromium)
timeoutInMinutes: 20
- ${{ if eq(parameters.VSCODE_BUILD_ESM, true) }}:
- powershell: .\scripts\test-esm.bat --tfs "Unit Tests"
displayName: Run unit tests (Electron) [ESM]
timeoutInMinutes: 15
- powershell: yarn test-node-esm
displayName: Run unit tests (node.js) [ESM]
timeoutInMinutes: 15
- powershell: node test/unit/browser/index.esm.js --sequential --browser chromium --tfs "Browser Unit Tests"
displayName: Run unit tests (Browser, Chromium) [ESM]
timeoutInMinutes: 20
- ${{ if eq(parameters.VSCODE_BUILD_ESM, false) }}:
- powershell: .\scripts\test.bat --tfs "Unit Tests"
displayName: Run unit tests (Electron)
timeoutInMinutes: 15
- powershell: yarn test-node
displayName: Run unit tests (node.js)
timeoutInMinutes: 15
- powershell: node test/unit/browser/index.js --sequential --browser chromium --tfs "Browser Unit Tests"
displayName: Run unit tests (Browser, Chromium)
timeoutInMinutes: 20

- ${{ if ne(parameters.VSCODE_QUALITY, 'oss') }}:
- powershell: .\scripts\test.bat --build --tfs "Unit Tests"
displayName: Run unit tests (Electron)
timeoutInMinutes: 15

- powershell: yarn test-node --build
displayName: Run unit tests (node.js)
timeoutInMinutes: 15

- powershell: yarn test-browser-no-install --sequential --build --browser chromium --tfs "Browser Unit Tests"
displayName: Run unit tests (Browser, Chromium)
timeoutInMinutes: 20
- ${{ if eq(parameters.VSCODE_BUILD_ESM, true) }}:
- powershell: .\scripts\test-esm.bat --build --tfs "Unit Tests"
displayName: Run unit tests (Electron) [ESM]
timeoutInMinutes: 15
- script: yarn test-node-esm --build
displayName: Run unit tests (node.js) [ESM]
timeoutInMinutes: 15
- powershell: yarn test-browser-esm-no-install --sequential --build --browser chromium --tfs "Browser Unit Tests"
displayName: Run unit tests (Browser, Chromium) [ESM]
timeoutInMinutes: 20
- ${{ if eq(parameters.VSCODE_BUILD_ESM, false) }}:
- powershell: .\scripts\test.bat --build --tfs "Unit Tests"
displayName: Run unit tests (Electron)
timeoutInMinutes: 15
- powershell: yarn test-node --build
displayName: Run unit tests (node.js)
timeoutInMinutes: 15
- powershell: yarn test-browser-no-install --sequential --build --browser chromium --tfs "Browser Unit Tests"
displayName: Run unit tests (Browser, Chromium)
timeoutInMinutes: 20

- ${{ if eq(parameters.VSCODE_RUN_INTEGRATION_TESTS, true) }}:
- powershell: |
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
"scripts": {
"test": "echo Please run any of the test scripts from the scripts folder.",
"test-browser": "npx playwright install && node test/unit/browser/index.js",
"test-browser-esm": "npx playwright install && node test/unit/browser/index.esm.js",
"test-browser-no-install": "node test/unit/browser/index.js",
"test-browser-esm-no-install": "node test/unit/browser/index.esm.js",
"test-node": "mocha test/unit/node/index.js --delay --ui=tdd --timeout=5000 --exit",
"test-node-esm": "mocha test/unit/node/index.mjs --delay --ui=tdd --timeout=5000 --exit",
"test-extension": "vscode-test",
"preinstall": "node build/npm/preinstall.js",
"postinstall": "node build/npm/postinstall.js",
Expand Down
31 changes: 31 additions & 0 deletions scripts/test-esm.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@echo off
setlocal

set ELECTRON_RUN_AS_NODE=

pushd %~dp0\..

:: Get Code.exe location
for /f "tokens=2 delims=:," %%a in ('findstr /R /C:"\"nameShort\":.*" product.json') do set NAMESHORT=%%~a
set NAMESHORT=%NAMESHORT: "=%
set NAMESHORT=%NAMESHORT:"=%.exe
set CODE=".build\electron\%NAMESHORT%"

:: Download Electron if needed
call node build\lib\electron.js
if %errorlevel% neq 0 node .\node_modules\gulp\bin\gulp.js electron

:: Run tests
set ELECTRON_ENABLE_LOGGING=1
%CODE% .\test\unit\electron\index.esm.js --crash-reporter-directory=%~dp0\..\.build\crashes %*

popd

endlocal

:: app.exit(0) is exiting with code 255 in Electron 1.7.4.
:: See https://github.com/microsoft/vscode/issues/28582
echo errorlevel: %errorlevel%
if %errorlevel% == 255 set errorlevel=0

exit /b %errorlevel%
43 changes: 43 additions & 0 deletions scripts/test-esm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
set -e

if [[ "$OSTYPE" == "darwin"* ]]; then
realpath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"; }
ROOT=$(dirname $(dirname $(realpath "$0")))
else
ROOT=$(dirname $(dirname $(readlink -f $0)))
# --disable-dev-shm-usage: when run on docker containers where size of /dev/shm
# partition < 64MB which causes OOM failure for chromium compositor that uses the partition for shared memory
LINUX_EXTRA_ARGS="--disable-dev-shm-usage"
fi

cd $ROOT

if [[ "$OSTYPE" == "darwin"* ]]; then
NAME=`node -p "require('./product.json').nameLong"`
CODE="./.build/electron/$NAME.app/Contents/MacOS/Electron"
else
NAME=`node -p "require('./product.json').applicationName"`
CODE=".build/electron/$NAME"
fi

VSCODECRASHDIR=$ROOT/.build/crashes

# Node modules
test -d node_modules || yarn

# Get electron
yarn electron

# Unit Tests
if [[ "$OSTYPE" == "darwin"* ]]; then
cd $ROOT ; ulimit -n 4096 ; \
ELECTRON_ENABLE_LOGGING=1 \
"$CODE" \
test/unit/electron/index.esm.js --crash-reporter-directory=$VSCODECRASHDIR "$@"
else
cd $ROOT ; \
ELECTRON_ENABLE_LOGGING=1 \
"$CODE" \
test/unit/electron/index.esm.js --crash-reporter-directory=$VSCODECRASHDIR $LINUX_EXTRA_ARGS "$@"
fi
Loading

0 comments on commit 02fcc99

Please sign in to comment.