提交 3de1f3cc 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

safe-test support under win32

上级 f5e5d329
......@@ -30,7 +30,7 @@ script:
- echo $TRAVIS_OS_NAME
- node --version
- npm --version
- ./script/safe-test.sh
- npm run test:safe
after_success:
- if [ "$TRAVIS_OS_NAME" == 'osx' ]; then npm run coverage; fi
......
......@@ -60,7 +60,7 @@ RUN npm install \
COPY . .
# RUN npm run test:debug
RUN ./script/safe-test.sh
RUN npm run test:safe
RUN npm run dist
# Loading from node_modules Folders: https://nodejs.org/api/modules.html
......
......@@ -32,10 +32,10 @@ function wechaty::errorBotNotFound() {
`--volume="$(pwd)":/bot`
this will let the container visit your current directory.
2. Are you sure your .js/.ts files aren't .js.txt/.ts.txt?
this could be a problem on new Windows installs (file
this could be a problem on new Windows installs (file
extensions hidden by default).
if you still have issue, please have a look at
......@@ -265,7 +265,7 @@ function main() {
test)
# WECHATY_LOG=silent npm run test:unit
WECHATY_LOG=silent ./script/safe-test.sh
WECHATY_LOG=silent npm run test:safe
;;
#
......
......@@ -28,6 +28,7 @@
"lint:sh": "bash -n bin/*.sh",
"sloc": "sloc bin example src test index.ts --details --format cli-table --keys total,source,comment && sloc bin example src test index.ts",
"test": "npm run clean && npm run lint && npm run test:unit && npm run test:shell && npm run sloc",
"test:safe": "ts-node script/safe-test",
"test:linux": "npm run pretest && parallel ts-node -- ./src/**/*.spec.ts ./test/**/*.spec.ts && npm run posttest",
"test:pack": "npm run dist && export TMPDIR=/tmp/wechaty.$$ && npm pack && mkdir $TMPDIR && mv wechaty-*.*.*.tgz $TMPDIR && cp test/fixture/smoke-testing.js $TMPDIR && cd $TMPDIR && npm init -y && npm i wechaty-*.*.*.tgz && node smoke-testing.js",
"test:shell": "shellcheck bin/*.sh",
......
#!/usr/bin/env bash
#
# https://github.com/Chatie/wechaty/issues/1084
# WebDriver / Puppeteer sometimes will fail(i.e. timeout) with no reason.
# That will cause the unit tests fail randomly.
# So we need to retry again when unit tests fail,
# and treat it's really fail after MAX_RETRY_NUM times.
MAX_RETRY_NUM=3
echo "Safe Test: starting..."
n=0
npm test
while ((n < MAX_RETRY_NUM && $? > 0))
do
((n++))
echo "Safe Test: retrying $n times..."
npm test
done
#!/usr/bin/env ts-node
/**
* https://github.com/Chatie/wechaty/issues/1084
* WebDriver / Puppeteer sometimes will fail(i.e. timeout) with no reason.
* That will cause the unit tests fail randomly.
* So we need to retry again when unit tests fail,
* and treat it's really fail after MAX_RETRY_NUM times.
*/
import { spawn } from 'child_process'
const MAX_RETRY_NUM = 1
async function main(): Promise<number> {
console.log('Safe Test: starting...')
let round = 0
let succ = false
do {
console.log(`Safe Test: running for round #${round}`)
succ = await npmTest()
if (succ) { // success!
console.log(`Safe Test: successed at round #${round}!`)
return 0
}
} while (round++ < MAX_RETRY_NUM)
return 1 // fail finally :(
}
async function npmTest() {
const child = spawn(
'npm',
[
'test',
],
{
stdio: 'inherit',
},
)
return new Promise<boolean>((resolve, reject) => {
child.once('exit', code =>
code === 0 ? resolve(true) : resolve(false),
)
child.once('error', reject)
})
}
main()
.then(process.exit)
.catch(e => {
console.error(e)
process.exit(1)
})
......@@ -177,5 +177,4 @@ test('clickSwitchAccount()', async t => {
t.equal(clicked, false, 'should no button found')
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册