-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Run rustdoc-gui tests in parallel #86692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
c4eefc3
a1daa8d
40136e1
e540aa0
eca2b3b
c17628b
86fa21c
7f2b52b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -70,12 +70,45 @@ function parseOptions(args) { | |||||||||
return null; | ||||||||||
} | ||||||||||
|
||||||||||
/// Print single char status information without \n | ||||||||||
function char_printer(n_tests) { | ||||||||||
const max_per_line = 10; | ||||||||||
let current = 0; | ||||||||||
return { | ||||||||||
successful: function() { | ||||||||||
current += 1; | ||||||||||
if (current % max_per_line === 0) { | ||||||||||
process.stdout.write(`. (${current}/${n_tests})\n`); | ||||||||||
} else { | ||||||||||
process.stdout.write("."); | ||||||||||
} | ||||||||||
}, | ||||||||||
erroneous: function() { | ||||||||||
current += 1; | ||||||||||
if (current % max_per_line === 0) { | ||||||||||
process.stderr.write(`F (${current}/${n_tests})\n`); | ||||||||||
} else { | ||||||||||
process.stderr.write("F"); | ||||||||||
} | ||||||||||
}, | ||||||||||
}; | ||||||||||
} | ||||||||||
|
||||||||||
/// Sort array by .file_name property | ||||||||||
function by_filename(a, b) { | ||||||||||
return a.file_name - b.file_name; | ||||||||||
} | ||||||||||
|
||||||||||
async function main(argv) { | ||||||||||
let opts = parseOptions(argv.slice(2)); | ||||||||||
if (opts === null) { | ||||||||||
process.exit(1); | ||||||||||
} | ||||||||||
|
||||||||||
// Print successful tests too | ||||||||||
let debug = false; | ||||||||||
// Run tests in sequentially | ||||||||||
let no_headless = false; | ||||||||||
const options = new Options(); | ||||||||||
try { | ||||||||||
// This is more convenient that setting fields one by one. | ||||||||||
|
@@ -84,13 +117,15 @@ async function main(argv) { | |||||||||
"--variable", "DOC_PATH", opts["doc_folder"], | ||||||||||
]; | ||||||||||
if (opts["debug"]) { | ||||||||||
debug = true; | ||||||||||
args.push("--debug"); | ||||||||||
} | ||||||||||
if (opts["show_text"]) { | ||||||||||
args.push("--show-text"); | ||||||||||
} | ||||||||||
if (opts["no_headless"]) { | ||||||||||
args.push("--no-headless"); | ||||||||||
no_headless = true; | ||||||||||
} | ||||||||||
options.parseArguments(args); | ||||||||||
} catch (error) { | ||||||||||
|
@@ -101,25 +136,77 @@ async function main(argv) { | |||||||||
let failed = false; | ||||||||||
let files; | ||||||||||
if (opts["files"].length === 0) { | ||||||||||
files = fs.readdirSync(opts["tests_folder"]).filter(file => path.extname(file) == ".goml"); | ||||||||||
files = fs.readdirSync(opts["tests_folder"]); | ||||||||||
} else { | ||||||||||
files = opts["files"].filter(file => path.extname(file) == ".goml"); | ||||||||||
files = opts["files"]; | ||||||||||
} | ||||||||||
files = files.filter(file => path.extname(file) == ".goml"); | ||||||||||
if (files.length === 0) { | ||||||||||
console.error("rustdoc-gui: No test selected"); | ||||||||||
process.exit(2); | ||||||||||
} | ||||||||||
|
||||||||||
files.sort(); | ||||||||||
for (var i = 0; i < files.length; ++i) { | ||||||||||
const testPath = path.join(opts["tests_folder"], files[i]); | ||||||||||
await runTest(testPath, options).then(out => { | ||||||||||
const [output, nb_failures] = out; | ||||||||||
console.log(output); | ||||||||||
dns2utf8 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
if (nb_failures > 0) { | ||||||||||
|
||||||||||
console.log(`Running ${files.length} rustdoc-gui tests...`); | ||||||||||
process.setMaxListeners(files.length + 1); | ||||||||||
let tests = []; | ||||||||||
let results = { | ||||||||||
successful: [], | ||||||||||
failed: [], | ||||||||||
errored: [], | ||||||||||
}; | ||||||||||
const status_bar = char_printer(files.length); | ||||||||||
for (let i = 0; i < files.length; ++i) { | ||||||||||
const file_name = files[i]; | ||||||||||
const testPath = path.join(opts["tests_folder"], file_name); | ||||||||||
tests.push( | ||||||||||
runTest(testPath, options) | ||||||||||
.then(out => { | ||||||||||
const [output, nb_failures] = out; | ||||||||||
results[nb_failures === 0 ? "successful" : "failed"].push({ | ||||||||||
file_name: file_name, | ||||||||||
output: output, | ||||||||||
}); | ||||||||||
if (nb_failures > 0) { | ||||||||||
status_bar.erroneous() | ||||||||||
failed = true; | ||||||||||
} else { | ||||||||||
status_bar.successful() | ||||||||||
} | ||||||||||
}) | ||||||||||
.catch(err => { | ||||||||||
results.errored.push({ | ||||||||||
file_name: file_name, | ||||||||||
output: err, | ||||||||||
}); | ||||||||||
status_bar.erroneous(); | ||||||||||
failed = true; | ||||||||||
} | ||||||||||
}).catch(err => { | ||||||||||
console.error(err); | ||||||||||
failed = true; | ||||||||||
}) | ||||||||||
); | ||||||||||
if (no_headless) { | ||||||||||
await tests[i]; | ||||||||||
GuillaumeGomez marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
} | ||||||||||
} | ||||||||||
await Promise.all(tests); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't it be:
Suggested change
? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logic wise kind of yes. But you can await a future multiple times, the work will get done only once |
||||||||||
// final \n after the tests | ||||||||||
console.log("\n"); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't it be:
Suggested change
? Or do you specifically want an empty line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If so, maybe better to use two There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted a bit more separation between the sections for readability so the progress bar is visually spaced from the outputs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replaced it with a better finish method that prints the final stats |
||||||||||
|
||||||||||
if (debug === false) { | ||||||||||
results.successful.sort(by_filename); | ||||||||||
results.successful.forEach(r => { | ||||||||||
console.log(r.output); | ||||||||||
}); | ||||||||||
} | ||||||||||
results.failed.sort(by_filename); | ||||||||||
results.failed.forEach(r => { | ||||||||||
console.log(r.output); | ||||||||||
}); | ||||||||||
// print run errors on the bottom so developers see them better | ||||||||||
results.errored.sort(by_filename); | ||||||||||
results.errored.forEach(r => { | ||||||||||
console.error(r.output); | ||||||||||
}); | ||||||||||
|
||||||||||
if (failed) { | ||||||||||
process.exit(1); | ||||||||||
} | ||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.