Skip to content
/ rust Public
forked from rust-lang/rust

Commit 0164b60

Browse files
authored
Rollup merge of rust-lang#159786 - AayushMainali-Github:fix-142648-ignore-hidden-js-tests, r=notriddle
rustdoc-js: ignore editor temp files in test folder discovery `tester.js` previously treated every `*.js` entry under `--test-folder` as a test. Editor temporary files such as Emacs `.#alias-4.js` also end with `.js`, so discovering them caused `rustdoc-js-std` to fail with `ENOENT` when the lock file was a dead symlink. This change mirrors compiletest's `is_test` filtering and skips names that start with `.`, `#`, or `~` during folder discovery. Explicit `--test-file` paths are unchanged. Fixes rust-lang#142648.
2 parents 309f45d + a14d50a commit 0164b60

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/tools/rustdoc-js/tester.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,22 @@ async function loadSearchJS(doc_folder, resource_suffix) {
539539
};
540540
}
541541

542+
/**
543+
* Returns true if `fileName` looks like a proper rustdoc-js test file.
544+
*
545+
* Mirrors compiletest's `is_test` filtering so editor temp/autosave files
546+
* (for example Emacs `.#foo.js`) are not treated as tests.
547+
*/
548+
function isTestFile(fileName) {
549+
if (!fileName.endsWith(".js")) {
550+
return false;
551+
}
552+
553+
// `.`, `#`, and `~` are common temp-file prefixes.
554+
const invalidPrefixes = [".", "#", "~"];
555+
return !invalidPrefixes.some(prefix => fileName.startsWith(prefix));
556+
}
557+
542558
function showHelp() {
543559
console.log("rustdoc-js options:");
544560
console.log(" --doc-folder [PATH] : location of the generated doc folder");
@@ -626,7 +642,7 @@ async function main(argv) {
626642
}
627643
} else if (opts["test_folder"].length !== 0) {
628644
for (const file of fs.readdirSync(opts["test_folder"])) {
629-
if (!file.endsWith(".js")) {
645+
if (!isTestFile(file)) {
630646
continue;
631647
}
632648
process.stdout.write(`Testing ${file} ... `);

0 commit comments

Comments
 (0)