Skip to content

Commit d4be232

Browse files
authored
Merge pull request #979 from rust-lang/fix/project-tests
Reenable some projects in tests
2 parents d5f2a49 + 6a7d5e6 commit d4be232

3 files changed

Lines changed: 117 additions & 26 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ jobs:
3535
"--extended-regex-tests",
3636
"--test-successful-rustc --nb-parts 2 --current-part 0",
3737
"--test-successful-rustc --nb-parts 2 --current-part 1",
38-
"--projects",
38+
"--projects --nb-parts 2 --current-part 0",
39+
"--projects --nb-parts 2 --current-part 1",
3940
"--gcc-asm-tests --test-release-libcore",
4041
]
4142

@@ -53,6 +54,10 @@ jobs:
5354
# `llvm-14-tools` is needed to install the `FileCheck` binary which is used for asm tests.
5455
run: sudo apt-get install ninja-build ripgrep llvm-14-tools llvm
5556

57+
- name: Install the libraries needed to build librsvg
58+
if: ${{ contains(matrix.commands, '--projects') }}
59+
run: sudo apt-get install libcairo2-dev libpango1.0-dev libfontconfig1-dev libfreetype-dev libharfbuzz-dev libxml2-dev libglib2.0-dev
60+
5661
- name: Download artifact
5762
run: curl -LO https://github.com/rust-lang/gcc/releases/latest/download/${{ matrix.libgccjit_version.gcc }}
5863

‎build_system/src/test.rs‎

Lines changed: 94 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -724,40 +724,109 @@ where
724724
// echo "[BUILD] sysroot in release mode"
725725
// ./build_sysroot/build_sysroot.sh --release
726726

