Skip to content

Commit 0c497cc

Browse files
committed
ui pattern failure tests
1 parent d7c8e0f commit 0c497cc

File tree

2 files changed

+154
-92
lines changed

2 files changed

+154
-92
lines changed

Diff for: .github/workflows/failures.yml

+54-48
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 "[email protected]"
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 "[email protected]"
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

Diff for: build_system/src/test.rs

+100-44
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,91 @@ 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+
println!("file is {:?}", &file_path);
914+
Ok(())
915+
} else {
916+
remove_file(file_path).map_err(|e| e.to_string())
917+
}
918+
},
919+
)?;
920+
} else {
921+
walk_dir(
922+
rust_path.join("tests/ui"),
923+
|dir| {
924+
let dir_name = dir.file_name().and_then(|name| name.to_str()).unwrap_or("");
925+
if [
926+
"abi",
927+
"extern",
928+
"unsized-locals",
929+
"proc-macro",
930+
"threads-sendsync",
931+
"borrowck",
932+
"test-attrs",
933+
]
934+
.iter()
935+
.any(|name| *name == dir_name)
936+
{
937+
std::fs::remove_dir_all(dir).map_err(|error| {
938+
format!("Failed to remove folder `{}`: {:?}", dir.display(), error)
939+
})?;
940+
}
941+
Ok(())
942+
},
943+
|_| Ok(()),
944+
)?;
945+
946+
// These two functions are used to remove files that are known to not be working currently
947+
// with the GCC backend to reduce noise.
948+
fn dir_handling(dir: &Path) -> Result<(), String> {
949+
if dir.file_name().map(|name| name == "auxiliary").unwrap_or(true) {
950+
return Ok(());
951+
}
952+
walk_dir(dir, dir_handling, file_handling)
915953
}
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);
954+
fn file_handling(file_path: &Path) -> Result<(), String> {
955+
if !file_path.extension().map(|extension| extension == "rs").unwrap_or(false) {
956+
return Ok(());
957+
}
958+
let path_str = file_path.display().to_string().replace("\\", "/");
959+
if should_not_remove_test(&path_str) {
960+
return Ok(());
961+
} else if should_remove_test(file_path)? {
962+
return remove_file(&file_path);
963+
}
964+
Ok(())
921965
}
922-
Ok(())
923-
}
924-
925-
walk_dir(rust_path.join("tests/ui"), dir_handling, file_handling)?;
926966

967+
walk_dir(rust_path.join("tests/ui"), dir_handling, file_handling)?;
968+
}
927969
let nb_parts = args.nb_parts.unwrap_or(0);
928970
if nb_parts > 0 {
929971
let current_part = args.current_part.unwrap();
@@ -1004,22 +1046,24 @@ where
10041046
}
10051047

10061048
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")
1049+
test_rustc_inner(env, args, |_| Ok(false), None, "run-make")?;
1050+
test_rustc_inner(env, args, |_| Ok(false), None, "ui")
10091051
}
10101052

10111053
fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
10121054
let result1 = test_rustc_inner(
10131055
env,
10141056
args,
10151057
prepare_files_callback_failing("tests/failing-run-make-tests.txt", "run-make"),
1058+
None,
10161059
"run-make",
10171060
);
10181061

10191062
let result2 = test_rustc_inner(
10201063
env,
10211064
args,
10221065
prepare_files_callback_failing("tests/failing-ui-tests.txt", "ui"),
1066+
None,
10231067
"ui",
10241068
);
10251069

@@ -1031,16 +1075,28 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
10311075
env,
10321076
args,
10331077
prepare_files_callback_success("tests/failing-ui-tests.txt", "ui"),
1078+
None,
10341079
"ui",
10351080
)?;
10361081
test_rustc_inner(
10371082
env,
10381083
args,
10391084
prepare_files_callback_success("tests/failing-run-make-tests.txt", "run-make"),
1085+
None,
10401086
"run-make",
10411087
)
10421088
}
10431089

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

0 commit comments

Comments
 (0)