diff --git a/build/azure-pipelines/linux/sql-product-build-linux.yml b/build/azure-pipelines/linux/sql-product-build-linux.yml index 3edaff0dd1..112e68e141 100644 --- a/build/azure-pipelines/linux/sql-product-build-linux.yml +++ b/build/azure-pipelines/linux/sql-product-build-linux.yml @@ -133,7 +133,8 @@ steps: set -e APP_ROOT=$(agent.builddirectory)/azuredatastudio-linux-x64 APP_NAME=$(node -p "require(\"$APP_ROOT/resources/app/product.json\").applicationName") - INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME" \ + export INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME" \ + export NO_CLEANUP=1 DISPLAY=:10 node ./scripts/test-extensions-unit.js ${{ extension }} displayName: 'Run ${{ extension }} Stable Extension Unit Tests' condition: and(succeeded(), eq(variables['RUN_TESTS'], 'true')) @@ -148,6 +149,14 @@ steps: continueOnError: true condition: and(succeeded(), eq(variables['RUN_UNSTABLE_TESTS'], 'true')) + - script: | + set -e + mkdir -p $(Build.ArtifactStagingDirectory)/logs/linux-x64 + cd /tmp + tar -czvf $(Build.ArtifactStagingDirectory)/logs/linux-x64/logs-linux-x64.tar.gz adsuser* + displayName: Archive Logs + continueOnError: true + - script: | set -e yarn gulp vscode-linux-x64-build-deb diff --git a/scripts/test-extensions-unit.bat b/scripts/test-extensions-unit.bat index 2ed245ac79..3019119dfe 100755 --- a/scripts/test-extensions-unit.bat +++ b/scripts/test-extensions-unit.bat @@ -117,8 +117,10 @@ if "%RUN_DBPROJECT_TESTS%" == "true" ( if %errorlevel% neq 0 exit /b %errorlevel% -rmdir /s /q %VSCODEUSERDATADIR% -rmdir /s /q %VSCODEEXTENSIONSDIR% +if "%NO_CLEANUP%"=="" ( + rmdir /s /q %VSCODEUSERDATADIR% + rmdir /s /q %VSCODEEXTENSIONSDIR% +) popd diff --git a/scripts/test-extensions-unit.js b/scripts/test-extensions-unit.js index 577ffdc56b..f698e50d37 100644 --- a/scripts/test-extensions-unit.js +++ b/scripts/test-extensions-unit.js @@ -33,14 +33,6 @@ let argv = require('yargs') .default('extensions', extensionList) .strict().help().wrap(null).version(false).argv; -// set up environment - -const VSCODEUSERDATADIR = tmp.dirSync({ prefix: 'adsuser' }).name; -const VSCODEEXTENSIONSDIR = tmp.dirSync({ prefix: 'adsext' }).name; - -console.log(VSCODEUSERDATADIR); -console.log(VSCODEEXTENSIONSDIR); - if (!process.env.INTEGRATION_TEST_ELECTRON_PATH) { process.env.INTEGRATION_TEST_ELECTRON_PATH = path.join(__dirname, '..', 'scripts', os.platform() === 'win32' ? 'code.bat' : 'code.sh'); console.log('Running unit tests out of sources.'); @@ -67,6 +59,14 @@ for (const ext of argv.extensions) { console.log(`*** starting ${ext} tests ***`); console.log('*'.repeat(ext.length + 23)); + // set up environment + + const VSCODEUSERDATADIR = tmp.dirSync({ prefix: `adsuser_${ext}` }).name; + const VSCODEEXTENSIONSDIR = tmp.dirSync({ prefix: `adsext_${ext}` }).name; + + console.log(`VSCODEUSERDATADIR : ${VSCODEUSERDATADIR}`); + console.log(`VSCODEEXTENSIONSDIR : ${VSCODEEXTENSIONSDIR}`); + const command = `${process.env.INTEGRATION_TEST_ELECTRON_PATH} --no-sandbox --extensionDevelopmentPath=${path.join(__dirname, '..', 'extensions', ext)} --extensionTestsPath=${path.join(__dirname, '..', 'extensions', ext, 'out', 'test')} --user-data-dir=${VSCODEUSERDATADIR} --extensions-dir=${VSCODEEXTENSIONSDIR} --remote-debugging-port=9222 --disable-telemetry --disable-crash-reporter --disable-updates --nogpu`; console.log(`Command used: ${command}`); console.log(execSync(command, { stdio: 'inherit' })); @@ -74,5 +74,7 @@ for (const ext of argv.extensions) { // clean up -fs.remove(VSCODEUSERDATADIR, { recursive: true }).catch(console.error); -fs.remove(VSCODEEXTENSIONSDIR, { recursive: true }).catch(console.error); +if (!process.env.NO_CLEANUP) { + fs.remove(VSCODEUSERDATADIR, { recursive: true }).catch(console.error); + fs.remove(VSCODEEXTENSIONSDIR, { recursive: true }).catch(console.error); +} diff --git a/scripts/test-extensions-unit.sh b/scripts/test-extensions-unit.sh index 217e13c72c..4a0e69ad02 100755 --- a/scripts/test-extensions-unit.sh +++ b/scripts/test-extensions-unit.sh @@ -111,5 +111,7 @@ if [[ "$RUN_DBPROJECT_TESTS" == "true" ]]; then "$INTEGRATION_TEST_ELECTRON_PATH" $LINUX_NO_SANDBOX --extensionDevelopmentPath=$ROOT/extensions/sql-database-projects --extensionTestsPath=$ROOT/extensions/sql-database-projects/out/test --user-data-dir=$VSCODEUSERDATADIR --extensions-dir=$VSCODEEXTDIR --disable-telemetry --disable-crash-reporter --disable-updates --nogpu fi -rm -r $VSCODEUSERDATADIR -rm -r $VSCODEEXTDIR +if [[ "$NO_CLEANUP" == "" ]]; then + rm -r $VSCODEUSERDATADIR + rm -r $VSCODEEXTDIR +fi