727+
struct Project {
728+
url: &'static str,
729+
/// Arguments added to both the `cargo build` and the `cargo test` invocations.
730+
cargo_arguments: &'static [&'static str],
731+
/// Arguments forwarded to the test harness by `cargo test`.
732+
test_harness_arguments: &'static [&'static str],
733+
/// Variables added to the environment of both invocations.
734+
environment_variables: &'static [(&'static str, &'static str)],
735+
}
736+
737+
impl Project {
738+
const fn new(url: &'static str) -> Self {
739+
Self { url, cargo_arguments: &[], test_harness_arguments: &[], environment_variables: &[] }
740+
}
741+
742+
const fn cargo_arguments(mut self, arguments: &'static [&'static str]) -> Self {
743+
self.cargo_arguments = arguments;
744+
self
745+
}
746+
747+
const fn test_harness_arguments(mut self, arguments: &'static [&'static str]) -> Self {
748+
self.test_harness_arguments = arguments;
749+
self
750+
}
751+
752+
const fn environment_variables(
753+
mut self,
754+
variables: &'static [(&'static str, &'static str)],
755+
) -> Self {
756+
self.environment_variables = variables;
757+
self
758+
}
759+
}
760+
727761
fn test_projects(env: &Env, args: &TestArg) -> Result<(), String> {
728762
let projects = [
729-
//"https://gitlab.gnome.org/GNOME/librsvg", // FIXME: doesn't compile in the CI since the
730-
// version of cairo and other libraries is too old.
731-
"https://github.com/rust-random/getrandom",
732-
"https://github.com/BurntSushi/memchr",
733-
"https://github.com/dtolnay/itoa",
734-
"https://github.com/rust-lang/cfg-if",
735-
//"https://github.com/rust-lang-nursery/lazy-static.rs", // FIXME: re-enable when the
736-
//failing test is fixed upstream.
737-
//"https://github.com/marshallpierce/rust-base64", // FIXME: one test is OOM-killed.
738-
// FIXME: ignore the base64 test that is OOM-killed.
739-
//"https://github.com/time-rs/time", // FIXME: one test fails (https://github.com/time-rs/time/issues/719).
740-
"https://github.com/rust-lang/log",
741-
"https://github.com/bitflags/bitflags",
742-
//"https://github.com/serde-rs/serde", // FIXME: one test fails.
743-
//"https://github.com/rayon-rs/rayon", // FIXME: very slow, only run on master?
744-
//"https://github.com/rust-lang/cargo", // FIXME: very slow, only run on master?
763+
// The reference images assume the exact cairo, pango and freetype that librsvg pins in its
764+
// own CI; this one renders text decorations a pixel off with the versions Ubuntu ships.
765+
Project::new("https://gitlab.gnome.org/GNOME/librsvg")
766+
.test_harness_arguments(&["--skip", "tests::svg1_1_text_text_03_b_svg", "--exact"])
767+
// A debug build of librsvg needs about 5 MB of stack per `cargo test` thread to reach
768+
// its maximum layer nesting depth; librsvg's own CI sets the same value.
769+
.environment_variables(&[("RUST_MIN_STACK", "8388608")]),
770+
Project::new("https://github.com/rust-random/getrandom"),
771+
Project::new("https://github.com/BurntSushi/memchr"),
772+
Project::new("https://github.com/dtolnay/itoa"),
773+
Project::new("https://github.com/rust-lang/cfg-if"),
774+
// The `ui` test compares against the diagnostics of the compiler it was blessed with, so it
775+
// fails on the nightly we use no matter which backend produces the code.
776+
Project::new("https://github.com/rust-lang-nursery/lazy-static.rs")
777+
.test_harness_arguments(&["--skip", "ui", "--exact"]),
778+
Project::new("https://github.com/marshallpierce/rust-base64"),
779+
// The test suite refuses to build unless every feature is enabled; it otherwise spawns a
780+
// nested `cargo test --all-features` which would not use this backend.
781+
Project::new("https://github.com/time-rs/time").cargo_arguments(&["--all-features"]),
782+
Project::new("https://github.com/rust-lang/log"),
783+
Project::new("https://github.com/bitflags/bitflags"),
784+
Project::new("https://github.com/serde-rs/serde"),
785+
Project::new("https://github.com/rayon-rs/rayon"),
786+
// FIXME: too slow to run in the CI: the release build alone takes 46 minutes and the
787+
// `cargo` crate itself needs 5.4 GB of memory in a single rustc process.
788+
//Project::new("https://github.com/rust-lang/cargo"),
745789
];
746790

747791
let mut env = env.clone();
748792
let rustflags =
749793
format!("{} --cap-lints allow", env.get("RUSTFLAGS").cloned().unwrap_or_default());
750794
env.insert("RUSTFLAGS".to_string(), rustflags);
751-
let run_tests = |projects_path, iter: &mut dyn Iterator<Item = &&str>| -> Result<(), String> {
752-
for project in iter {
753-
let clone_result = git_clone_root_dir(project, projects_path, true)?;
754-
let repo_path = Path::new(&clone_result.repo_dir);
755-
run_cargo_command(&[&"build", &"--release"], Some(repo_path), &env, args)?;
756-
run_cargo_command(&[&"test"], Some(repo_path), &env, args)?;
757-
}
795+
let run_tests =
796+
|projects_path, iter: &mut dyn Iterator<Item = &Project>| -> Result<(), String> {
797+
for project in iter {
798+
let clone_result = git_clone_root_dir(project.url, projects_path, true)?;
799+
let repo_path = Path::new(&clone_result.repo_dir);
800+
801+
let mut project_environment = env.clone();
802+
for (name, value) in project.environment_variables {
803+
project_environment.insert(name.to_string(), value.to_string());
804+
}
758805

759-
Ok(())
760-
};
806+
let mut build_command: Vec<&dyn AsRef<OsStr>> = vec![&"build", &"--release"];
807+
build_command.extend(
808+
project.cargo_arguments.iter().map(|argument| argument as &dyn AsRef<OsStr>),
809+
);
810+
run_cargo_command(&build_command, Some(repo_path), &project_environment, args)?;
811+
812+
let mut test_command: Vec<&dyn AsRef<OsStr>> = vec![&"test"];
813+
test_command.extend(
814+
project.cargo_arguments.iter().map(|argument| argument as &dyn AsRef<OsStr>),
815+
);
816+
if !project.test_harness_arguments.is_empty() {
817+
test_command.push(&"--");
818+
test_command.extend(
819+
project
820+
.test_harness_arguments
821+
.iter()
822+
.map(|argument| argument as &dyn AsRef<OsStr>),
823+
);
824+
}
825+
run_cargo_command(&test_command, Some(repo_path), &project_environment, args)?;
826+
}
827+
828+
Ok(())
829+
};
761830

762831
let projects_path = Path::new("projects");
763832
create_dir(projects_path)?;

‎tests/run/nonzero_div_ceil.rs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Compiler:
2+
//
3+
// Run-time:
4+
// status: 0
5+
6+
use std::hint::black_box;
7+
use std::num::NonZero;
8+
9+
fn main() {
10+
for (dividend, divisor, expected) in
11+
[(10u8, 3u8, 4u8), (1, 254, 1), (1, 255, 1), (2, 254, 1), (2, 255, 1), (200, 100, 2)]
12+
{
13+
let dividend = NonZero::new(black_box(dividend)).unwrap();
14+
let divisor = NonZero::new(black_box(divisor)).unwrap();
15+
assert_eq!(dividend.div_ceil(divisor).get(), expected);
16+
}
17+
}

0 commit comments

Comments
 (0)