From 5edb259c652ce8bed8477ec54fa37cc48f3472eb Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Thu, 3 Sep 2026 15:59:41 -0400 Subject: [PATCH 1/4] Add non-zero div test --- tests/run/nonzero_div_ceil.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/run/nonzero_div_ceil.rs diff --git a/tests/run/nonzero_div_ceil.rs b/tests/run/nonzero_div_ceil.rs new file mode 100644 index 00000000000..e6bd3c2ec98 --- /dev/null +++ b/tests/run/nonzero_div_ceil.rs @@ -0,0 +1,17 @@ +// Compiler: +// +// Run-time: +// status: 0 + +use std::hint::black_box; +use std::num::NonZero; + +fn main() { + for (dividend, divisor, expected) in + [(10u8, 3u8, 4u8), (1, 254, 1), (1, 255, 1), (2, 254, 1), (2, 255, 1), (200, 100, 2)] + { + let dividend = NonZero::new(black_box(dividend)).unwrap(); + let divisor = NonZero::new(black_box(divisor)).unwrap(); + assert_eq!(dividend.div_ceil(divisor).get(), expected); + } +} From 64b42492d543805383e225cf0062b88060ffc99b Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 4 Sep 2026 10:04:55 -0400 Subject: [PATCH 2/4] Re-enable disabled project tests --- .github/workflows/ci.yml | 7 ++- build_system/src/test.rs | 98 ++++++++++++++++++++++++++++++---------- 2 files changed, 79 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 529003fc384..2f5cc409e36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,8 @@ jobs: "--extended-regex-tests", "--test-successful-rustc --nb-parts 2 --current-part 0", "--test-successful-rustc --nb-parts 2 --current-part 1", - "--projects", + "--projects --nb-parts 2 --current-part 0", + "--projects --nb-parts 2 --current-part 1", "--gcc-asm-tests --test-release-libcore", ] @@ -53,6 +54,10 @@ jobs: # `llvm-14-tools` is needed to install the `FileCheck` binary which is used for asm tests. run: sudo apt-get install ninja-build ripgrep llvm-14-tools llvm + - name: Install the libraries needed to build librsvg + if: ${{ contains(matrix.commands, '--projects') }} + run: sudo apt-get install libcairo2-dev libpango1.0-dev libfontconfig1-dev libfreetype-dev libharfbuzz-dev libxml2-dev libglib2.0-dev + - name: Download artifact run: curl -LO https://github.com/rust-lang/gcc/releases/latest/download/${{ matrix.libgccjit_version.gcc }} diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 6f33bdc3929..8fd495f82e2 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -724,40 +724,88 @@ where // echo "[BUILD] sysroot in release mode" // ./build_sysroot/build_sysroot.sh --release +struct Project { + url: &'static str, + /// Arguments added to both the `cargo build` and the `cargo test` invocations. + cargo_arguments: &'static [&'static str], + /// Arguments forwarded to the test harness by `cargo test`. + test_harness_arguments: &'static [&'static str], +} + +impl Project { + const fn new(url: &'static str) -> Self { + Self { url, cargo_arguments: &[], test_harness_arguments: &[] } + } + + const fn cargo_arguments(mut self, arguments: &'static [&'static str]) -> Self { + self.cargo_arguments = arguments; + self + } + + const fn test_harness_arguments(mut self, arguments: &'static [&'static str]) -> Self { + self.test_harness_arguments = arguments; + self + } +} + fn test_projects(env: &Env, args: &TestArg) -> Result<(), String> { let projects = [ - //"https://gitlab.gnome.org/GNOME/librsvg", // FIXME: doesn't compile in the CI since the - // version of cairo and other libraries is too old. - "https://github.com/rust-random/getrandom", - "https://github.com/BurntSushi/memchr", - "https://github.com/dtolnay/itoa", - "https://github.com/rust-lang/cfg-if", - //"https://github.com/rust-lang-nursery/lazy-static.rs", // FIXME: re-enable when the - //failing test is fixed upstream. - //"https://github.com/marshallpierce/rust-base64", // FIXME: one test is OOM-killed. - // FIXME: ignore the base64 test that is OOM-killed. - //"https://github.com/time-rs/time", // FIXME: one test fails (https://github.com/time-rs/time/issues/719). - "https://github.com/rust-lang/log", - "https://github.com/bitflags/bitflags", - //"https://github.com/serde-rs/serde", // FIXME: one test fails. - //"https://github.com/rayon-rs/rayon", // FIXME: very slow, only run on master? - //"https://github.com/rust-lang/cargo", // FIXME: very slow, only run on master? + Project::new("https://gitlab.gnome.org/GNOME/librsvg"), + Project::new("https://github.com/rust-random/getrandom"), + Project::new("https://github.com/BurntSushi/memchr"), + Project::new("https://github.com/dtolnay/itoa"), + Project::new("https://github.com/rust-lang/cfg-if"), + // The `ui` test compares against the diagnostics of the compiler it was blessed with, so it + // fails on the nightly we use no matter which backend produces the code. + Project::new("https://github.com/rust-lang-nursery/lazy-static.rs") + .test_harness_arguments(&["--skip", "ui", "--exact"]), + Project::new("https://github.com/marshallpierce/rust-base64"), + // The test suite refuses to build unless every feature is enabled; it otherwise spawns a + // nested `cargo test --all-features` which would not use this backend. + Project::new("https://github.com/time-rs/time").cargo_arguments(&["--all-features"]), + Project::new("https://github.com/rust-lang/log"), + Project::new("https://github.com/bitflags/bitflags"), + Project::new("https://github.com/serde-rs/serde"), + Project::new("https://github.com/rayon-rs/rayon"), + // FIXME: too slow to run in the CI: the release build alone takes 46 minutes and the + // `cargo` crate itself needs 5.4 GB of memory in a single rustc process. + //Project::new("https://github.com/rust-lang/cargo"), ]; let mut env = env.clone(); let rustflags = format!("{} --cap-lints allow", env.get("RUSTFLAGS").cloned().unwrap_or_default()); env.insert("RUSTFLAGS".to_string(), rustflags); - let run_tests = |projects_path, iter: &mut dyn Iterator| -> Result<(), String> { - for project in iter { - let clone_result = git_clone_root_dir(project, projects_path, true)?; - let repo_path = Path::new(&clone_result.repo_dir); - run_cargo_command(&[&"build", &"--release"], Some(repo_path), &env, args)?; - run_cargo_command(&[&"test"], Some(repo_path), &env, args)?; - } + let run_tests = + |projects_path, iter: &mut dyn Iterator| -> Result<(), String> { + for project in iter { + let clone_result = git_clone_root_dir(project.url, projects_path, true)?; + let repo_path = Path::new(&clone_result.repo_dir); + + let mut build_command: Vec<&dyn AsRef> = vec![&"build", &"--release"]; + build_command.extend( + project.cargo_arguments.iter().map(|argument| argument as &dyn AsRef), + ); + run_cargo_command(&build_command, Some(repo_path), &env, args)?; - Ok(()) - }; + let mut test_command: Vec<&dyn AsRef> = vec![&"test"]; + test_command.extend( + project.cargo_arguments.iter().map(|argument| argument as &dyn AsRef), + ); + if !project.test_harness_arguments.is_empty() { + test_command.push(&"--"); + test_command.extend( + project + .test_harness_arguments + .iter() + .map(|argument| argument as &dyn AsRef), + ); + } + run_cargo_command(&test_command, Some(repo_path), &env, args)?; + } + + Ok(()) + }; let projects_path = Path::new("projects"); create_dir(projects_path)?; From 0dd8e990cdbc3178f52de654642f1e52b407ffe2 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Thu, 17 Sep 2026 20:28:41 -0400 Subject: [PATCH 3/4] Ignore a librsvg test since it fails in CI --- build_system/src/test.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 8fd495f82e2..01375c2c33d 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -750,7 +750,13 @@ impl Project { fn test_projects(env: &Env, args: &TestArg) -> Result<(), String> { let projects = [ - Project::new("https://gitlab.gnome.org/GNOME/librsvg"), + // The reference images assume the exact cairo, pango and freetype that librsvg pins in its + // own CI; this one renders text decorations a pixel off with the versions Ubuntu ships. + Project::new("https://gitlab.gnome.org/GNOME/librsvg").test_harness_arguments(&[ + "--skip", + "tests::svg1_1_text_text_03_b_svg", + "--exact", + ]), Project::new("https://github.com/rust-random/getrandom"), Project::new("https://github.com/BurntSushi/memchr"), Project::new("https://github.com/dtolnay/itoa"), From 6a7d5e64dd6b1f4d8de6f68a3840a170fd189d3e Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Fri, 18 Sep 2026 06:55:00 -0400 Subject: [PATCH 4/4] Fix for librsvg project tests --- build_system/src/test.rs | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 01375c2c33d..a55c2dcf83d 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -730,11 +730,13 @@ struct Project { cargo_arguments: &'static [&'static str], /// Arguments forwarded to the test harness by `cargo test`. test_harness_arguments: &'static [&'static str], + /// Variables added to the environment of both invocations. + environment_variables: &'static [(&'static str, &'static str)], } impl Project { const fn new(url: &'static str) -> Self { - Self { url, cargo_arguments: &[], test_harness_arguments: &[] } + Self { url, cargo_arguments: &[], test_harness_arguments: &[], environment_variables: &[] } } const fn cargo_arguments(mut self, arguments: &'static [&'static str]) -> Self { @@ -746,17 +748,25 @@ impl Project { self.test_harness_arguments = arguments; self } + + const fn environment_variables( + mut self, + variables: &'static [(&'static str, &'static str)], + ) -> Self { + self.environment_variables = variables; + self + } } fn test_projects(env: &Env, args: &TestArg) -> Result<(), String> { let projects = [ // The reference images assume the exact cairo, pango and freetype that librsvg pins in its // own CI; this one renders text decorations a pixel off with the versions Ubuntu ships. - Project::new("https://gitlab.gnome.org/GNOME/librsvg").test_harness_arguments(&[ - "--skip", - "tests::svg1_1_text_text_03_b_svg", - "--exact", - ]), + Project::new("https://gitlab.gnome.org/GNOME/librsvg") + .test_harness_arguments(&["--skip", "tests::svg1_1_text_text_03_b_svg", "--exact"]) + // A debug build of librsvg needs about 5 MB of stack per `cargo test` thread to reach + // its maximum layer nesting depth; librsvg's own CI sets the same value. + .environment_variables(&[("RUST_MIN_STACK", "8388608")]), Project::new("https://github.com/rust-random/getrandom"), Project::new("https://github.com/BurntSushi/memchr"), Project::new("https://github.com/dtolnay/itoa"), @@ -788,11 +798,16 @@ fn test_projects(env: &Env, args: &TestArg) -> Result<(), String> { let clone_result = git_clone_root_dir(project.url, projects_path, true)?; let repo_path = Path::new(&clone_result.repo_dir); + let mut project_environment = env.clone(); + for (name, value) in project.environment_variables { + project_environment.insert(name.to_string(), value.to_string()); + } + let mut build_command: Vec<&dyn AsRef> = vec![&"build", &"--release"]; build_command.extend( project.cargo_arguments.iter().map(|argument| argument as &dyn AsRef), ); - run_cargo_command(&build_command, Some(repo_path), &env, args)?; + run_cargo_command(&build_command, Some(repo_path), &project_environment, args)?; let mut test_command: Vec<&dyn AsRef> = vec![&"test"]; test_command.extend( @@ -807,7 +822,7 @@ fn test_projects(env: &Env, args: &TestArg) -> Result<(), String> { .map(|argument| argument as &dyn AsRef), ); } - run_cargo_command(&test_command, Some(repo_path), &env, args)?; + run_cargo_command(&test_command, Some(repo_path), &project_environment, args)?; } Ok(())