Skip to content

Commit 5272806

Browse files
committed
test improvs
1 parent be08dfc commit 5272806

File tree

3 files changed

+39
-47
lines changed

3 files changed

+39
-47
lines changed

.github/workflows/ci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ jobs:
4747

4848
- name: Install packages
4949
# `llvm-14-tools` is needed to install the `FileCheck` binary which is used for asm tests.
50-
run: |
51-
sudo apt-get install ninja-build ripgrep llvm-14-tools libstdc++-11-dev
50+
run: sudo apt-get install ninja-build ripgrep llvm-14-tools
5251

5352
- name: Install rustfmt & clippy
5453
run: rustup component add rustfmt clippy

build_system/src/test.rs

+35-45
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ fn should_remove_test(file_path: &Path) -> Result<bool, String> {
840840
"-Cllvm-args",
841841
"//~",
842842
"thread",
843+
"//@ known-bug"
843844
]
844845
.iter()
845846
.any(|check| line.contains(check))
@@ -865,11 +866,13 @@ fn test_rustc_inner<F>(
865866
where
866867
F: Fn(&Path) -> Result<bool, String>,
867868
{
869+
// FIXME: create a function "display_if_not_quiet" or something along the line.
868870
println!("[TEST] rust-lang/rust");
869871
let mut env = env.clone();
870872
let rust_path = setup_rustc(&mut env, args)?;
871873

872874
if !prepare_files_callback(&rust_path)? {
875+
// FIXME: create a function "display_if_not_quiet" or something along the line.
873876
println!("Keeping all {} tests", test_type);
874877
}
875878

@@ -899,6 +902,8 @@ where
899902
|_| Ok(()),
900903
)?;
901904

905+
// These two functions are used to remove files that are known to not be working currently
906+
// with the GCC backend to reduce noise.
902907
fn dir_handling(dir: &Path) -> Result<(), String> {
903908
if dir.file_name().map(|name| name == "auxiliary").unwrap_or(true) {
904909
return Ok(());
@@ -918,16 +923,6 @@ where
918923
Ok(())
919924
}
920925

921-
remove_file(&rust_path.join("tests/ui/consts/const_cmp_type_id.rs"))?;
922-
remove_file(&rust_path.join("tests/ui/consts/issue-73976-monomorphic.rs"))?;
923-
// this test is oom-killed in the CI.
924-
remove_file(&rust_path.join("tests/ui/consts/issue-miri-1910.rs"))?;
925-
// Tests generating errors.
926-
remove_file(&rust_path.join("tests/ui/consts/issue-94675.rs"))?;
927-
remove_file(&rust_path.join("tests/ui/mir/mir_heavy_promoted.rs"))?;
928-
remove_file(&rust_path.join("tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop-fail.rs"))?;
929-
remove_file(&rust_path.join("tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs"))?;
930-
931926
walk_dir(rust_path.join("tests/ui"), dir_handling, file_handling)?;
932927

933928
let nb_parts = args.nb_parts.unwrap_or(0);
@@ -960,7 +955,10 @@ where
960955
.map(|line| line.trim())
961956
.filter(|line| !line.is_empty())
962957
.collect::<Vec<_>>();
958+
// To ensure it'll be always the same sub files, we sort the content.
963959
files.sort();
960+
// We increment the number of tests by one because if this is an odd number, we would skip
961+
// one test.
964962
let count = files.len() / nb_parts + 1;
965963
let start = current_part * count;
966964
for path in files.iter().skip(start).take(count) {
@@ -969,18 +967,19 @@ where
969967
}
970968
}
971969

970+
// FIXME: create a function "display_if_not_quiet" or something along the line.
972971
println!("[TEST] rustc {} test suite", test_type);
973972
env.insert("COMPILETEST_FORCE_STAGE0".to_string(), "1".to_string());
974973

975974
let extra =
976975
if args.is_using_gcc_master_branch() { "" } else { " -Csymbol-mangling-version=v0" };
977976

978977
let rustc_args = format!(
979-
"{} -Zcodegen-backend={} --sysroot {}{}",
980-
env.get("TEST_FLAGS").unwrap_or(&String::new()),
981-
args.config_info.cg_backend_path,
982-
args.config_info.sysroot_path,
983-
extra,
978+
"{test_flags} -Zcodegen-backend={backend} --sysroot {sysroot}{extra}",
979+
test_flags = env.get("TEST_FLAGS").unwrap_or(&String::new()),
980+
backend = args.config_info.cg_backend_path,
981+
sysroot = args.config_info.sysroot_path,
982+
extra = extra,
984983
);
985984

986985
env.get_mut("RUSTFLAGS").unwrap().clear();
@@ -1009,18 +1008,21 @@ fn test_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
10091008
}
10101009

