Skip to content

Commit 3f58ab6

Browse files
committed
Allow rustdoc-js and rustdoc-js-std to use none default build dir location
1 parent 965888a commit 3f58ab6

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

src/bootstrap/test.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,6 @@ impl Step for RustdocTheme {
607607

608608
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
609609
pub struct RustdocJSStd {
610-
pub host: Interned<String>,
611610
pub target: Interned<String>,
612611
}
613612

@@ -621,13 +620,16 @@ impl Step for RustdocJSStd {
621620
}
622621

623622
fn make_run(run: RunConfig<'_>) {
624-
run.builder.ensure(RustdocJSStd { host: run.host, target: run.target });
623+
run.builder.ensure(RustdocJSStd { target: run.target });
625624
}
626625

627626
fn run(self, builder: &Builder<'_>) {
628627
if let Some(ref nodejs) = builder.config.nodejs {
629628
let mut command = Command::new(nodejs);
630-
command.args(&["src/tools/rustdoc-js-std/tester.js", &*self.host]);
629+
command
630+
.arg(builder.src.join("src/tools/rustdoc-js-std/tester.js"))
631+
.arg(builder.doc_out(self.target))
632+
.arg(builder.src.join("src/test/rustdoc-js-std"));
631633
builder.ensure(crate::doc::Std { target: self.target, stage: builder.top_stage });
632634
builder.run(&mut command);
633635
} else {

src/tools/compiletest/src/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2779,7 +2779,7 @@ impl<'test> TestCx<'test> {
27792779
Command::new(&nodejs)
27802780
.arg(root.join("src/tools/rustdoc-js/tester.js"))
27812781
.arg(out_dir.parent().expect("no parent"))
2782-
.arg(&self.testpaths.file.file_stem().expect("couldn't get file stem")),
2782+
.arg(self.testpaths.file.with_extension("js")),
27832783
);
27842784
if !res.status.success() {
27852785
self.fatal_proc_rec("rustdoc-js test failed!", &res);

src/tools/rustdoc-js-std/tester.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const fs = require('fs');
2-
3-
const TEST_FOLDER = 'src/test/rustdoc-js-std/';
2+
const path = require('path');
43

54
function getNextStep(content, pos, stop) {
65
while (pos < content.length && content[pos] !== stop &&
@@ -246,17 +245,16 @@ function readFileMatching(dir, name, extension) {
246245
}
247246

248247
function main(argv) {
249-
if (argv.length !== 3) {
250-
console.error("Expected toolchain to check as argument (for example \
251-
'x86_64-apple-darwin')");
248+
if (argv.length !== 4) {
249+
console.error("USAGE: node tester.js STD_DOCS TEST_FOLDER");
252250
return 1;
253251
}
254-
var toolchain = argv[2];
252+
var std_docs = argv[2];
253+
var test_folder = argv[3];
255254

256-
var mainJs = readFileMatching("build/" + toolchain + "/doc/", "main", ".js");
257-
var ALIASES = readFileMatching("build/" + toolchain + "/doc/", "aliases", ".js");
258-
var searchIndex = readFileMatching("build/" + toolchain + "/doc/",
259-
"search-index", ".js").split("\n");
255+
var mainJs = readFileMatching(std_docs, "main", ".js");
256+
var ALIASES = readFileMatching(std_docs, "aliases", ".js");
257+
var searchIndex = readFileMatching(std_docs, "search-index", ".js").split("\n");
260258
if (searchIndex[searchIndex.length - 1].length === 0) {
261259
searchIndex.pop();
262260
}
@@ -287,8 +285,8 @@ function main(argv) {
287285

288286
var errors = 0;
289287

290-
fs.readdirSync(TEST_FOLDER).forEach(function(file) {
291-
var loadedFile = loadContent(readFile(TEST_FOLDER + file) +
288+
fs.readdirSync(test_folder).forEach(function(file) {
289+
var loadedFile = loadContent(readFile(path.join(test_folder, file)) +
292290
'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;');
293291
const expected = loadedFile.EXPECTED;
294292
const query = loadedFile.QUERY;

src/tools/rustdoc-js/tester.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const fs = require('fs');
2+
const path = require('path');
23
const { spawnSync } = require('child_process');
34

4-
const TEST_FOLDER = 'src/test/rustdoc-js/';
5-
65
function getNextStep(content, pos, stop) {
76
while (pos < content.length && content[pos] !== stop &&
87
(content[pos] === ' ' || content[pos] === '\t' || content[pos] === '\n')) {
@@ -266,10 +265,11 @@ function main(argv) {
266265
var errors = 0;
267266

268267
for (var j = 3; j < argv.length; ++j) {
269-
const test_name = argv[j];
268+
const test_file = argv[j];
269+
const test_name = path.basename(test_file, ".js");
270270

271271
process.stdout.write('Checking "' + test_name + '" ... ');
272-
if (!fs.existsSync(TEST_FOLDER + test_name + ".js")) {
272+
if (!fs.existsSync(test_file)) {
273273
errors += 1;
274274
console.error("FAILED");
275275
console.error("==> Missing '" + test_name + ".js' file...");
@@ -279,7 +279,7 @@ function main(argv) {
279279
const test_out_folder = out_folder + test_name;
280280

281281
var [loaded, index] = load_files(test_out_folder, test_name);
282-
var loadedFile = loadContent(readFile(TEST_FOLDER + test_name + ".js") +
282+
var loadedFile = loadContent(readFile(test_file) +
283283
'exports.QUERY = QUERY;exports.EXPECTED = EXPECTED;');
284284
const expected = loadedFile.EXPECTED;
285285
const query = loadedFile.QUERY;

0 commit comments

Comments
 (0)