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

compile-test: allow overriding nodejs binary location #37611

Merged
merged 1 commit into from
Nov 12, 2016

Conversation

Mark-Simulacrum
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum commented Nov 6, 2016

Add a command-line argument to manually specify which nodejs binary should be used,
which disables the default search.

Original work done by @tari.

Fixes #34188.

@rust-highfive
Copy link
Collaborator

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@TimNN
Copy link
Contributor

TimNN commented Nov 6, 2016

There already seems to be a nodejs option: https://github.com/rust-lang/rust/blob/master/src/tools/compiletest/src/common.rs#L192, which is used when provided.

@bors
Copy link
Contributor

bors commented Nov 6, 2016

☔ The latest upstream changes (presumably #37597) made this pull request unmergeable. Please resolve the merge conflicts.

@Mark-Simulacrum
Copy link
Member Author

@TimNN That's true, I didn't notice. Though I believe that the existing nodejs doesn't try to detect other variants (node, node.exe, nodejs.exe). If this isn't considered worth it, feel free to close this, but then we should close the linked issue (#34188).

@TimNN
Copy link
Contributor

TimNN commented Nov 6, 2016

Mh, there is some detection in bootstrap, so at least when using rustbuild, thinks should be detected correctly.

@alexcrichton
Copy link
Member

Thanks for the PR! I agree with @TimNN that the best place for this is probably in rustbuild itself, we already need the node executable to run other unit test suites like the standard library. Perhaps this logic could be moved there and continue to be communicated to compiletest via this flag?

@alexcrichton
Copy link
Member

@Mark-Simulacrum thoughts about updating to place this logic in rustbuild's detection and passing it down to compiletest that way?

@TimNN
Copy link
Contributor

TimNN commented Nov 10, 2016

@alexcrichton: I'm pretty sure that logic is already present in rustbuild, isn't it?

See https://github.com/rust-lang/rust/blob/master/src/bootstrap/sanity.rs#L84-L89:

    // Look for the nodejs command, needed for emscripten testing
    if let Some(node) = have_cmd("node".as_ref()) {
        build.config.nodejs = Some(node);
    } else if let Some(node) = have_cmd("nodejs".as_ref()) {
        build.config.nodejs = Some(node);
    }

@Mark-Simulacrum Mark-Simulacrum force-pushed the tari-nodejs-runner-detect branch 2 times, most recently from e9d9d46 to c3ed357 Compare November 10, 2016 22:00
@Mark-Simulacrum
Copy link
Member Author

I think I updated this as @alexcrichton suggested (with rustbuild), but I don't have a good way to test, since I don't use rustbuild locally. If someone can give me a set of commands to run then I can run those.

@@ -86,6 +86,10 @@ pub fn check(build: &mut Build) {
build.config.nodejs = Some(node);
} else if let Some(node) = have_cmd("nodejs".as_ref()) {
build.config.nodejs = Some(node);
} else if let Some(node) = have_cmd("node.exe".as_ref()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for those extra checks, have_cmd will automatically consider .exe as well for each command.

Copy link
Member

Choose a reason for hiding this comment

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

(agreed yeah)

@TimNN
Copy link
Contributor

TimNN commented Nov 10, 2016

I don't think the current implementation needs much adjusting -- the only problem I can see with it is that it does not allow specifying the path to node in config.toml or via ./configure but will instead always search the path.

@Mark-Simulacrum
Copy link
Member Author

Hmm, yeah, I see that now. Can someone point me to where I can make those changes (if we want to)? Otherwise we can just close this.

@@ -110,6 +110,9 @@ pub fn compiletest(build: &Build,

if let Some(nodejs) = build.config.nodejs.as_ref() {
cmd.arg("--nodejs").arg(nodejs);
} else {
// FIXME: Print a message about being unable to detect a nodejs binary;
// and suggest a fix (passing --nodejs to configure?).
Copy link
Member

Choose a reason for hiding this comment

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

I think it's fine to leave this kind of error reporting to compiletest rather than in rustbuild itself

@@ -173,6 +173,9 @@ pub struct Config {
// status whether android device available or not
pub adb_device_status: bool,

// Name with which to invoke Node for asmjs targets
pub node_path: Option<String>,
Copy link
Member

Choose a reason for hiding this comment

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

This should be set at some point, right? (from the command-line flag)

Copy link
Contributor

Choose a reason for hiding this comment

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

There already is a nodejs option for compiletest (a few lines down).

@alexcrichton
Copy link
Member

@Mark-Simulacrum you can take a look at src/bootstrap/config.rs to support manual configuration of node (which seems great to have!). You can mirror the logic for a custom rustc/cargo by just adding appropriate fields to the structs there, parsing them out, and also parsing the line from ./configure (if it exists) to go into the right field.

@TimNN
Copy link
Contributor

TimNN commented Nov 10, 2016

Also you'll probably want to update the logic here to only try to auto detect node if it has not been specified by the user (somewhat like it's done for gdb just below).

@Mark-Simulacrum Mark-Simulacrum force-pushed the tari-nodejs-runner-detect branch 3 times, most recently from bfd3c58 to f752c98 Compare November 10, 2016 23:05
@Mark-Simulacrum
Copy link
Member Author

Alright, rebased and [hopefully] made this work with the comments suggested above.

@alexcrichton
Copy link
Member

@bors: r+

Thanks!

@bors
Copy link
Contributor

bors commented Nov 10, 2016

📌 Commit f752c98 has been approved by alexcrichton

Allow passing a custom nodejs directory in configure.
@Mark-Simulacrum
Copy link
Member Author

Mark-Simulacrum commented Nov 12, 2016

@bors did not seem to notice this was r+ed.

Edit: Bors noticed, but I pushed afterwards for some reason. I'm not sure why.

@eddyb
Copy link
Member

eddyb commented Nov 12, 2016

@bors r=alexcrichton

@bors
Copy link
Contributor

bors commented Nov 12, 2016

📌 Commit c524c50 has been approved by alexcrichton

@Mark-Simulacrum Mark-Simulacrum changed the title compiletest: detect nodejs binary, allow override compile-test: allow overriding nodejs binary location Nov 12, 2016
@bors
Copy link
Contributor

bors commented Nov 12, 2016

⌛ Testing commit c524c50 with merge fd983d0...

bors added a commit that referenced this pull request Nov 12, 2016
…lexcrichton

compile-test: allow overriding nodejs binary location

Add a command-line argument to manually specify which nodejs binary should be used,
which disables the default search.

Original work done by @tari.

Fixes #34188.
@bors bors merged commit c524c50 into rust-lang:master Nov 12, 2016
@Mark-Simulacrum Mark-Simulacrum deleted the tari-nodejs-runner-detect branch December 27, 2016 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants