Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

Expand All @@ -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 }}

Expand Down
119 changes: 94 additions & 25 deletions build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,40 +724,109 @@ 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],
/// 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: &[], environment_variables: &[] }
}

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
}

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 = [
//"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?
// 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"])
// 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"),
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<Item = &&str>| -> 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<Item = &Project>| -> 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 project_environment = env.clone();
for (name, value) in project.environment_variables {
project_environment.insert(name.to_string(), value.to_string());
}

Ok(())
};
let mut build_command: Vec<&dyn AsRef<OsStr>> = vec![&"build", &"--release"];
build_command.extend(
project.cargo_arguments.iter().map(|argument| argument as &dyn AsRef<OsStr>),
);
run_cargo_command(&build_command, Some(repo_path), &project_environment, args)?;

let mut test_command: Vec<&dyn AsRef<OsStr>> = vec![&"test"];
test_command.extend(
project.cargo_arguments.iter().map(|argument| argument as &dyn AsRef<OsStr>),
);
if !project.test_harness_arguments.is_empty() {
test_command.push(&"--");
test_command.extend(
project
.test_harness_arguments
.iter()
.map(|argument| argument as &dyn AsRef<OsStr>),
);
}
run_cargo_command(&test_command, Some(repo_path), &project_environment, args)?;
}

Ok(())
};

let projects_path = Path::new("projects");
create_dir(projects_path)?;
Expand Down
17 changes: 17 additions & 0 deletions tests/run/nonzero_div_ceil.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
Loading