Skip to content

Commit 3973329

Browse files
committed
ui pattern failure tests
1 parent d7c8e0f commit 3973329

File tree

2 files changed

+153
-92
lines changed

2 files changed

+153
-92
lines changed

.github/workflows/failures.yml

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -31,70 +31,76 @@ jobs:
3131
env_extra: "TEST_FLAGS='-Cpanic=abort -Zpanic-abort-tests' GCC_EXEC_PREFIX=/usr/lib/gcc/"
3232

3333
steps:
34-
- uses: actions/checkout@v3
34+
- uses: actions/checkout@v3
3535

36-
# `rustup show` installs from rust-toolchain.toml
37-
- name: Setup rust toolchain
38-
run: rustup show
36+
# `rustup show` installs from rust-toolchain.toml
37+
- name: Setup rust toolchain
38+
run: rustup show
3939

40-
- name: Setup rust cache
41-
uses: Swatinem/rust-cache@v2
40+
- name: Setup rust cache
41+
uses: Swatinem/rust-cache@v2
4242

43-
- name: Install packages
44-
run: sudo apt-get install ninja-build ripgrep
43+
- name: Install packages
44+
run: sudo apt-get install ninja-build ripgrep
4545

46-
- name: Install libgccjit12
47-
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'
48-
run: sudo apt-get install libgccjit-12-dev
46+
- name: Install libgccjit12
47+
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'
48+
run: sudo apt-get install libgccjit-12-dev
4949

50-
- name: Setup path to libgccjit
51-
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'
52-
run: |
50+
- name: Setup path to libgccjit
51+
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'
52+
run: |
5353
echo 'gcc-path = "/usr/lib/gcc/x86_64-linux-gnu/12"' > config.toml
5454
echo "LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12" >> $GITHUB_ENV
5555
echo "LD_LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12" >> $GITHUB_ENV
5656
57-
- name: Download artifact
58-
if: matrix.libgccjit_version.gcc != 'libgccjit12.so'
59-
run: curl -LO https://github.com/rust-lang/gcc/releases/latest/download/gcc-13.deb
57+
- name: Download artifact
58+
if: matrix.libgccjit_version.gcc != 'libgccjit12.so'
59+
run: curl -LO https://github.com/rust-lang/gcc/releases/latest/download/gcc-13.deb
6060

61-
- name: Setup path to libgccjit
62-
if: matrix.libgccjit_version.gcc != 'libgccjit12.so'
63-
run: |
61+
- name: Setup path to libgccjit
62+
if: matrix.libgccjit_version.gcc != 'libgccjit12.so'
63+
run: |
6464
sudo dpkg --force-overwrite -i gcc-13.deb
6565
echo 'gcc-path = "/usr/lib"' > config.toml
6666
echo "LIBRARY_PATH=/usr/lib" >> $GITHUB_ENV
6767
echo "LD_LIBRARY_PATH=/usr/lib" >> $GITHUB_ENV
6868
69-
- name: Set env
70-
run: |
71-
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
69+
- name: Set env
70+
run: |
71+
echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV
7272
73-
#- name: Cache rust repository
73+
#- name: Cache rust repository
7474
#uses: actions/cache@v3
7575
#id: cache-rust-repository
7676
#with:
77-
#path: rust
78-
#key: ${{ runner.os }}-packages-${{ hashFiles('rust/.git/HEAD') }}
79-
80-
- name: Git config
81-
run: |
82-
git config --global user.email "user@example.com"
83-
git config --global user.name "User"
84-
85-
- name: Prepare dependencies
86-
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'
87-
run: ./y.sh prepare --libgccjit12-patches
88-
89-
- name: Prepare dependencies
90-
if: matrix.libgccjit_version.gcc != 'libgccjit12.so'
91-
run: ./y.sh prepare
92-
93-
- name: Add more failing tests because the sysroot is not compiled with LTO
94-
run: cat tests/failing-non-lto-tests.txt >> tests/failing-ui-tests.txt
95-
96-
- name: Run tests
97-
id: tests
98-
run: |
99-
${{ matrix.libgccjit_version.env_extra }} ./y.sh test --release --clean --build-sysroot --test-failing-rustc ${{ matrix.libgccjit_version.extra }} | tee output_log
100-
rg --text "test result" output_log >> $GITHUB_STEP_SUMMARY
77+
#path: rust
78+
#key: ${{ runner.os }}-packages-${{ hashFiles('rust/.git/HEAD') }}
79+
80+
- name: Git config
81+
run: |
82+
git config --global user.email "user@example.com"
83+
git config --global user.name "User"
84+
85+
- name: Prepare dependencies
86+
if: matrix.libgccjit_version.gcc == 'libgccjit12.so'
87+
run: ./y.sh prepare --libgccjit12-patches
88+
89+
- name: Prepare dependencies
90+
if: matrix.libgccjit_version.gcc != 'libgccjit12.so'
91+
run: ./y.sh prepare
92+
93+
- name: Add more failing tests because the sysroot is not compiled with LTO
94+
run: cat tests/failing-non-lto-tests.txt >> tests/failing-ui-tests.txt
95+
96+
- name: Run tests
97+
id: tests
98+
run: |
99+
${{ matrix.libgccjit_version.env_extra }} ./y.sh test --release --clean --build-sysroot --test-failing-rustc ${{ matrix.libgccjit_version.extra }} | tee output_log
100+
rg --text "test result" output_log >> $GITHUB_STEP_SUMMARY
101+
102+
- name: Run failing ui pattern tests
103+
id: ui-tests
104+
run: |
105+
${{ matrix.libgccjit_version.env_extra }} ./y.sh test --release --clean --build-sysroot --test-failing-ui-pattern-tests ${{ matrix.libgccjit_version.extra }} | tee output_log
106+
rg --text "test result" output_log >> $GITHUB_STEP_SUMMARY

