1'use strict'; 2const common = require('../common'); 3const spawn = require('child_process').spawn; 4const assert = require('assert'); 5 6const subprocess = spawn('echo', ['ok']); 7 8let didSpawn = false; 9subprocess.on('spawn', function() { 10 didSpawn = true; 11}); 12function mustCallAfterSpawn() { 13 return common.mustCall(function() { 14 assert.ok(didSpawn); 15 }); 16} 17 18subprocess.on('error', common.mustNotCall()); 19subprocess.on('spawn', common.mustCall()); 20subprocess.stdout.on('data', mustCallAfterSpawn()); 21subprocess.stdout.on('end', mustCallAfterSpawn()); 22subprocess.stdout.on('close', mustCallAfterSpawn()); 23subprocess.stderr.on('data', common.mustNotCall()); 24subprocess.stderr.on('end', mustCallAfterSpawn()); 25subprocess.stderr.on('close', mustCallAfterSpawn()); 26subprocess.on('exit', mustCallAfterSpawn()); 27subprocess.on('close', mustCallAfterSpawn()); 28