summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/launcher_test.js
blob: a9fc9384c4b8617ebf060346d944c515323e029e (plain)
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
// Note: This test cannot be run in parallel because all output from child processes of the same
// shell is multiplexed to the same buffer.
(function() {
"use strict";

// Note: the windows command line length limit is 8191 characters, so keep this string length
// under that.
const numLines = 300;
const lineContents = "lots of super fun text\n".repeat(numLines).trim();

var echoTest = function() {
    clearRawMongoProgramOutput();

    // This will produce `numLines` + 1 lines of output because echo isn't being called with
    // `-n`. This will block until the program exits.
    var exitCode = runProgram("echo", lineContents);
    var output = rawMongoProgramOutput();

    assert.eq(0, exitCode);

    assert.eq(numLines,
              output.split('\n').length - 1,
              "didn't wait for program's output buffer to finish being consumed");
};

// The motivating failure for the test was a race in runProgram. Empirically, 10 runs has always
// been sufficient for this to fail. 16 gives the test some leeway.
for (var i = 0; i < 16; i++) {
    echoTest();
}
})();