MCPcopy
hub / github.com/eslint/eslint / run

Function run

tools/fuzzer-runner.js:41–85  ·  view source on GitHub ↗

* Runs the fuzzer and outputs a progress bar * @param {Object} [options] Options for the fuzzer * @param {number} [options.amount=300] A positive integer indicating how much testing to do. Larger values result in a higher * chance of finding bugs, but cause the testing to take longer (linear incr

({ amount = 300, fuzzBrokenAutofixes = true } = {})

Source from the content-addressed store, hash-verified

39 * schema as objects returned from eslint-fuzzer.
40 */
41function run({ amount = 300, fuzzBrokenAutofixes = true } = {}) {
42 const crashTestCount = amount * CRASH_AUTOFIX_TEST_COUNT_RATIO;
43 const autofixTestCount = fuzzBrokenAutofixes ? amount : 0;
44
45 /*
46 * To keep the progress bar moving at a roughly constant speed, apply a different weight for finishing
47 * a crash-only fuzzer run versus an autofix fuzzer run.
48 */
49 const progressBar = new ProgressBar(
50 "Fuzzing rules [:bar] :percent, :elapseds elapsed, eta :etas, errors so far: :elapsedErrors",
51 {
52 width: 30,
53 total:
54 crashTestCount +
55 autofixTestCount * ESTIMATED_CRASH_AUTOFIX_PERFORMANCE_RATIO,
56 },
57 );
58
59 // Start displaying the progress bar.
60 progressBar.tick(0, { elapsedErrors: 0 });
61
62 const crashTestResults = fuzz({
63 linter,
64 count: crashTestCount,
65 checkAutofixes: false,
66 progressCallback(elapsedErrors) {
67 progressBar.tick(1, { elapsedErrors });
68 progressBar.render();
69 },
70 });
71
72 const autofixTestResults = fuzz({
73 linter,
74 count: autofixTestCount,
75 checkAutofixes: true,
76 progressCallback(elapsedErrors) {
77 progressBar.tick(ESTIMATED_CRASH_AUTOFIX_PERFORMANCE_RATIO, {
78 elapsedErrors: crashTestResults.length + elapsedErrors,
79 });
80 progressBar.render();
81 },
82 });
83
84 return crashTestResults.concat(autofixTestResults);
85}
86
87module.exports = { run };

Callers 1

Makefile.jsFile · 0.85

Calls 1

fuzzFunction · 0.85

Tested by

no test coverage detected