Skip to content

Commit f83c77e

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

File tree

2 files changed

+108
-51
lines changed

2 files changed

+108
-51
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: 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: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ 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("--test-failing-ui-pattern-tests", ("Run failing ui pattern tests", test_failing_ui_pattern_tests));
2627
runners.insert("--test-failing-rustc", ("Run failing rustc tests", test_failing_rustc));
2728
runners.insert("--projects", ("Run the tests of popular crates", test_projects));
2829
runners.insert("--test-libcore", ("Run libcore tests", test_libcore));
@@ -860,6 +861,7 @@ fn test_rustc_inner<F>(
860861
env: &Env,
861862
args: &TestArg,
862863
prepare_files_callback: F,
864+
should_run_test_callback: Option<Box<dyn Fn(&Path) -> bool>>,
863865
test_type: &str,
864866
) -> Result<(), String>
865867
where
@@ -876,6 +878,39 @@ where
876878
}
877879

878880
if test_type == "ui" {
881+
if let Some(callback) = should_run_test_callback {
882+
fn walk_dir<F, G>(dir_path: PathBuf, dir_callback: F, file_callback: G) -> Result<(), String>
883+
where
884+
F: Fn(&Path) -> Result<(), String> + Copy,
885+
G: Fn(&Path) -> Result<(), String> + Copy,
886+
{
887+
if dir_path.is_dir() {
888+
for entry in std::fs::read_dir(dir_path).unwrap() {
889+
let entry = entry;
890+
let path = entry.unwrap().path();
891+
if path.is_dir() {
892+
dir_callback(&path)?;
893+
walk_dir(path, dir_callback, file_callback)?; // Recursive call
894+
} else if path.is_file() {
895+
file_callback(&path)?;
896+
}
897+
}
898+
}
899+
Ok(())
900+
}
901+
walk_dir(
902+
rust_path.join("tests/ui"),
903+
|_dir| Ok(()),
904+
|file_path| {
905+
if callback(file_path) {
906+
println!("file is {:?}",&file_path);
907+
Ok(())
908+
} else {
909+
remove_file(file_path).map_err(|e| e.to_string())
910+
}
911+
},
912+
)?;
913+
} else {
879914
walk_dir(
880915
rust_path.join("tests/ui"),
881916
|dir| {
@@ -923,7 +958,7 @@ where
923958
}
924959

925960
walk_dir(rust_path.join("tests/ui"), dir_handling, file_handling)?;
926-
961+
}
927962
let nb_parts = args.nb_parts.unwrap_or(0);
928963
if nb_parts > 0 {
929964
let current_part = args.current_part.unwrap();
@@ -966,6 +1001,7 @@ where
9661001
remove_file(&rust_path.join(path))?;
9671002
}
9681003
}
1004+
9691005
}
9701006

9711007
// FIXME: create a function "display_if_not_quiet" or something along the line.
@@ -1004,22 +1040,24 @@ where
10041040
}
10051041

10061042
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")
1043+
test_rustc_inner(env, args, |_| Ok(false), None, "run-make")?;
1044+
test_rustc_inner(env, args, |_| Ok(false), None, "ui")
10091045
}
10101046

10111047
fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
10121048
let result1 = test_rustc_inner(
10131049
env,
10141050
args,
10151051
prepare_files_callback_failing("tests/failing-run-make-tests.txt", "run-make"),
1052+
None,
10161053
"run-make",
10171054
);
10181055

10191056
let result2 = test_rustc_inner(
10201057
env,
10211058
args,
10221059
prepare_files_callback_failing("tests/failing-ui-tests.txt", "ui"),
1060+
None,
10231061
"ui",
10241062
);
10251063

@@ -1031,16 +1069,29 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
10311069
env,
10321070
args,
10331071
prepare_files_callback_success("tests/failing-ui-tests.txt", "ui"),
1072+
None,
10341073
"ui",
10351074
)?;
10361075
test_rustc_inner(
10371076
env,
10381077
args,
10391078
prepare_files_callback_success("tests/failing-run-make-tests.txt", "run-make"),
1079+
None,
10401080
"run-make",
10411081
)
10421082
}
10431083

1084+
fn test_failing_ui_pattern_tests(env: &Env, args: &TestArg) -> Result<(), String> {
1085+
test_rustc_inner(
1086+
env,
1087+
args,
1088+
|_| Ok(false),
1089+
Some(Box::new(|path| should_remove_test(path).unwrap_or(false))),
1090+
"ui",
1091+
)
1092+
}
1093+
1094+
10441095
fn prepare_files_callback_failing<'a>(
10451096
file_path: &'a str,
10461097
test_type: &'a str,

0 commit comments

Comments
 (0)