1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

python の nosetests を実行するためのgulpのtask runner

1
Last updated at Posted at 2014-12-20

// -*- coding: utf-8 -*-
var fs = require('fs');
var gulp = require('gulp');
var child_process = require('child_process');
 
gulp.task('test', function (){
    var status = 'stop';
    var cmd = 'nosetests';
    var targets = [
        'src/**/*.py',
        'tests/**/*.py'
    ];
 
    var testing = (function (event){
        console.log('run: ' +  event.path);
        if(status != 'running'){
            status = 'running';
            var child = child_process.exec(cmd, function (err, stdout, stderr){
                if (!err){
                    console.log('stdout: ' + stdout);
                    console.log('stderr: ' + stderr)
                } else {
                    console.log(err);
                    // err.code will be the exit code of the child process
                    console.log(err.code);
                    // err.signal will be set to the signal that terminated the process
                    console.log(err.signal);
                }
                status = 'stop';
            });
        };
    });
 
    gulp.watch(targets, function (event){
        testing(event);
    });
});
 
gulp.task('default', function (){
    gulp.run('test');
});
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?