-
Notifications
You must be signed in to change notification settings - Fork 13k
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
./x.py test should be able to run individual tests #49729
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Thanks for the PR! I've long wanted to do this! I think though this may be best done in rustbuild itself because we can't always just chop off one filename, but instead may have to chop off a few to get to the name of the test suite. (which the python script doens't know about but rustbuild does) |
Going to try doing this. Thank you 👍 |
f565e32
to
db57d81
Compare
Hi @alexcrichton, I've made the requested changes. PR should now be ready for another review. Thank you. |
Thanks! Looks reasonable to me, but to double check... |
src/bootstrap/test.rs
Outdated
// Get test-args by striping suite path | ||
let mut test_args: Vec<&str> = vec![]; | ||
paths.iter().filter(|p| p.starts_with(path) && p.is_file()) | ||
.for_each(|p| test_args.push(&p.strip_prefix(path).unwrap().to_str().unwrap())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be possible the rewrite as a collect.
src/bootstrap/builder.rs
Outdated
@@ -70,6 +70,8 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { | |||
/// Run this rule for all hosts without cross compiling. | |||
const ONLY_HOSTS: bool = false; | |||
|
|||
const PATH: &'static str = "not set"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather not add this here as it feels like the wrong place to put it, could you try instead having it returned as part of ShouldRun
? I think that should be relatively minimally impactful on the code, just moving a few things around. Calling should_run
multiple times is fine. I'd also appreciate renaming it to suite_path
and making it an Option
.
Please also verify that a mix of specific tests and crates works: ./x.py test src/test/run-pass/foo.rs src/bootstrap
should test both the specific test and bootstrap. I think the current code might not quite do this, but I'm not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'm on it
ff88d09
to
312e32f
Compare
Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@Mark-Simulacrum Thanks! I've worked on the feedback. Also mix of specific tests and crates i.e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a few more comments, but this is looking better! Thanks for working through this.
src/bootstrap/builder.rs
Outdated
for p in paths { | ||
if p.starts_with(&suite) { | ||
suites.push(PathBuf::from(suite)); | ||
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels wrong to me; if ./x.py test src/test/run-pass src/test/compile-fail
is invoked I'd expect the break to exit too early for us to populate suites for both tests.
It'd would also somewhat surprise me if this will work as-is when given a path to say src/libstd
since those are all set as individual paths inside the pathset, whereas the "suite" detection only matches the last path given. It might be best to restructure to have suite-matching be separate and orthogonal to the path-matching to avoid that problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, Could you please clarify on this if you don't mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, the way this code handles suites conflates them with the paths that could invoke a given Step. I think that's the wrong distinction to have as it adds little benefit and increases maintenance burden by connecting two concepts that are mostly unrelated. Instead, I would rather see these modifications contained to changes in maybe_run
and the code that calls it. Essentially, I'd expect another case added that calls should_run.is_suite_path(path)
or something like and then maybe_run can be called with a PathSet::Suite
(making PathSet
an enum). Does that help clarify? I can maybe explain in further detail.
Sorry for the somewhat moving target here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's alright. I now get it. Thanks! Will let you know if I get any more questions.
|
||
// Get test-args by striping suite path | ||
let mut test_args: Vec<&str> = paths.iter().filter(|p| p.starts_with(suite_path) && | ||
p.is_file()).map(|p| p.strip_prefix(suite_path).unwrap().to_str().unwrap()).collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably error out here if the argument is going to be silently ignored because it's part of our suite yet not a file (and as such we don't know what to do with it).
src/bootstrap/test.rs
Outdated
let mut test_args: Vec<&str> = paths.iter().filter(|p| p.starts_with(suite_path) && | ||
p.is_file()).map(|p| p.strip_prefix(suite_path).unwrap().to_str().unwrap()).collect(); | ||
|
||
if test_args.is_empty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any additional test args passed the command line should rather be appended to the existing set of paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! going to fix this ASAP
☔ The latest upstream changes (presumably #49972) made this pull request unmergeable. Please resolve the merge conflicts. |
Hi @Mark-Simulacrum, sorry for the delay on this, I've been kind of busy lately. You can now take another look. Thanks |
src/bootstrap/builder.rs
Outdated
self.set.iter().any(|p| p.ends_with(needle)) | ||
match self { | ||
PathSet::Set(set) => set.iter().any(|p| p.ends_with(needle)), | ||
_ => false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be explicit about which variant's are false here.
src/bootstrap/builder.rs
Outdated
self.set.iter().next().unwrap_or(&builder.build.src).to_path_buf() | ||
match self { | ||
PathSet::Set(set) => set.iter().next().unwrap_or(&builder.build.src).to_path_buf(), | ||
_ => PathBuf::from("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's instead return an Option
from path or panic if we don't expect it to be called on suites.
src/bootstrap/builder.rs
Outdated
if let Some(suite) = should_run.is_suite_path(path) { | ||
attempted_run = true; | ||
desc.maybe_run(builder, suite); | ||
} | ||
if let Some(pathset) = should_run.pathset_for_path(path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for sanity's sake, let's make this an else
perhaps? I think it'll make it easier to reason about when steps are run.
src/bootstrap/test.rs
Outdated
@@ -672,12 +674,13 @@ macro_rules! test_definitions { | |||
}); | |||
} | |||
|
|||
fn run(self, builder: &Builder) { | |||
fn run(self,builder: &Builder) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: space required
src/bootstrap/test.rs
Outdated
|
||
// Get test-args by striping suite path | ||
let is_file = |p: &PathBuf| { | ||
assert!(p.is_file(), "{:?} is not a valid file", p); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change the message here to be Expected {:?} to be a path to a test file
to be clearer about the reason for this error.
src/bootstrap/test.rs
Outdated
}; | ||
|
||
// Get test-args by striping suite path | ||
let is_file = |p: &PathBuf| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change this to assert_file
to be clearer.
src/bootstrap/builder.rs
Outdated
@@ -7,7 +7,6 @@ | |||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |||
// option. This file may not be copied, modified, or distributed | |||
// except according to those terms. | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This line should stay.
Thanks! Fixed. |
Ping from triage, @Mark-Simulacrum — looks like it's ready again! |
Thank you for taking this on! Let me know if you'd like another project in rustbuild to work on (there's a few cleanups that should be relatively straightforward, if you're interested); we can also put you in touch with other rust teams/working groups if you'd like to try something different. @bors r+ |
📌 Commit 281f534 has been approved by |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
src/bootstrap/test.rs
Outdated
|
||
// Get test-args by striping suite path | ||
let assert_file = |p: &PathBuf| { | ||
assert!(p.is_file(), "Expected {:?} to be a path to a test file", p); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Mark-Simulacrum Sorry, I missed this. Looks like this panics with ./x.py test suite_path
I think we should just ignore test args if suite path
is specified.
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors r+ |
📌 Commit bd8f2a0 has been approved by |
Fixed! r? @Mark-Simulacrum |
@bors r+ |
📌 Commit 2f8c2a9 has been approved by |
./x.py test should be able to run individual tests Allows user to be able to run individual tests by specifying filename i.e `./x.py test src/test/run-pass/foo.rs` Fixes #48483
☀️ Test successful - status-appveyor, status-travis |
Allows user to be able to run individual tests by specifying filename i.e
./x.py test src/test/run-pass/foo.rs
Fixes #48483