tests - enable crash reporter for electron based unit tests
//cc @deepak1556
This commit is contained in:
parent
b8357ede65
commit
ddbda4c196
|
@ -17,7 +17,7 @@ if %errorlevel% neq 0 node .\node_modules\gulp\bin\gulp.js electron
|
||||||
|
|
||||||
:: Run tests
|
:: Run tests
|
||||||
set ELECTRON_ENABLE_LOGGING=1
|
set ELECTRON_ENABLE_LOGGING=1
|
||||||
%CODE% .\test\unit\electron\index.js %*
|
%CODE% .\test\unit\electron\index.js --crash-reporter-directory=%~dp0\..\.build\crashes %*
|
||||||
|
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ else
|
||||||
CODE=".build/electron/$NAME"
|
CODE=".build/electron/$NAME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
VSCODECRASHDIR=$ROOT/.build/crashes
|
||||||
|
|
||||||
# Node modules
|
# Node modules
|
||||||
test -d node_modules || yarn
|
test -d node_modules || yarn
|
||||||
|
|
||||||
|
@ -32,10 +34,10 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
cd $ROOT ; ulimit -n 4096 ; \
|
cd $ROOT ; ulimit -n 4096 ; \
|
||||||
ELECTRON_ENABLE_LOGGING=1 \
|
ELECTRON_ENABLE_LOGGING=1 \
|
||||||
"$CODE" \
|
"$CODE" \
|
||||||
test/unit/electron/index.js "$@"
|
test/unit/electron/index.js --crash-reporter-directory=$VSCODECRASHDIR "$@"
|
||||||
else
|
else
|
||||||
cd $ROOT ; \
|
cd $ROOT ; \
|
||||||
ELECTRON_ENABLE_LOGGING=1 \
|
ELECTRON_ENABLE_LOGGING=1 \
|
||||||
"$CODE" \
|
"$CODE" \
|
||||||
test/unit/electron/index.js $LINUX_EXTRA_ARGS "$@"
|
test/unit/electron/index.js --crash-reporter-directory=$VSCODECRASHDIR $LINUX_EXTRA_ARGS "$@"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -7,9 +7,10 @@
|
||||||
// come before any mocha imports.
|
// come before any mocha imports.
|
||||||
process.env.MOCHA_COLORS = '1';
|
process.env.MOCHA_COLORS = '1';
|
||||||
|
|
||||||
const { app, BrowserWindow, ipcMain } = require('electron');
|
const { app, BrowserWindow, ipcMain, crashReporter } = require('electron');
|
||||||
|
const product = require('../../../product.json');
|
||||||
const { tmpdir } = require('os');
|
const { tmpdir } = require('os');
|
||||||
const { join } = require('path');
|
const { existsSync, mkdirSync } = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const mocha = require('mocha');
|
const mocha = require('mocha');
|
||||||
const events = require('events');
|
const events = require('events');
|
||||||
|
@ -34,6 +35,7 @@ const optimist = require('optimist')
|
||||||
.describe('reporter-options', 'the mocha reporter options').string('reporter-options').default('reporter-options', '')
|
.describe('reporter-options', 'the mocha reporter options').string('reporter-options').default('reporter-options', '')
|
||||||
.describe('wait-server', 'port to connect to and wait before running tests')
|
.describe('wait-server', 'port to connect to and wait before running tests')
|
||||||
.describe('timeout', 'timeout for tests')
|
.describe('timeout', 'timeout for tests')
|
||||||
|
.describe('crash-reporter-directory', 'crash reporter directory').string('crash-reporter-directory')
|
||||||
.describe('tfs').string('tfs')
|
.describe('tfs').string('tfs')
|
||||||
.describe('help', 'show the help').alias('help', 'h');
|
.describe('help', 'show the help').alias('help', 'h');
|
||||||
|
|
||||||
|
@ -44,8 +46,39 @@ if (argv.help) {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let crashReporterDirectory = argv['crash-reporter-directory'];
|
||||||
|
if (crashReporterDirectory) {
|
||||||
|
crashReporterDirectory = path.normalize(crashReporterDirectory);
|
||||||
|
|
||||||
|
if (!path.isAbsolute(crashReporterDirectory)) {
|
||||||
|
console.error(`The path '${crashReporterDirectory}' specified for --crash-reporter-directory must be absolute.`);
|
||||||
|
app.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!existsSync(crashReporterDirectory)) {
|
||||||
|
try {
|
||||||
|
mkdirSync(crashReporterDirectory);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`The path '${crashReporterDirectory}' specified for --crash-reporter-directory does not seem to exist or cannot be created.`);
|
||||||
|
app.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crashes are stored in the crashDumps directory by default, so we
|
||||||
|
// need to change that directory to the provided one
|
||||||
|
console.log(`Found --crash-reporter-directory argument. Setting crashDumps directory to be '${crashReporterDirectory}'`);
|
||||||
|
app.setPath('crashDumps', crashReporterDirectory);
|
||||||
|
|
||||||
|
crashReporter.start({
|
||||||
|
companyName: 'Microsoft',
|
||||||
|
productName: process.env['VSCODE_DEV'] ? `${product.nameShort} Dev` : product.nameShort,
|
||||||
|
uploadToServer: false,
|
||||||
|
compress: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (!argv.debug) {
|
if (!argv.debug) {
|
||||||
app.setPath('userData', join(tmpdir(), `vscode-tests-${Date.now()}`));
|
app.setPath('userData', path.join(tmpdir(), `vscode-tests-${Date.now()}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
function deserializeSuite(suite) {
|
function deserializeSuite(suite) {
|
||||||
|
|
Loading…
Reference in a new issue