Skip to content

Commit 9fe4630

Browse files
authored
Rollup merge of #112562 - klensy:rd-gui-test-win, r=GuillaumeGomez
rustdoc-gui: allow running on Windows This adds few fixes to allow running `python x.py test rustdoc-gui` on Windows. * path to npm required to be `npm.cmd` on Windows (otherwise don't work for me) * properly parse node module version on Windows * properly provide path to browser-ui-test runner (fixed in #112613) r? `@GuillaumeGomez`
2 parents 82eb4a0 + 4e628a5 commit 9fe4630

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

config.example.toml

+7
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ changelog-seen = 2
250250
# target when running tests, otherwise this can be omitted.
251251
#nodejs = "node"
252252

253+
# The npm executable to use. Note that this is used for rustdoc-gui tests,
254+
# otherwise this can be omitted.
255+
#
256+
# Under Windows this should be `npm.cmd` or path to it (verified on nodejs v18.06), or
257+
# error will be emitted.
258+
#npm = "npm"
259+
253260
# Python interpreter to use for various tasks throughout the build, notably
254261
# rustdoc tests, the lldb python interpreter, and some dist bits and pieces.
255262
#

src/tools/rustdoc-gui-test/src/main.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,19 @@ fn get_browser_ui_test_version_inner(npm: &Path, global: bool) -> Option<String>
1414
if global {
1515
command.arg("--global");
1616
}
17-
let lines = command
18-
.output()
19-
.map(|output| String::from_utf8_lossy(&output.stdout).into_owned())
20-
.unwrap_or(String::new());
17+
let lines = match command.output() {
18+
Ok(output) => String::from_utf8_lossy(&output.stdout).into_owned(),
19+
Err(e) => {
20+
eprintln!(
21+
"path to npm can be wrong, provided path: {npm:?}. Try to set npm path \
22+
in config.toml in [build.npm]",
23+
);
24+
panic!("{:?}", e)
25+
}
26+
};
2127
lines
2228
.lines()
23-
.find_map(|l| l.split(':').nth(1)?.strip_prefix("browser-ui-test@"))
29+
.find_map(|l| l.rsplit(':').next()?.strip_prefix("browser-ui-test@"))
2430
.map(|v| v.to_owned())
2531
}
2632

0 commit comments

Comments
 (0)