@@ -35,24 +35,35 @@ gulp.task('server:stop', function(done){
3535} ) ;
3636
3737
38+ // Spawns a process on windows
39+ function windowsSpawn ( executable , args , options ) {
40+ return spawn ( 'cmd.exe' , [ '/c' , executable ] . concat ( args ) , options ) ;
41+ }
42+
3843// Runs integration tests with casperjs and phantomjs
44+ // Using casper with gulp and windows is not intuitive. Change this at your own
45+ // risk.
3946gulp . task ( 'test:integration' , function ( done ) {
4047 var tests = [ 'spec/integration' ] ;
41- var isWindows = process . platform === 'win32' ;
42- var casperCmd = 'casperjs' ;
48+ var casperChild ;
4349 var onError = function ( code ) {
4450 done ( code ) ;
4551 // Gulp doesn't handle the error properly so clean up properly
4652 stopServer ( 1 ) ;
4753 } ;
4854
49- if ( isWindows ) {
50- casperCmd = 'casperjs.cmd' ;
55+ if ( process . platform === 'win32' ) {
56+ // Don't inherit stdio here since it causes problems
57+ casperChild = windowsSpawn ( 'casperjs' , [ 'test' ] . concat ( tests ) ) ;
58+ // Must handle data here for the tests to execute within the task
59+ // Handle this only for windows
60+ casperChild . stdout . on ( 'data' , function ( data ) {
61+ gutil . log ( 'CasperJS:' , data . toString ( ) . slice ( 0 , - 1 ) ) ; // remove \n
62+ } ) ;
63+ } else {
64+ casperChild = spawn ( 'casperjs' , [ 'test' ] . concat ( tests ) , { stdio : 'inherit' } ) ;
5165 }
5266
53- var casperChild = spawn ( casperCmd , [ 'test' ] . concat ( tests ) ,
54- { stdio : 'inherit' } ) ;
55-
5667 casperChild . on ( 'close' , function ( code ) {
5768 if ( code ) {
5869 // If there is an error, format the error object for gulp
@@ -102,7 +113,7 @@ gulp.task('test:unit:tdd', function (done) {
102113
103114
104115// Runs server unit tests with jasmine 2.1
105- gulp . task ( 'test:server- unit' , function ( ) {
116+ gulp . task ( 'test:unit:server ' , function ( ) {
106117 return gulp . src ( 'server/**/*.spec.js' )
107118 . pipe ( jasmine ( ) ) ;
108119} ) ;
@@ -124,7 +135,8 @@ gulp.task('test:all',
124135 gulpSequence (
125136 'server:start' ,
126137 'test:lint' ,
127- 'test:server-unit' ,
138+ 'test:unit' ,
139+ 'test:unit:server' ,
128140 'test:api' ,
129141 'test:integration' ,
130142 'server:stop' ) ) ;
0 commit comments