Skip to content

Commit

Permalink
Run the tests of popular crates in the CI
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Feb 8, 2024
1 parent 8235b26 commit cb4226c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
"--extended-regex-tests",
"--test-successful-rustc --nb-parts 2 --current-part 0",
"--test-successful-rustc --nb-parts 2 --current-part 1",
"--projects",
]

steps:
Expand Down
35 changes: 33 additions & 2 deletions build_system/src/test.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::build;
use crate::config::{Channel, ConfigInfo};
use crate::utils::{
get_gcc_path, get_toolchain, remove_file, run_command, run_command_with_env,
get_gcc_path, get_toolchain, git_clone, remove_file, run_command, run_command_with_env,
run_command_with_output_and_env, rustc_version_info, split_args, walk_dir,
};

use std::collections::{BTreeSet, HashMap};
use std::ffi::OsStr;
use std::fs::{remove_dir_all, File};
use std::fs::{create_dir_all, remove_dir_all, File};
use std::io::{BufRead, BufReader};
use std::path::{Path, PathBuf};
use std::str::FromStr;
Expand All @@ -31,6 +31,7 @@ fn get_runners() -> Runners {
"--test-failing-rustc",
("Run failing rustc tests", test_failing_rustc),
);
runners.insert("--projects", ("Run the tests of popular crates", test_projects));
runners.insert("--test-libcore", ("Run libcore tests", test_libcore));
runners.insert("--clean", ("Empty cargo target directory", clean));
runners.insert("--build-sysroot", ("Build sysroot", build_sysroot));
Expand Down Expand Up @@ -679,6 +680,36 @@ where
// echo "[BUILD] sysroot in release mode"
// ./build_sysroot/build_sysroot.sh --release

fn test_projects(env: &Env, args: &TestArg) -> Result<(), String> {
let projects = [
//"https://gitlab.gnome.org/GNOME/librsvg", // FIXME: latest commit causes a segfault in libgccjit.
"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",
//"https://github.com/marshallpierce/rust-base64", // FIXME: one test is OOM-killed.
// TODO: ignore the base64 test that is OOM-killed.
"https://github.com/time-rs/time",
"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",
// "https://github.com/rust-lang/cargo", // TODO: very slow, only run on master?
];
for project in projects {
let projects_path = Path::new("projects");
create_dir_all(projects_path)
.map_err(|err| format!("Failed to create directory `projects`: {}", err))?;
let clone_result = git_clone(project, Some(projects_path))?;
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)?;
}

Ok(())
}

fn test_libcore(env: &Env, args: &TestArg) -> Result<(), String> {
// FIXME: create a function "display_if_not_quiet" or something along the line.
println!("[TEST] libcore");
Expand Down
5 changes: 4 additions & 1 deletion build_system/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ pub fn get_gcc_path() -> Result<String, String> {
pub struct CloneResult {
pub ran_clone: bool,
pub repo_name: String,
pub repo_dir: String,
}

pub fn git_clone(to_clone: &str, dest: Option<&Path>) -> Result<CloneResult, String> {
Expand All @@ -299,13 +300,15 @@ pub fn git_clone(to_clone: &str, dest: Option<&Path>) -> Result<CloneResult, Str
return Ok(CloneResult {
ran_clone: false,
repo_name,
repo_dir: dest.display().to_string(),
});
}

run_command_with_output(&[&"git", &"clone", &to_clone, &dest], None)?;
run_command_with_output(&[&"git", &"clone", &"--depth", &"1", &to_clone, &dest], None)?;
Ok(CloneResult {
ran_clone: true,
repo_name,
repo_dir: dest.display().to_string(),
})
}

Expand Down

0 comments on commit cb4226c

Please sign in to comment.