diff options
author | cjihrig <cjihrig@gmail.com> | 2016-07-15 15:43:24 -0400 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2016-07-18 17:14:16 -0400 |
commit | 04b4d15b396a7befea31dbfec89f69ff71dc71ca (patch) | |
tree | 7819010b9b687fb20328c04645e9ec64c25b9328 /test/parallel/test-pipe-head.js | |
parent | 59741a9beeb0ccaac6fc3247605bf090d36ad50e (diff) | |
download | node-new-04b4d15b396a7befea31dbfec89f69ff71dc71ca.tar.gz |
test: use mustCall() for simple flow tracking
Many of the tests use variables to track when callback functions
are invoked or events are emitted. These variables are then
asserted on process exit. This commit replaces this pattern in
straightforward cases with common.mustCall(). This makes the
tests easier to reason about, leads to a net reduction in lines
of code, and uncovered a few bugs in tests. This commit also
replaces some callbacks that should never be called with
common.fail().
PR-URL: https://github.com/nodejs/node/pull/7753
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test/parallel/test-pipe-head.js')
-rw-r--r-- | test/parallel/test-pipe-head.js | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/test/parallel/test-pipe-head.js b/test/parallel/test-pipe-head.js index ac8b165151..dcb4e89137 100644 --- a/test/parallel/test-pipe-head.js +++ b/test/parallel/test-pipe-head.js @@ -10,16 +10,8 @@ var script = join(common.fixturesDir, 'print-10-lines.js'); var cmd = '"' + nodePath + '" "' + script + '" | head -2'; -var finished = false; - -exec(cmd, function(err, stdout, stderr) { +exec(cmd, common.mustCall(function(err, stdout, stderr) { if (err) throw err; var lines = stdout.split('\n'); assert.equal(3, lines.length); - finished = true; -}); - - -process.on('exit', function() { - assert.ok(finished); -}); +})); |