diff options
| author | michal kostrubiec <fractalfirdev@gmail.com> | 2025-05-09 22:47:20 +0200 |
|---|---|---|
| committer | michal kostrubiec <fractalfirdev@gmail.com> | 2025-05-28 23:45:53 +0200 |
| commit | d098c8a2beda9911a0274b8658e4362e8e185a32 (patch) | |
| tree | b419cb0aa4d34053f258ffb6f0155543782712db | |
| parent | cfe88fa8318ecf6aa2947a6314c0dcdc830e7de0 (diff) | |
| download | rust-d098c8a2beda9911a0274b8658e4362e8e185a32.tar.gz rust-d098c8a2beda9911a0274b8658e4362e8e185a32.zip | |
modifed y.sh to allow for running cargo tests.
| -rw-r--r-- | .github/workflows/ci.yml | 3 | ||||
| -rw-r--r-- | .github/workflows/m68k.yml | 2 | ||||
| -rw-r--r-- | .github/workflows/release.yml | 3 | ||||
| -rw-r--r-- | .github/workflows/stdarch.yml | 2 | ||||
| -rw-r--r-- | CONTRIBUTING.md | 2 | ||||
| -rw-r--r-- | build_system/src/test.rs | 34 |
6 files changed, 38 insertions, 8 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef024258ffc..91c5abaa6b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,8 +80,7 @@ jobs: run: | ./y.sh prepare --only-libcore ./y.sh build --sysroot - ./y.sh test --mini-tests - cargo test + ./y.sh test --cargo-tests - name: Run y.sh cargo build run: | diff --git a/.github/workflows/m68k.yml b/.github/workflows/m68k.yml index 21731f7087e..b905707deda 100644 --- a/.github/workflows/m68k.yml +++ b/.github/workflows/m68k.yml @@ -95,7 +95,7 @@ jobs: ./y.sh prepare --only-libcore --cross ./y.sh build --sysroot --features compiler_builtins/no-f16-f128 --target-triple m68k-unknown-linux-gnu ./y.sh test --mini-tests - CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu cargo test + CG_GCC_TEST_TARGET=m68k-unknown-linux-gnu ./y.sh test --cargo-tests ./y.sh clean all - name: Prepare dependencies diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 47a40286554..51d84c92b44 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,8 +56,7 @@ jobs: run: | ./y.sh prepare --only-libcore EMBED_LTO_BITCODE=1 ./y.sh build --sysroot --release --release-sysroot - ./y.sh test --mini-tests - cargo test + ./y.sh test --cargo-tests ./y.sh clean all - name: Prepare dependencies diff --git a/.github/workflows/stdarch.yml b/.github/workflows/stdarch.yml index 4b9f48e7b18..93e5019ec88 100644 --- a/.github/workflows/stdarch.yml +++ b/.github/workflows/stdarch.yml @@ -90,7 +90,7 @@ jobs: if: ${{ !matrix.cargo_runner }} run: | ./y.sh test --release --clean --release-sysroot --build-sysroot --mini-tests --std-tests --test-libcore - cargo test + ./y.sh test --cargo-tests - name: Run stdarch tests if: ${{ !matrix.cargo_runner }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8e313ab08b5..54cba0e6de3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,7 +33,7 @@ To run specific tests, use appropriate flags such as: - `./y.sh test --test-libcore` - `./y.sh test --std-tests` -- `cargo test -- <name of test>` +- `./y.sh test --cargo-tests -- <name of test>` Additionally, you can run the tests of `libgccjit`: diff --git a/build_system/src/test.rs b/build_system/src/test.rs index df4ac85233b..959f49ff937 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -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>, + /// Additional 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,33 @@ fn clean(_env: &Env, args: &TestArg) -> Result<(), String> { create_dir(&path) } +fn cargo_tests(test_env: &Env, test_args: &TestArg) -> Result<(), String> { + // 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"); @@ -1217,7 +1247,9 @@ fn run_all(env: &Env, args: &TestArg) -> Result<(), String> { // asm_tests(env, args)?; test_libcore(env, args)?; extended_sysroot_tests(env, args)?; + cargo_tests(env, args)?; test_rustc(env, args)?; + Ok(()) } |
