MCPcopy Index your code
hub / github.com/tensorflow/tfjs / main

Function main

scripts/run_flaky.js:20–56  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

18
19
20function main(args) {
21 const command = args['command'];
22 const times = parseInt(args['times']);
23
24 if (times === 0) {
25 throw new Error(`Flaky test asked to run zero times: '${command}'`);
26 }
27
28 console.log(`Running flaky test at most ${times} times`);
29 console.log(`Command: '${command}'`);
30 const exitCodes = [];
31 for (let i = 0; i < times; i++) {
32 console.log(`Flaky run ${i + 1} of a potential ${times} for '${command}'`);
33 const exitCode = exec(command).code;
34 exitCodes.push(exitCode);
35 if (exitCode === 0) {
36 break;
37 }
38 }
39
40 const success = exitCodes[exitCodes.length - 1] === 0;
41 if (!success) {
42 console.error(`Flaky test failed ${times} times`);
43 } else if (exitCodes.length > 1) {
44 console.warn(
45 `Flaky test failed ${exitCodes.length - 1} times before passing.`);
46 } else {
47 // Test passed with no fails
48 console.log('Flaky test passed on the first run');
49 }
50 console.error(`Command: '${command}'`);
51 console.error(`Exit codes: ${exitCodes}`);
52
53 if (!success) {
54 process.exit(1);
55 }
56}
57
58const parser = new ArgumentParser(
59 {description: 'Run a flaky test a number of times or until it passes'});

Callers 1

run_flaky.jsFile · 0.70

Calls 3

execFunction · 0.85
logMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…