这个吞咽任务在完成后不会退出,我必须手动按Ctrl退出。
gulp.task('test', function(done) {
var testem = require('testem');
var testemOptions = {
file: 'testem.json'
};
var t = new testem();
t.startCI(testemOptions, done);
});如何使此任务正确退出?
注意:实际上它是自己退出的,但在完成后大约需要15秒。
输出:
[15:49:59] Using gulpfile ~/gulpfile.js
[15:49:59] Starting 'test'...
ok 1 PhantomJS 1.9 - Integration Tests: Home Index Page
1..3
# tests 3
# pass 3
# fail 0
# ok
[15:50:00] Finished 'test' after 1.33 s发布于 2014-08-01 22:39:57
成功地使用Chromium launcher再现了您的问题,但是PhantomJS也应该是一样的。在15sec CPU的结束和process的实际出口之间确实存在一个task延迟。
> time gulp testem
Starting 'testem'...
ok 1 Chrome 32.0 - sass: link
ok 2 Chrome 32.0 - Unit - HomeRoute: exists
ok 3 Chrome 32.0 - Unit - HomeRoute: #model
ok 4 Chrome 32.0 - Unit - HomeRoute: redirect
1..4
# tests 4
# pass 4
# fail 0
# ok
Finished 'testem' after 938 ms
gulp testem 1.27s user 0.25s system 9% cpu 16.581 total通过删除设置在任务上的done callback并将其传递给不接受此参数的startCI,
var testem = require('testem');
gulp.task('test', function () {
var testemOptions = {
file: 'testem.json'
};
var t = new testem();
return t.startCI(testemOptions);
});该任务按预期运行,并在finish上正确退出:
> time gulp testem
Starting 'testem'...
ok 1 Chrome 32.0 - sass: link
ok 2 Chrome 32.0 - Unit - HomeRoute: exists
ok 3 Chrome 32.0 - Unit - HomeRoute: #model
ok 4 Chrome 32.0 - Unit - HomeRoute: redirect
1..4
# tests 4
# pass 4
# fail 0
# ok
gulp testem 1.26s user 0.19s system 91% cpu 1.582 total顺便说一句,您不知道可以这样做,只需将一个具有file属性的对象传递给startCI,我认为您应该使用fs.readFile读取配置文件,并将其数据解析为JSON,以便使用在testem.json中提供的配置参数启动testem。
还有一件事,就是我没有机会尝试的一个gulp插件,吞咽,但这可能会有所帮助。
https://stackoverflow.com/questions/25019955
复制相似问题