-
Notifications
You must be signed in to change notification settings - Fork 77
modifed y.sh to allow for running cargo tests. #669
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
Open
FractalFir
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
FractalFir:y_cargo_tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ fn get_runners() -> Runners { | |
); | ||
runners.insert("--extended-regex-tests", ("Run extended regex tests", extended_regex_tests)); | ||
runners.insert("--mini-tests", ("Run mini tests", mini_tests)); | ||
|
||
runners.insert("--cargo-tests", ("Run cargo tests", cargo_tests)); | ||
runners | ||
} | ||
|
||
|
@@ -88,6 +88,8 @@ struct TestArg { | |
use_system_gcc: bool, | ||
runners: Vec<String>, | ||
flags: Vec<String>, | ||
/// Additonal arguments, to be passed to commands like `cargo test`. | ||
test_args: Vec<String>, | ||
nb_parts: Option<usize>, | ||
current_part: Option<usize>, | ||
sysroot_panic_abort: bool, | ||
|
@@ -144,6 +146,7 @@ impl TestArg { | |
show_usage(); | ||
return Ok(None); | ||
} | ||
"--" => test_arg.test_args.extend(&mut args), | ||
x if runners.contains_key(x) | ||
&& !test_arg.runners.iter().any(|runner| runner == x) => | ||
{ | ||
|
@@ -203,6 +206,32 @@ fn clean(_env: &Env, args: &TestArg) -> Result<(), String> { | |
create_dir(&path) | ||
} | ||
|
||
fn cargo_tests(test_env: &Env, test_args: &TestArg) -> Result<(), String> { | ||
antoyo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// First, we call `mini_tests` to build minicore for us. This ensures we are testing with a working `minicore`, | ||
// and that any changes we have made affect `minicore`(since it would get rebuilt). | ||
mini_tests(test_env, test_args)?; | ||
// Then, we copy some of the env vars from `test_env` | ||
// We don't want to pass things like `RUSTFLAGS`, since they contain the -Zcodegen-backend flag. | ||
// That would force `cg_gcc` to *rebuild itself* and only then run tests, which is undesirable. | ||
let mut env = HashMap::new(); | ||
env.insert( | ||
"LD_LIBRARY_PATH".into(), | ||
test_env.get("LD_LIBRARY_PATH").expect("LD_LIBRARY_PATH missing!").to_string(), | ||
); | ||
env.insert( | ||
"LIBRARY_PATH".into(), | ||
test_env.get("LIBRARY_PATH").expect("LIBRARY_PATH missing!").to_string(), | ||
); | ||
env.insert( | ||
"CG_RUSTFLAGS".into(), | ||
test_env.get("CG_RUSTFLAGS").map(|s| s.as_str()).unwrap_or("").to_string(), | ||
); | ||
// Pass all the default args + the user-specified ones. | ||
let mut args: Vec<&dyn AsRef<OsStr>> = vec![&"cargo", &"test"]; | ||
args.extend(test_args.test_args.iter().map(|s| s as &dyn AsRef<OsStr>)); | ||
run_command_with_output_and_env(&args, None, Some(&env))?; | ||
Ok(()) | ||
} | ||
fn mini_tests(env: &Env, args: &TestArg) -> Result<(), String> { | ||
// FIXME: create a function "display_if_not_quiet" or something along the line. | ||
println!("[BUILD] mini_core"); | ||
|
@@ -1218,6 +1247,7 @@ fn run_all(env: &Env, args: &TestArg) -> Result<(), String> { | |
test_libcore(env, args)?; | ||
extended_sysroot_tests(env, args)?; | ||
test_rustc(env, args)?; | ||
cargo_tests(env, args)?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this ran? I'm asking because |
||
Ok(()) | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
As a reminder:
Could you please update the doc and the CI to use this new command instead of cargo test?