-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
aggregate-output.js
93 lines (78 loc) · 3.14 KB
/
aggregate-output.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* @author Toru Nagashima
* @copyright 2016 Toru Nagashima. All rights reserved.
* See LICENSE file in root directory for full license.
*/
"use strict"
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const assert = require("power-assert")
const nodeApi = require("../lib")
const BufferStream = require("./lib/buffer-stream")
const util = require("./lib/util")
const runAll = util.runAll
const runPar = util.runPar
const runSeq = util.runSeq
//------------------------------------------------------------------------------
// Test
//------------------------------------------------------------------------------
describe("[aggregated-output] npm-run-all", () => {
before(() => process.chdir("test-workspace"))
after(() => process.chdir(".."))
/**
* create expected text
* @param {string} term the term to use when creating a line
* @returns {string} the complete line
*/
function createExpectedOutput(term) {
return `[${term}]__[${term}]`
}
describe("should not intermingle output of various commands", () => {
const EXPECTED_SERIALIZED_TEXT = [
createExpectedOutput("first"),
createExpectedOutput("second"),
`${createExpectedOutput("third")}\n`,
].join("\n")
const EXPECTED_PARALLELIZED_TEXT = [
createExpectedOutput("second"),
createExpectedOutput("third"),
`${createExpectedOutput("first")}\n`,
].join("\n")
let stdout = null
beforeEach(() => {
stdout = new BufferStream()
})
it("Node API", () => nodeApi(
["test-task:delayed first 300", "test-task:delayed second 100", "test-task:delayed third 200"],
{stdout, silent: true, aggregateOutput: true}
)
.then(() => {
assert.equal(stdout.value, EXPECTED_SERIALIZED_TEXT)
}))
it("npm-run-all command", () => runAll(
["test-task:delayed first 300", "test-task:delayed second 100", "test-task:delayed third 200", "--silent", "--aggregate-output"],
stdout
)
.then(() => {
assert.equal(stdout.value, EXPECTED_SERIALIZED_TEXT)
}))
it("run-s command", () => runSeq(
["test-task:delayed first 300", "test-task:delayed second 100", "test-task:delayed third 200", "--silent", "--aggregate-output"],
stdout
)
.then(() => {
assert.equal(stdout.value, EXPECTED_SERIALIZED_TEXT)
}))
it("run-p command", () => runPar([
"test-task:delayed first 3000",
"test-task:delayed second 1000",
"test-task:delayed third 2000",
"--silent", "--aggregate-output"],
stdout
)
.then(() => {
assert.equal(stdout.value, EXPECTED_PARALLELIZED_TEXT)
}))
})
})