@@ -65,72 +65,29 @@ shell.cd('../..');
6565// async
6666//
6767
68- // no callback (no need for asyncFlags)
68+ // no callback
6969var c = shell . exec ( 'node -e \"console.log(1234)\"' , { async :true } ) ;
7070assert . equal ( shell . error ( ) , null ) ;
7171assert . ok ( 'stdout' in c , 'async exec returns child process object' ) ;
7272
73- var asyncFlags = [ ] ;
74-
7573//
7674// callback as 2nd argument
7775//
78- asyncFlags [ 0 ] = false ;
79- shell . exec ( 'node -e \"console.log(5678);\"' , { async :true } , function ( code , output ) {
76+ shell . exec ( 'node -e \"console.log(5678);\"' , function ( code , output ) {
8077 assert . equal ( code , 0 ) ;
8178 assert . ok ( output === '5678\n' || output === '5678\nundefined\n' ) ; // 'undefined' for v0.4
82- asyncFlags [ 0 ] = true ;
83-
84-
85- // Most of the following code doesn't really belong here since it tests the sync version (stdout).
86- // However there seems to be a race condition with the stdout returned by child.exec()
87- // that makes the tests fail intermittently. So we're keeping them here in a chain
88- // to avoid this race issue
89-
90- // STILL SUFFERING INTERMITTENT FAILURES - COMMENTING OUT UNTIL THIS GETS SORTED OUT
91-
92- shell . exit ( 123 ) ;
93-
94-
95- // //
96- // // check if stdout is proxied with default silent options (i.e. silent = false)
97- // //
98- // asyncFlags[1] = false;
99- // shell.mkdir('-p', 'tmp');
100- // var file = 'tmp/tempscript'+Math.random()+'.js',
101- // script = 'require(\'../../global.js\'); exec(\'node -e \"console.log(555);\"\')';
102- // script.to(file);
103- // child.exec('node '+file, function(err, stdout, stderr) {
104- // assert.ok(stdout === '555\n' || stdout === '555\nundefined\n'); // 'undefined' for v0.4
105- // asyncFlags[1] = true;
106-
107- // //
108- // // check if stdout is proxied when: silent(true), {silent:false}
109- // //
110- // asyncFlags[2] = false;
111- // shell.mkdir('-p', 'tmp');
112- // var file = 'tmp/tempscript'+Math.random()+'.js',
113- // script = 'require(\'../../global.js\'); silent(true); exec(\'node -e \"console.log(333);\"\', {silent:false})';
114- // script.to(file);
115- // child.exec('node '+file, function(err, stdout, stderr) {
116- // assert.ok(stdout === '333\n' || stdout === '333\nundefined\n'); // 'undefined' for v0.4
117- // asyncFlags[2] = true;
118-
119- // //
120- // // check if stdout is proxied when: silent(true), {silent:false} - async
121- // //
122- // asyncFlags[3] = false;
123- // shell.mkdir('-p', 'tmp');
124- // var file = 'tmp/tempscript'+Math.random()+'.js',
125- // script = 'require(\'../../global.js\'); silent(true); exec(\'node -e \"console.log(222);\"\', {silent:false, async:true})';
126- // script.to(file);
127- // child.exec('node '+file, function(err, stdout, stderr) {
128- // assert.ok(stdout === '222\n' || stdout === '222\nundefined\n'); // 'undefined' for v0.4
129- // asyncFlags[3] = true;
130-
131- // shell.exit(123);
132- // });
133- // });
134- // });
79+
80+ //
81+ // callback as 3rd argument
82+ //
83+ shell . exec ( 'node -e \"console.log(5566);\"' , { async :true } , function ( code , output ) {
84+ assert . equal ( code , 0 ) ;
85+ assert . ok ( output === '5566\n' || output === '5566\nundefined\n' ) ; // 'undefined' for v0.4
86+
87+ shell . exit ( 123 ) ;
88+
89+ } ) ;
90+
13591} ) ;
92+
13693assert . equal ( shell . error ( ) , null ) ;
0 commit comments