From 02391c6cf277e466df97d3bd9534c652ed95c555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=AE=B6=E8=BE=89?= <35832931+ColinCollins@users.noreply.github.com> Date: Thu, 7 Jun 2018 17:33:54 +0800 Subject: [PATCH] CircleCI test failed but build successfully problem fixed (#2816) --- .circleci/config.yml | 5 +---- gulpfile.js | 15 +++++++++++++++ package.json | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0892dc5e17..81567c4c70 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,10 +10,7 @@ jobs: - run: sudo npm install -g gulp - run: npm install gulp-qunit - run: npm install - - run: - command: - set -e - npm test + - run: npm test workflows: version: 2 diff --git a/gulpfile.js b/gulpfile.js index 40648736f6..3ddf426db2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -167,3 +167,18 @@ gulp.task('watch-jsb-polyfill', function () { }); gulp.task('watch-dev-files', ['watch-preview', 'watch-jsb-polyfill']); + +gulp.task('test-in-ci', function () { + const { spawn } = require('child_process'); + var gulp = process.platform === 'win32' ? 'gulp.cmd' : 'gulp'; + var child = spawn(gulp, ['test'], { + stdio: [0, 'pipe', 2] + }); + child.stdout.on('data', function (data) { + process.stdout.write(data); + if (data.toString().indexOf(' assertions failed ') !== -1) { + process.exitCode = 1; + process.exit(); + } + }); +}); diff --git a/package.json b/package.json index 2e1729b0f4..35de3c2273 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ ], "license": "MIT", "scripts": { - "test": "gulp test" + "test": "gulp test-in-ci" }, "devDependencies": { "async": "1.5.2",