Make `yarn test` more quiet (#1037)

This commit adds a new runOption for execDependencyGraph, namely
`printVerboseResults`. If this flag is true, then execDependencyGraph
will print a "Full Results" section along with the standard error and
standard out of every task, regardless of whether it failed or
succeeded. (Note, this is the existing behavior for all invocations
prior to this commit).

If the flag is not true, then execDependencyGraph will not print a full
results section, and stdout/stderr will be logged only for tasks that
fail.

This commit also modifies `yarn test` to use the new flag so that it
prints verbose tests only when the `--full` option is provided. This is
consistent with our sharness behavior: we print the full sharness logs
only when `--full` was provided.

This fixes #1035, and ensures that running `yarn test` has a high signal
to noise ratio (i.e. it only shows an enumeration of top level tasks).
This improves the developer ergonomics of SourceCred by not having a
super commonly used and core script spam the user with mostly irrelevant
information.

Test plan:

Run `yarn test` when all tests are passing, and observe that the output
has much less noise:

```
yarn run v1.12.3
$ node ./config/test.js
tmpdir for backend output: /tmp/sourcecred-test-6337SZ9smvWsWvqE

Starting tasks
  GO   ensure-flow-typing
  GO   check-stopships
  GO   check-pretty
  GO   lint
  GO   flow
  GO   unit
  GO   backend
 PASS  check-stopships
 PASS  ensure-flow-typing
 PASS  flow
 PASS  backend
  GO   sharness
 PASS  sharness
 PASS  check-pretty
 PASS  lint
 PASS  unit

Overview
Final result:  SUCCESS
Done in 11.66s.
```

Run `yarn test` when there is a real failure (e.g. a unit test failure)
and observe that full details on the failure, including the output from
stdout/stderr, is still provided.

Run `yarn test --full` and observe that full, verbose logs are provided.
This commit is contained in:
Dandelion Mané 2019-01-05 18:16:29 -08:00 committed by GitHub
parent eac0a3ebee
commit 24895b3c7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View File

@ -8,7 +8,10 @@ main();
function main() { function main() {
const options = parseArgs(); const options = parseArgs();
execDependencyGraph(makeTasks(options.mode)).then(({success}) => { const printVerboseResults = options.mode === "FULL";
const runOptions = {printVerboseResults};
const tasks = makeTasks(options.mode);
execDependencyGraph(tasks, runOptions).then(({success}) => {
process.exitCode = success ? 0 : 1; process.exitCode = success ? 0 : 1;
}); });
} }

View File

@ -37,6 +37,9 @@ type RunOptions = {|
+taskLaunchLabel?: string, +taskLaunchLabel?: string,
+overallPassLabel?: string, +overallPassLabel?: string,
+overallFailLabel?: string, +overallFailLabel?: string,
// Determines whether we print the contents of stdout and stderr for
// all tasks (printVerboseResults === true) or just for failing tasks.
+printVerboseResults?: boolean,
|}; |};
*/ */
@ -46,6 +49,7 @@ const defaultOptions = {
taskLaunchLabel: " GO ", taskLaunchLabel: " GO ",
overallPassLabel: "SUCCESS", overallPassLabel: "SUCCESS",
overallFailLabel: "FAILURE", overallFailLabel: "FAILURE",
printVerboseResults: false,
}; };
module.exports = async function execDependencyGraph( module.exports = async function execDependencyGraph(
@ -179,10 +183,12 @@ module.exports = async function execDependencyGraph(
}); });
} }
printSection("Full results"); if (fullOptions.printVerboseResults) {
for (const task of tasks) { printSection("Full results");
const result = completedTasks.get(task.id); for (const task of tasks) {
displayResult(task.id, result, "FULL"); const result = completedTasks.get(task.id);
displayResult(task.id, result, "FULL");
}
} }
printSection("Overview"); printSection("Overview");