完成后,Testem gulp任务会挂起 [英] Testem gulp task hangs after finished
问题描述
这个gulp任务完成后不会退出,我必须手动按
Ctrl-C退出。
gulp.task('test',function(done){
var testem = require('testem');
var testemOptions = {
file:'testem。 json'
};
var t = new testem();
t.startCI(testemOptions,done);
});
我怎样才能让这个任务正常退出?
输出:
<$> 注意:实际上它会自行退出,但完成后需要15秒。 p $ p>
[15:49:59]使用gulpfile〜/ gulpfile.js
[15:49:59]开始'测试'...
ok 1 PhantomJS 1.9 - 集成测试:首页索引页面
1..3
#测试3
#通过3
#失败0
#ok
[15:50:00] 1.33 s
使用 Chromium启动器
管理重现您的问题,但它应该与 PhantomJS
。在任务$ c $的结尾之间确实存在
15秒
CPU
c>以及过程的实际出口
。
> time gulp testem
启动'testem'...
ok 1 Chrome 32.0 - sass:link
ok 2 Chrome 32.0 - 单元 - HomeRoute:存在
ok 3 Chrome 32.0 - 单元 - HomeRoute:#model
ok 4 Chrome 32.0 - 单元 - HomeRoute:重定向
1..4
#测试4
#通过4
#失败0
#ok
在938 ms后完成'testem'
gulp testem 1.27s用户0.25s系统9%cpu 16.581 total
通过删除完成回调
您在任务上设置并传递给 startCI
,它不把它作为参数,
var testem = require('testem' );
gulp.task('test',function(){
var testemOptions = {
file:'testem.json'
};
var t = new testem();
return t.startCI(testemOptions);
});
任务按预期运行并在完成时正常退出:
> time gulp testem
启动'testem'...
ok 1 Chrome 32.0 - sass:link
ok 2 Chrome 32.0 - 单元 - HomeRoute:存在
ok 3 Chrome 32.0 - 单元 - HomeRoute:#model
ok 4 Chrome 32.0 - 单元 - HomeRoute:重定向
1..4
#测试4
#通过4
#失败0
#ok
gulp testem 1.26s user 0.19s system 91%cpu 1.582 total
$ b $顺便说一下,不知道你可以做到这一点,只需将一个带有文件
属性的对象传递给 startCI
,我认为你应该使用 fs.readFile
读取配置文件,并将它的数据解析为 JSON
使用您在 testem.json
中提供的配置参数启动 testem
。
还有一件事是,有一个gulp插件, gulp-testem
a> ,我没有机会尝试,但这可能会有所帮助。This gulp task doesn't exit after finished, I have to manually press Ctrl-C to exit.
gulp.task('test', function(done) {
var testem = require('testem');
var testemOptions = {
file: 'testem.json'
};
var t = new testem();
t.startCI(testemOptions, done);
});
How can i make this task exit properly?
Note: Actually it exits itself, but it takes like 15 seconds after finished.
Output:
[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
Managed to reproduce your problem using the Chromium launcher
, but it's should be the same with PhantomJS
. There is indeed a 15sec
CPU
delay between the end of the task
and the actual exit of the process
.
> 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
By removing the done callback
you set on the task and passing to startCI
that don't take this as parameter,
var testem = require('testem');
gulp.task('test', function () {
var testemOptions = {
file: 'testem.json'
};
var t = new testem();
return t.startCI(testemOptions);
});
the task run as expected and exit properly on 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
By the way, don't know you can do this, simply pass an object with a file
property to startCI
, I thought you should read the config file using fs.readFile
and parsing its data into JSON
to launch testem
using the config parameters you provided inside testem.json
.
One more thing, there is a gulp plugin, gulp-testem that I did not have the opportunity to try, but which may be helpful.
这篇关于完成后,Testem gulp任务会挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!