Rename rustdoc js test suites
This commit is contained in:
parent
834347ddaf
commit
aa3ca321e9
27 changed files with 93 additions and 100 deletions
|
@ -1,4 +1,5 @@
|
|||
const fs = require('fs');
|
||||
const { spawnSync } = require('child_process');
|
||||
|
||||
const TEST_FOLDER = 'src/test/rustdoc-js/';
|
||||
|
||||
|
@ -219,17 +220,22 @@ function lookForEntry(entry, data) {
|
|||
return null;
|
||||
}
|
||||
|
||||
function main(argv) {
|
||||
if (argv.length !== 3) {
|
||||
console.error("Expected toolchain to check as argument (for example \
|
||||
'x86_64-apple-darwin')");
|
||||
return 1;
|
||||
function build_docs(out_dir, rustdoc_path, file_to_document) {
|
||||
var c = spawnSync(rustdoc_path, [file_to_document, '-o', out_dir]);
|
||||
var s = '';
|
||||
if (c.error || c.stderr.length > 0) {
|
||||
if (c.stderr.length > 0) {
|
||||
s += '==> STDERR: ' + c.stderr + '\n';
|
||||
}
|
||||
s += '==> ERROR: ' + c.error;
|
||||
}
|
||||
var toolchain = argv[2];
|
||||
return s;
|
||||
}
|
||||
|
||||
var mainJs = readFile("build/" + toolchain + "/doc/main.js");
|
||||
var ALIASES = readFile("build/" + toolchain + "/doc/aliases.js");
|
||||
var searchIndex = readFile("build/" + toolchain + "/doc/search-index.js").split("\n");
|
||||
function load_files(out_folder, crate) {
|
||||
var mainJs = readFile(out_folder + "/main.js");
|
||||
var ALIASES = readFile(out_folder + "/aliases.js");
|
||||
var searchIndex = readFile(out_folder + "/search-index.js").split("\n");
|
||||
if (searchIndex[searchIndex.length - 1].length === 0) {
|
||||
searchIndex.pop();
|
||||
}
|
||||
|
@ -248,7 +254,7 @@ function main(argv) {
|
|||
var functionsToLoad = ["buildHrefAndPath", "pathSplitter", "levenshtein", "validateResult",
|
||||
"getQuery", "buildIndex", "execQuery", "execSearch"];
|
||||
|
||||
finalJS += 'window = { "currentCrate": "std" };\n';
|
||||
finalJS += 'window = { "currentCrate": "' + crate + '" };\n';
|
||||
finalJS += 'var rootPath = "../";\n';
|
||||
finalJS += ALIASES;
|
||||
finalJS += loadThings(arraysToLoad, 'array', extractArrayVariable, mainJs);
|
||||
|
@ -256,11 +262,47 @@ function main(argv) {
|
|||
finalJS += loadThings(functionsToLoad, 'function', extractFunction, mainJs);
|
||||
|
||||
var loaded = loadContent(finalJS);
|
||||
var index = loaded.buildIndex(searchIndex.searchIndex);
|
||||
return [loaded, loaded.buildIndex(searchIndex.searchIndex)];
|
||||
}
|
||||
|
||||
function main(argv) {
|
||||
if (argv.length !== 4) {
|
||||
console.error("USAGE: node tester.js [TOOLCHAIN] [STAGE]");
|
||||
return 1;
|
||||
}
|
||||
const toolchain = argv[2];
|
||||
const stage = argv[3];
|
||||
const rustdoc_path = './build/' + toolchain + '/stage' + stage + '/bin/rustdoc';
|
||||
|
||||
var errors = 0;
|
||||
|
||||
fs.readdirSync(TEST_FOLDER).forEach(function(file) {
|
||||
if (!file.endsWith('.js')) {
|
||||
return;
|
||||
}
|
||||
var test_name = file.substring(0, file.length - 3);
|
||||
process.stdout.write('Checking "' + test_name + '" ... ');
|
||||
var rust_file = TEST_FOLDER + test_name + '.rs';
|
||||
|
||||
if (!fs.existsSync(rust_file)) {
|
||||
console.error("FAILED");
|
||||
console.error("==> Missing '" + test_name + ".rs' file...");
|
||||
errors += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
var out_folder = "build/" + toolchain + "/stage" + stage + "/tests/rustdoc-js/" +
|
||||
test_name;
|
||||
|
||||
var ret = build_docs(out_folder, rustdoc_path, rust_file);
|
||||
if (ret.length > 0) {
|
||||
console.error("FAILED");
|
||||
console.error(ret);
|
||||
errors += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
var [loaded, index] = load_files(out_folder, test_name);
|
||||
var loadedFile = loadContent(readFile(TEST_FOLDER + file) +
|
||||
'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;');
|
||||
const expected = loadedFile.EXPECTED;
|
||||
|
@ -270,7 +312,6 @@ function main(argv) {
|
|||
const exact_check = loadedFile.exact_check;
|
||||
const should_fail = loadedFile.should_fail;
|
||||
var results = loaded.execSearch(loaded.getQuery(query), index);
|
||||
process.stdout.write('Checking "' + file + '" ... ');
|
||||
var error_text = [];
|
||||
for (var key in expected) {
|
||||
if (!expected.hasOwnProperty(key)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue