提交 aa3ca321 编写于 作者: G Guillaume Gomez

Rename rustdoc js test suites

上级 834347dd
......@@ -405,7 +405,7 @@ fn get_step_descriptions(kind: Kind) -> Vec<StepDescription> {
test::Miri,
test::Clippy,
test::CompiletestTest,
test::RustdocJS,
test::RustdocJSStd,
test::RustdocJSNotStd,
test::RustdocTheme,
// Run bootstrap close to the end as it's unlikely to fail
......
......@@ -574,22 +574,22 @@ fn run(self, builder: &Builder<'_>) {
}
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct RustdocJS {
pub struct RustdocJSStd {
pub host: Interned<String>,
pub target: Interned<String>,
}
impl Step for RustdocJS {
impl Step for RustdocJSStd {
type Output = ();
const DEFAULT: bool = true;
const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
run.path("src/test/rustdoc-js")
run.path("src/test/rustdoc-js-std")
}
fn make_run(run: RunConfig<'_>) {
run.builder.ensure(RustdocJS {
run.builder.ensure(RustdocJSStd {
host: run.host,
target: run.target,
});
......@@ -598,7 +598,7 @@ fn make_run(run: RunConfig<'_>) {
fn run(self, builder: &Builder<'_>) {
if let Some(ref nodejs) = builder.config.nodejs {
let mut command = Command::new(nodejs);
command.args(&["src/tools/rustdoc-js/tester.js", &*self.host]);
command.args(&["src/tools/rustdoc-js-std/tester.js", &*self.host]);
builder.ensure(crate::doc::Std {
target: self.target,
stage: builder.top_stage,
......@@ -606,7 +606,7 @@ fn run(self, builder: &Builder<'_>) {
builder.run(&mut command);
} else {
builder.info(
"No nodejs found, skipping \"src/test/rustdoc-js\" tests"
"No nodejs found, skipping \"src/test/rustdoc-js-std\" tests"
);
}
}
......@@ -625,7 +625,7 @@ impl Step for RustdocJSNotStd {
const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
run.path("src/test/rustdoc-js-not-std")
run.path("src/test/rustdoc-js")
}
fn make_run(run: RunConfig) {
......@@ -640,7 +640,7 @@ fn make_run(run: RunConfig) {
fn run(self, builder: &Builder) {
if let Some(ref nodejs) = builder.config.nodejs {
let mut command = Command::new(nodejs);
command.args(&["src/tools/rustdoc-js-not-std/tester.js",
command.args(&["src/tools/rustdoc-js/tester.js",
&*self.host,
builder.top_stage.to_string().as_str()]);
builder.ensure(crate::doc::Std {
......@@ -650,7 +650,7 @@ fn run(self, builder: &Builder) {
builder.run(&mut command);
} else {
builder.info(
"No nodejs found, skipping \"src/test/rustdoc-js-not-std\" tests"
"No nodejs found, skipping \"src/test/rustdoc-js\" tests"
);
}
}
......
const QUERY = 'Fo';
const EXPECTED = {
'others': [
{ 'path': 'basic', 'name': 'Foo' },
],
};
const QUERY = 'String';
const EXPECTED = {
'others': [
{ 'path': 'std::string', 'name': 'String' },
{ 'path': 'std::ffi', 'name': 'CString' },
{ 'path': 'std::ffi', 'name': 'OsString' },
],
'in_args': [
{ 'path': 'std::str', 'name': 'eq' },
],
'returned': [
{ 'path': 'std::string::String', 'name': 'add' },
],
};
const QUERY = 'String';
const QUERY = 'Fo';
const EXPECTED = {
'others': [
{ 'path': 'std::string', 'name': 'String' },
{ 'path': 'std::ffi', 'name': 'CString' },
{ 'path': 'std::ffi', 'name': 'OsString' },
],
'in_args': [
{ 'path': 'std::str', 'name': 'eq' },
],
'returned': [
{ 'path': 'std::string::String', 'name': 'add' },
{ 'path': 'basic', 'name': 'Foo' },
],
};
const fs = require('fs');
const { spawnSync } = require('child_process');
const TEST_FOLDER = 'src/test/rustdoc-js-not-std/';
const TEST_FOLDER = 'src/test/rustdoc-js-std/';
function getNextStep(content, pos, stop) {
while (pos < content.length && content[pos] !== stop &&
......@@ -220,27 +219,17 @@ function lookForEntry(entry, data) {
return null;
}
function remove_docs(out_dir) {
spawnSync('rm', ['-rf', out_dir]);
}
function build_docs(out_dir, rustdoc_path, file_to_document) {
remove_docs(out_dir);
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;
function main(argv) {
if (argv.length !== 3) {
console.error("Expected toolchain to check as argument (for example \
'x86_64-apple-darwin')");
return 1;
}
return s;
}
var toolchain = argv[2];
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");
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");
if (searchIndex[searchIndex.length - 1].length === 0) {
searchIndex.pop();
}
......@@ -259,7 +248,7 @@ function load_files(out_folder, crate) {
var functionsToLoad = ["buildHrefAndPath", "pathSplitter", "levenshtein", "validateResult",
"getQuery", "buildIndex", "execQuery", "execSearch"];
finalJS += 'window = { "currentCrate": "' + crate + '" };\n';
finalJS += 'window = { "currentCrate": "std" };\n';
finalJS += 'var rootPath = "../";\n';
finalJS += ALIASES;
finalJS += loadThings(arraysToLoad, 'array', extractArrayVariable, mainJs);
......@@ -267,47 +256,11 @@ function load_files(out_folder, crate) {
finalJS += loadThings(functionsToLoad, 'function', extractFunction, mainJs);
var loaded = loadContent(finalJS);
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 index = loaded.buildIndex(searchIndex.searchIndex);
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-not-std/" +
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;
......@@ -317,6 +270,7 @@ 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)) {
......@@ -354,8 +308,6 @@ function main(argv) {
console.error("FAILED");
console.error(error_text.join("\n"));
} else {
// In this case, we remove the docs, no need to keep them around.
remove_docs(out_folder);
console.log("OK");
}
});
......
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)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册