mirror of
https://github.com/vatesfr/xen-orchestra.git
synced 2026-09-10 22:14:48 -05:00
feat: script test-unit now bails on first error
This commit is contained in:
@@ -93,7 +93,7 @@
|
||||
"test": "npm run test-lint && npm run test-unit",
|
||||
"test-integration": "jest \".integ\\.spec\\.js$\"",
|
||||
"test-lint": "eslint --ignore-path .gitignore --ignore-pattern packages/xo-web .",
|
||||
"test-unit": "jest \"^(?!.*\\.integ\\.spec\\.js$)\" && scripts/run-script.js test",
|
||||
"test-unit": "jest \"^(?!.*\\.integ\\.spec\\.js$)\" && scripts/run-script.js --bail test",
|
||||
"travis-tests": "scripts/travis-tests.js"
|
||||
},
|
||||
"workspaces": [
|
||||
|
||||
@@ -16,11 +16,12 @@ const { env } = process
|
||||
// TODO: https://docs.npmjs.com/misc/scripts#environment
|
||||
require('exec-promise')(args => {
|
||||
const {
|
||||
bail,
|
||||
concurrency,
|
||||
parallel,
|
||||
_: [script],
|
||||
} = getopts(args, {
|
||||
boolean: ['parallel'],
|
||||
boolean: ['bail', 'parallel'],
|
||||
string: ['concurrency'],
|
||||
})
|
||||
|
||||
@@ -37,8 +38,6 @@ require('exec-promise')(args => {
|
||||
env: Object.assign({}, env, {
|
||||
PATH: `${dir}/node_modules/.bin${delimiter}${env.PATH}`,
|
||||
}),
|
||||
shell: true,
|
||||
stdio: 'inherit',
|
||||
}
|
||||
return forEach.call([`pre${script}`, script, `post${script}`], script => {
|
||||
const command = scripts[script]
|
||||
@@ -46,6 +45,11 @@ require('exec-promise')(args => {
|
||||
console.log(`* ${name}:${script} −`, command)
|
||||
return fromEvent(spawn(command, spawnOpts), 'exit').then(code => {
|
||||
if (code !== 0) {
|
||||
if (bail) {
|
||||
// eslint-disable-next-line no-throw-literal
|
||||
throw `${name}:${script} − Error: ` + code
|
||||
}
|
||||
|
||||
++errors
|
||||
console.log(`* ${name}:${script} − Error:`, code)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user