This reverts commit 664cd3fa04
.
This commit is contained in:
parent
664cd3fa04
commit
ba07cc6237
4 changed files with 4 additions and 41 deletions
|
@ -35,5 +35,5 @@ steps:
|
||||||
displayName: 'Yarn check'
|
displayName: 'Yarn check'
|
||||||
|
|
||||||
- script: |
|
- script: |
|
||||||
node run-tests.js -c 2 -g $(group) --hard-retry
|
node run-tests.js -c 2 -g $(group)
|
||||||
displayName: 'Run tests'
|
displayName: 'Run tests'
|
||||||
|
|
|
@ -106,7 +106,6 @@
|
||||||
"node-sass": "4.12.0",
|
"node-sass": "4.12.0",
|
||||||
"pre-commit": "1.2.2",
|
"pre-commit": "1.2.2",
|
||||||
"prettier": "1.17.1",
|
"prettier": "1.17.1",
|
||||||
"ps-list": "6.3.0",
|
|
||||||
"react": "16.8.6",
|
"react": "16.8.6",
|
||||||
"react-dom": "16.8.6",
|
"react-dom": "16.8.6",
|
||||||
"react-ssr-prepass": "1.0.5",
|
"react-ssr-prepass": "1.0.5",
|
||||||
|
|
37
run-tests.js
37
run-tests.js
|
@ -1,21 +1,16 @@
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const _glob = require('glob')
|
const _glob = require('glob')
|
||||||
const psList = require('ps-list')
|
|
||||||
const _treeKill = require('tree-kill')
|
|
||||||
const { promisify } = require('util')
|
const { promisify } = require('util')
|
||||||
const { Sema } = require('async-sema')
|
const { Sema } = require('async-sema')
|
||||||
const { spawn, exec: execOrig } = require('child_process')
|
const { spawn, exec: execOrig } = require('child_process')
|
||||||
|
|
||||||
const glob = promisify(_glob)
|
const glob = promisify(_glob)
|
||||||
const exec = promisify(execOrig)
|
const exec = promisify(execOrig)
|
||||||
const treeKill = promisify(_treeKill)
|
|
||||||
|
|
||||||
const NUM_RETRIES = 2
|
const NUM_RETRIES = 2
|
||||||
const DEFAULT_CONCURRENCY = 3
|
const DEFAULT_CONCURRENCY = 3
|
||||||
|
|
||||||
;(async () => {
|
;(async () => {
|
||||||
// kills all node process except current one and all Chrome(driver) instances
|
|
||||||
const useHardRetries = process.argv.indexOf('--hard-retry') > -1
|
|
||||||
let concurrencyIdx = process.argv.indexOf('-c')
|
let concurrencyIdx = process.argv.indexOf('-c')
|
||||||
const concurrency =
|
const concurrency =
|
||||||
parseInt(process.argv[concurrencyIdx + 1], 10) || DEFAULT_CONCURRENCY
|
parseInt(process.argv[concurrencyIdx + 1], 10) || DEFAULT_CONCURRENCY
|
||||||
|
@ -73,20 +68,12 @@ const DEFAULT_CONCURRENCY = 3
|
||||||
stdio: 'inherit'
|
stdio: 'inherit'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const exitHandler = code => {
|
children.add(child)
|
||||||
|
child.on('exit', code => {
|
||||||
children.delete(child)
|
children.delete(child)
|
||||||
if (code) reject(new Error(`failed with code: ${code}`))
|
if (code) reject(new Error(`failed with code: ${code}`))
|
||||||
resolve()
|
resolve()
|
||||||
}
|
})
|
||||||
child.on('exit', exitHandler)
|
|
||||||
|
|
||||||
child.prepareRestart = () => {
|
|
||||||
child.removeListener('exit', exitHandler)
|
|
||||||
children.delete(child)
|
|
||||||
child.kill()
|
|
||||||
}
|
|
||||||
child.restart = () => resolve(runTest(test))
|
|
||||||
children.add(child)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
|
@ -106,24 +93,6 @@ const DEFAULT_CONCURRENCY = 3
|
||||||
await exec(`git clean -fdx "${path.join(__dirname, test)}"`)
|
await exec(`git clean -fdx "${path.join(__dirname, test)}"`)
|
||||||
await exec(`git checkout "${path.join(__dirname, test)}"`)
|
await exec(`git checkout "${path.join(__dirname, test)}"`)
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
|
|
||||||
if (useHardRetries) {
|
|
||||||
const runningChildren = [...children]
|
|
||||||
runningChildren.forEach(child => child.prepareRestart())
|
|
||||||
for (const proc of await psList()) {
|
|
||||||
const name = proc.name.toLowerCase()
|
|
||||||
|
|
||||||
if (name.includes('chrome') || name.includes('node')) {
|
|
||||||
if (proc.pid !== process.pid) {
|
|
||||||
console.log('killing', name)
|
|
||||||
try {
|
|
||||||
await treeKill(proc.pid)
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
runningChildren.forEach(child => child.restart())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11410,11 +11410,6 @@ prr@~1.0.1:
|
||||||
resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476"
|
resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476"
|
||||||
integrity sha1-0/wRS6BplaRexok/SEzrHXj19HY=
|
integrity sha1-0/wRS6BplaRexok/SEzrHXj19HY=
|
||||||
|
|
||||||
ps-list@6.3.0:
|
|
||||||
version "6.3.0"
|
|
||||||
resolved "https://registry.yarnpkg.com/ps-list/-/ps-list-6.3.0.tgz#a2b775c2db7d547a28fbaa3a05e4c281771259be"
|
|
||||||
integrity sha512-qau0czUSB0fzSlBOQt0bo+I2v6R+xiQdj78e1BR/Qjfl5OHWJ/urXi8+ilw1eHe+5hSeDI1wrwVTgDp2wst4oA==
|
|
||||||
|
|
||||||
ps-tree@=1.1.1:
|
ps-tree@=1.1.1:
|
||||||
version "1.1.1"
|
version "1.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/ps-tree/-/ps-tree-1.1.1.tgz#5f1ba35455b8c25eeb718d04c37de1555d96d3db"
|
resolved "https://registry.yarnpkg.com/ps-tree/-/ps-tree-1.1.1.tgz#5f1ba35455b8c25eeb718d04c37de1555d96d3db"
|
||||||
|
|
Loading…
Reference in a new issue