Skip to content
Permalink
Browse files

Rename rustdoc js test suites

  • Loading branch information...
GuillaumeGomez committed Feb 23, 2019
1 parent 834347d commit aa3ca321e92c541dce363634c9cea7cf23689a5e
@@ -405,7 +405,7 @@ impl<'a> Builder<'a> {
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 @@ impl Step for RustdocTheme {
}

#[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,15 +598,15 @@ impl Step for RustdocJS {
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,
});
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 @@ impl Step for RustdocJSNotStd {
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 @@ impl Step for RustdocJSNotStd {
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"
);
}
}

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,15 @@
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' },
],
};
@@ -1,15 +1,7 @@
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' },
],
};
@@ -1,7 +1,6 @@
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,55 +248,19 @@ 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);
finalJS += loadThings(variablesToLoad, 'variable', extractVariable, mainJs);
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");
}
});
@@ -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,19 +254,55 @@ 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);
finalJS += loadThings(variablesToLoad, 'variable', extractVariable, mainJs);
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)) {

0 comments on commit aa3ca32

Please sign in to comment.
You can’t perform that action at this time.