build_system/src/test.rs

Lines changed: 99 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ fn get_runners() -> Runners {
2323
runners.insert("--test-rustc", ("Run all rustc tests", test_rustc as Runner));
2424
runners
2525
.insert("--test-successful-rustc", ("Run successful rustc tests", test_successful_rustc));
26+
runners.insert(
27+
"--test-failing-ui-pattern-tests",
28+
("Run failing ui pattern tests", test_failing_ui_pattern_tests),
29+
);
2630
runners.insert("--test-failing-rustc", ("Run failing rustc tests", test_failing_rustc));
2731
runners.insert("--projects", ("Run the tests of popular crates", test_projects));
2832
runners.insert("--test-libcore", ("Run libcore tests", test_libcore));
@@ -860,6 +864,7 @@ fn test_rustc_inner<F>(
860864
env: &Env,
861865
args: &TestArg,
862866
prepare_files_callback: F,
867+
should_run_test_callback: Option<Box<dyn Fn(&Path) -> bool>>,
863868
test_type: &str,
864869
) -> Result<(), String>
865870
where
@@ -876,54 +881,90 @@ where
876881
}
877882

878883
if test_type == "ui" {
879-
walk_dir(
880-
rust_path.join("tests/ui"),
881-
|dir| {
882-
let dir_name = dir.file_name().and_then(|name| name.to_str()).unwrap_or("");
883-
if [
884-
"abi",
885-
"extern",
886-
"unsized-locals",
887-
"proc-macro",
888-
"threads-sendsync",
889-
"borrowck",
890-
"test-attrs",
891-
]
892-
.iter()
893-
.any(|name| *name == dir_name)
894-
{
895-
std::fs::remove_dir_all(dir).map_err(|error| {
896-
format!("Failed to remove folder `{}`: {:?}", dir.display(), error)
897-
})?;
884+
if let Some(callback) = should_run_test_callback {
885+
fn walk_dir<F, G>(
886+
dir_path: PathBuf,
887+
dir_callback: F,
888+
file_callback: G,
889+
) -> Result<(), String>
890+
where
891+
F: Fn(&Path) -> Result<(), String> + Copy,
892+
G: Fn(&Path) -> Result<(), String> + Copy,
893+
{
894+
if dir_path.is_dir() {
895+
for entry in std::fs::read_dir(dir_path).unwrap() {
896+
let entry = entry;
897+
let path = entry.unwrap().path();
898+
if path.is_dir() {
899+
dir_callback(&path)?;
900+
walk_dir(path, dir_callback, file_callback)?; // Recursive call
901+
} else if path.is_file() {
902+
file_callback(&path)?;
903+
}
904+
}
898905
}
899906
Ok(())
900-
},
901-
|_| Ok(()),
902-
)?;
903-
904-
// These two functions are used to remove files that are known to not be working currently
905-
// with the GCC backend to reduce noise.
906-
fn dir_handling(dir: &Path) -> Result<(), String> {
907-
if dir.file_name().map(|name| name == "auxiliary").unwrap_or(true) {
908-
return Ok(());
909907
}
910-
walk_dir(dir, dir_handling, file_handling)
911-
}
912-
fn file_handling(file_path: &Path) -> Result<(), String> {
913-
if !file_path.extension().map(|extension| extension == "rs").unwrap_or(false) {
914-
return Ok(());
908+
walk_dir(
909+
rust_path.join("tests/ui"),
910+
|_dir| Ok(()),
911+
|file_path| {
912+
if callback(file_path) {
913+
Ok(())
914+
} else {
915+
remove_file(file_path).map_err(|e| e.to_string())
916+
}
917+
},
918+
)?;
919+
} else {
920+
walk_dir(
921+
rust_path.join("tests/ui"),
922+
|dir| {
923+
let dir_name = dir.file_name().and_then(|name| name.to_str()).unwrap_or("");
924+
if [
925+
"abi",
926+
"extern",
927+
"unsized-locals",
928+
"proc-macro",
929+
"threads-sendsync",
930+
"borrowck",
931+
"test-attrs",
932+
]
933+
.iter()
934+
.any(|name| *name == dir_name)
935+
{
936+
std::fs::remove_dir_all(dir).map_err(|error| {
937+
format!("Failed to remove folder `{}`: {:?}", dir.display(), error)
938+
})?;
939+
}
940+
Ok(())
941+
},
942+
|_| Ok(()),
943+
)?;
944+
945+
// These two functions are used to remove files that are known to not be working currently
946+
// with the GCC backend to reduce noise.
947+
fn dir_handling(dir: &Path) -> Result<(), String> {
948+
if dir.file_name().map(|name| name == "auxiliary").unwrap_or(true) {
949+
return Ok(());
950+
}
951+
walk_dir(dir, dir_handling, file_handling)
915952
}
916-
let path_str = file_path.display().to_string().replace("\\", "/");
917-
if should_not_remove_test(&path_str) {
918-
return Ok(());
919-
} else if should_remove_test(file_path)? {
920-
return remove_file(&file_path);
953+
fn file_handling(file_path: &Path) -> Result<(), String> {
954+
if !file_path.extension().map(|extension| extension == "rs").unwrap_or(false) {
955+
return Ok(());
956+
}
957+
let path_str = file_path.display().to_string().replace("\\", "/");
958+
if should_not_remove_test(&path_str) {
959+
return Ok(());
960+
} else if should_remove_test(file_path)? {
961+
return remove_file(&file_path);
962+
}
963+
Ok(())
921964
}
922-
Ok(())
923-
}
924-
925-
walk_dir(rust_path.join("tests/ui"), dir_handling, file_handling)?;
926965

966+
walk_dir(rust_path.join("tests/ui"), dir_handling, file_handling)?;
967+
}
927968
let nb_parts = args.nb_parts.unwrap_or(0);
928969
if nb_parts > 0 {
929970
let current_part = args.current_part.unwrap();
@@ -1004,22 +1045,24 @@ where
10041045
}
10051046

10061047
fn test_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
1007-
test_rustc_inner(env, args, |_| Ok(false), "run-make")?;
1008-
test_rustc_inner(env, args, |_| Ok(false), "ui")
1048+
test_rustc_inner(env, args, |_| Ok(false), None, "run-make")?;
1049+
test_rustc_inner(env, args, |_| Ok(false), None, "ui")
10091050
}
10101051

10111052
fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
10121053
let result1 = test_rustc_inner(
10131054
env,
10141055
args,
10151056
prepare_files_callback_failing("tests/failing-run-make-tests.txt", "run-make"),
1057+
None,
10161058
"run-make",
10171059
);
10181060

10191061
let result2 = test_rustc_inner(
10201062
env,
10211063
args,
10221064
prepare_files_callback_failing("tests/failing-ui-tests.txt", "ui"),
1065+
None,
10231066
"ui",
10241067
);
10251068

@@ -1031,16 +1074,28 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
10311074
env,
10321075
args,
10331076
prepare_files_callback_success("tests/failing-ui-tests.txt", "ui"),
1077+
None,
10341078
"ui",
10351079
)?;
10361080
test_rustc_inner(
10371081
env,
10381082
args,
10391083
prepare_files_callback_success("tests/failing-run-make-tests.txt", "run-make"),
1084+
None,
10401085
"run-make",
10411086
)
10421087
}
10431088

1089+
fn test_failing_ui_pattern_tests(env: &Env, args: &TestArg) -> Result<(), String> {
1090+
test_rustc_inner(
1091+
env,
1092+
args,
1093+
|_| Ok(false),
1094+
Some(Box::new(|path| should_remove_test(path).unwrap_or(false))),
1095+
"ui",
1096+
)
1097+
}
1098+
10441099
fn prepare_files_callback_failing<'a>(
10451100
file_path: &'a str,
10461101
test_type: &'a str,

0 commit comments

Comments
 (0)