Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc-gui: allow running on Windows #112562

Merged
merged 2 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ changelog-seen = 2
# target when running tests, otherwise this can be omitted.
#nodejs = "node"

# The npm executable to use. Note that this is used for rustdoc-gui tests,
# otherwise this can be omitted.
#
# Under Windows this should be `npm.cmd` or path to it (verified on nodejs v18.06), or
# error will be emitted.
#npm = "npm"

# Python interpreter to use for various tasks throughout the build, notably
# rustdoc tests, the lldb python interpreter, and some dist bits and pieces.
#
Expand Down
16 changes: 11 additions & 5 deletions src/tools/rustdoc-gui-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ fn get_browser_ui_test_version_inner(npm: &Path, global: bool) -> Option<String>
if global {
command.arg("--global");
}
let lines = command
.output()
.map(|output| String::from_utf8_lossy(&output.stdout).into_owned())
.unwrap_or(String::new());
let lines = match command.output() {
Ok(output) => String::from_utf8_lossy(&output.stdout).into_owned(),
Err(e) => {
eprintln!(
"path to npm can be wrong, provided path: {npm:?}. Try to set npm path \
in config.toml in [build.npm]",
);
panic!("{:?}", e)
}
};
lines
.lines()
.find_map(|l| l.split(':').nth(1)?.strip_prefix("browser-ui-test@"))
.find_map(|l| l.rsplit(':').next()?.strip_prefix("browser-ui-test@"))
Comment on lines -23 to +29
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider windows path C:\\proj\\rust\\node_modules\\browser-ui-test:browser-ui-test@0.16.6: in that case split will find wrong part of string.

.map(|v| v.to_owned())
}

Expand Down