safe-test.sh 468 字节
Newer Older
1
#!/usr/bin/env bash
Huan (李卓桓)'s avatar
add doc  
Huan (李卓桓) 已提交
2 3 4 5 6 7 8
#
# 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.

9 10
MAX_RETRY_NUM=3

11 12
echo "Safe Test: starting..."

13 14 15 16 17
n=0
npm test
while ((n < MAX_RETRY_NUM && $? > 0))
do
  ((n++))
18
  echo "Safe Test: retrying $n times..."
19 20
  npm test
done