10111010
fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
1012-
test_rustc_inner(
1011+
let result1 = test_rustc_inner(
10131012
env,
10141013
args,
10151014
prepare_files_callback_failing("tests/failing-run-make-tests.txt", "run-make"),
10161015
"run-make",
1017-
)?;
1018-
test_rustc_inner(
1016+
);
1017+
1018+
let result2 = test_rustc_inner(
10191019
env,
10201020
args,
10211021
prepare_files_callback_failing("tests/failing-ui-tests.txt", "ui"),
10221022
"ui",
1023-
)
1023+
);
1024+
1025+
result1.and(result2)
10241026
}
10251027

10261028
fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
@@ -1045,6 +1047,7 @@ fn prepare_files_callback_failing<'a>(
10451047
move |rust_path| {
10461048
let files = std::fs::read_to_string(file_path).unwrap_or_default();
10471049
let first_file_name = files.lines().next().unwrap_or("");
1050+
// If the first line ends with a `/`, we treat it as a directory.
10481051
if first_file_name.ends_with('/') {
10491052
// Treat as directory
10501053
// Removing all tests.
@@ -1064,20 +1067,6 @@ fn prepare_files_callback_failing<'a>(
10641067
],
10651068
Some(rust_path),
10661069
)?;
1067-
// Putting back only the failing ones.
1068-
1069-
if let Ok(files) = std::fs::read_to_string(&file_path) {
1070-
for file in
1071-
files.split('\n').map(|line| line.trim()).filter(|line| !line.is_empty())
1072-
{
1073-
run_command(&[&"git", &"checkout", &"--", &file], Some(&rust_path))?;
1074-
}
1075-
} else {
1076-
println!(
1077-
"Failed to read `{}`, not putting back failing {} tests",
1078-
file_path, test_type
1079-
);
1080-
}
10811070
} else {
10821071
// Treat as file
10831072
// Removing all tests.
@@ -1096,20 +1085,20 @@ fn prepare_files_callback_failing<'a>(
10961085
],
10971086
Some(rust_path),
10981087
)?;
1099-
// Putting back only the failing ones.
1100-
if let Ok(files) = std::fs::read_to_string(&file_path) {
1101-
for file in
1102-
files.split('\n').map(|line| line.trim()).filter(|line| !line.is_empty())
1103-
{
1104-
run_command(&[&"git", &"checkout", &"--", &file], Some(&rust_path))?;
1105-
}
1106-
} else {
1107-
println!(
1108-
"Failed to read `{}`, not putting back failing `{}` tests",
1109-
file_path, test_type
1110-
);
1088+
}
1089+
1090+
// Putting back only the failing ones.
1091+
if let Ok(files) = std::fs::read_to_string(&file_path) {
1092+
for file in files.split('\n').map(|line| line.trim()).filter(|line| !line.is_empty()) {
1093+
run_command(&[&"git", &"checkout", &"--", &file], Some(&rust_path))?;
11111094
}
1095+
} else {
1096+
println!(
1097+
"Failed to read `{}`, not putting back failing {} tests",
1098+
file_path, test_type
1099+
);
11121100
}
1101+
11131102
Ok(true)
11141103
}
11151104
}
@@ -1121,6 +1110,7 @@ fn prepare_files_callback_success<'a>(
11211110
move |rust_path| {
11221111
let files = std::fs::read_to_string(file_path).unwrap_or_default();
11231112
let first_file_name = files.lines().next().unwrap_or("");
1113+
// If the first line ends with a `/`, we treat it as a directory.
11241114
if first_file_name.ends_with('/') {
11251115
if let Ok(files) = std::fs::read_to_string(file_path) {
11261116
for file in

tests/failing-ui-tests.txt

+3
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@ tests/ui/consts/try-operator.rs
7070
tests/ui/coroutine/unwind-abort-mix.rs
7171
tests/ui/type-alias-impl-trait/rpit_tait_equality_in_canonical_query.rs
7272
tests/ui/impl-trait/equality-in-canonical-query.rs
73+
tests/ui/consts/issue-miri-1910.rs
74+
tests/ui/mir/mir_heavy_promoted.rs
75+

0 commit comments

Comments
 (0)