Advertisement
TakesxiSximada

python testing gulp

Dec 20th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // -*- coding: utf-8 -*-
  2. var fs = require('fs');
  3. var gulp = require('gulp');
  4. var child_process = require('child_process');
  5.  
  6. gulp.task('test', function (){
  7.     var status = 'stop';
  8.     var cmd = 'nosetests';
  9.     var targets = [
  10.         'src/**/*.py',
  11.         'tests/**/*.py'
  12.     ];
  13.  
  14.     var testing = (function (event){
  15.         console.log('run: ' +  event.path);
  16.         if(status != 'running'){
  17.             status = 'running';
  18.             var child = child_process.exec(cmd, function (err, stdout, stderr){
  19.                 if (!err){
  20.                     console.log('stdout: ' + stdout);
  21.                     console.log('stderr: ' + stderr)
  22.                 } else {
  23.                     console.log(err);
  24.                     // err.code will be the exit code of the child process
  25.                     console.log(err.code);
  26.                     // err.signal will be set to the signal that terminated the process
  27.                     console.log(err.signal);
  28.                 }
  29.                 status = 'stop';
  30.             });
  31.         };
  32.     });
  33.  
  34.     gulp.watch(targets, function (event){
  35.         testing(event);
  36.     });
  37. });
  38.  
  39. gulp.task('default', function (){
  40.     gulp.run('test');
  41. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement