From 3973329f32507063e0021026ac6ed47a7c18fdf2 Mon Sep 17 00:00:00 2001 From: lordforever Date: Mon, 27 May 2024 05:10:01 +0530 Subject: [PATCH 1/6] ui pattern failure tests --- .github/workflows/failures.yml | 102 ++++++++++++----------- build_system/src/test.rs | 143 +++++++++++++++++++++++---------- 2 files changed, 153 insertions(+), 92 deletions(-) diff --git a/.github/workflows/failures.yml b/.github/workflows/failures.yml index 9fa6f416c14..2287df5ccb3 100644 --- a/.github/workflows/failures.yml +++ b/.github/workflows/failures.yml @@ -31,70 +31,76 @@ jobs: env_extra: "TEST_FLAGS='-Cpanic=abort -Zpanic-abort-tests' GCC_EXEC_PREFIX=/usr/lib/gcc/" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - # `rustup show` installs from rust-toolchain.toml - - name: Setup rust toolchain - run: rustup show + # `rustup show` installs from rust-toolchain.toml + - name: Setup rust toolchain + run: rustup show - - name: Setup rust cache - uses: Swatinem/rust-cache@v2 + - name: Setup rust cache + uses: Swatinem/rust-cache@v2 - - name: Install packages - run: sudo apt-get install ninja-build ripgrep + - name: Install packages + run: sudo apt-get install ninja-build ripgrep - - name: Install libgccjit12 - if: matrix.libgccjit_version.gcc == 'libgccjit12.so' - run: sudo apt-get install libgccjit-12-dev + - name: Install libgccjit12 + if: matrix.libgccjit_version.gcc == 'libgccjit12.so' + run: sudo apt-get install libgccjit-12-dev - - name: Setup path to libgccjit - if: matrix.libgccjit_version.gcc == 'libgccjit12.so' - run: | + - name: Setup path to libgccjit + if: matrix.libgccjit_version.gcc == 'libgccjit12.so' + run: | echo 'gcc-path = "/usr/lib/gcc/x86_64-linux-gnu/12"' > config.toml echo "LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12" >> $GITHUB_ENV echo "LD_LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12" >> $GITHUB_ENV - - name: Download artifact - if: matrix.libgccjit_version.gcc != 'libgccjit12.so' - run: curl -LO https://github.com/rust-lang/gcc/releases/latest/download/gcc-13.deb + - name: Download artifact + if: matrix.libgccjit_version.gcc != 'libgccjit12.so' + run: curl -LO https://github.com/rust-lang/gcc/releases/latest/download/gcc-13.deb - - name: Setup path to libgccjit - if: matrix.libgccjit_version.gcc != 'libgccjit12.so' - run: | + - name: Setup path to libgccjit + if: matrix.libgccjit_version.gcc != 'libgccjit12.so' + run: | sudo dpkg --force-overwrite -i gcc-13.deb echo 'gcc-path = "/usr/lib"' > config.toml echo "LIBRARY_PATH=/usr/lib" >> $GITHUB_ENV echo "LD_LIBRARY_PATH=/usr/lib" >> $GITHUB_ENV - - name: Set env - run: | - echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV + - name: Set env + run: | + echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV - #- name: Cache rust repository + #- name: Cache rust repository #uses: actions/cache@v3 #id: cache-rust-repository #with: - #path: rust - #key: ${{ runner.os }}-packages-${{ hashFiles('rust/.git/HEAD') }} - - - name: Git config - run: | - git config --global user.email "user@example.com" - git config --global user.name "User" - - - name: Prepare dependencies - if: matrix.libgccjit_version.gcc == 'libgccjit12.so' - run: ./y.sh prepare --libgccjit12-patches - - - name: Prepare dependencies - if: matrix.libgccjit_version.gcc != 'libgccjit12.so' - run: ./y.sh prepare - - - name: Add more failing tests because the sysroot is not compiled with LTO - run: cat tests/failing-non-lto-tests.txt >> tests/failing-ui-tests.txt - - - name: Run tests - id: tests - run: | - ${{ matrix.libgccjit_version.env_extra }} ./y.sh test --release --clean --build-sysroot --test-failing-rustc ${{ matrix.libgccjit_version.extra }} | tee output_log - rg --text "test result" output_log >> $GITHUB_STEP_SUMMARY + #path: rust + #key: ${{ runner.os }}-packages-${{ hashFiles('rust/.git/HEAD') }} + + - name: Git config + run: | + git config --global user.email "user@example.com" + git config --global user.name "User" + + - name: Prepare dependencies + if: matrix.libgccjit_version.gcc == 'libgccjit12.so' + run: ./y.sh prepare --libgccjit12-patches + + - name: Prepare dependencies + if: matrix.libgccjit_version.gcc != 'libgccjit12.so' + run: ./y.sh prepare + + - name: Add more failing tests because the sysroot is not compiled with LTO + run: cat tests/failing-non-lto-tests.txt >> tests/failing-ui-tests.txt + + - name: Run tests + id: tests + run: | + ${{ matrix.libgccjit_version.env_extra }} ./y.sh test --release --clean --build-sysroot --test-failing-rustc ${{ matrix.libgccjit_version.extra }} | tee output_log + rg --text "test result" output_log >> $GITHUB_STEP_SUMMARY + + - name: Run failing ui pattern tests + id: ui-tests + run: | + ${{ matrix.libgccjit_version.env_extra }} ./y.sh test --release --clean --build-sysroot --test-failing-ui-pattern-tests ${{ matrix.libgccjit_version.extra }} | tee output_log + rg --text "test result" output_log >> $GITHUB_STEP_SUMMARY diff --git a/build_system/src/test.rs b/build_system/src/test.rs index f1b7b8d19b6..8484ab4544f 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -23,6 +23,10 @@ fn get_runners() -> Runners { runners.insert("--test-rustc", ("Run all rustc tests", test_rustc as Runner)); runners .insert("--test-successful-rustc", ("Run successful rustc tests", test_successful_rustc)); + runners.insert( + "--test-failing-ui-pattern-tests", + ("Run failing ui pattern tests", test_failing_ui_pattern_tests), + ); runners.insert("--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)); @@ -860,6 +864,7 @@ fn test_rustc_inner( env: &Env, args: &TestArg, prepare_files_callback: F, + should_run_test_callback: Option bool>>, test_type: &str, ) -> Result<(), String> where @@ -876,54 +881,90 @@ where } if test_type == "ui" { - walk_dir( - rust_path.join("tests/ui"), - |dir| { - let dir_name = dir.file_name().and_then(|name| name.to_str()).unwrap_or(""); - if [ - "abi", - "extern", - "unsized-locals", - "proc-macro", - "threads-sendsync", - "borrowck", - "test-attrs", - ] - .iter() - .any(|name| *name == dir_name) - { - std::fs::remove_dir_all(dir).map_err(|error| { - format!("Failed to remove folder `{}`: {:?}", dir.display(), error) - })?; + if let Some(callback) = should_run_test_callback { + fn walk_dir( + dir_path: PathBuf, + dir_callback: F, + file_callback: G, + ) -> Result<(), String> + where + F: Fn(&Path) -> Result<(), String> + Copy, + G: Fn(&Path) -> Result<(), String> + Copy, + { + if dir_path.is_dir() { + for entry in std::fs::read_dir(dir_path).unwrap() { + let entry = entry; + let path = entry.unwrap().path(); + if path.is_dir() { + dir_callback(&path)?; + walk_dir(path, dir_callback, file_callback)?; // Recursive call + } else if path.is_file() { + file_callback(&path)?; + } + } } Ok(()) - }, - |_| Ok(()), - )?; - - // These two functions are used to remove files that are known to not be working currently - // with the GCC backend to reduce noise. - fn dir_handling(dir: &Path) -> Result<(), String> { - if dir.file_name().map(|name| name == "auxiliary").unwrap_or(true) { - return Ok(()); } - walk_dir(dir, dir_handling, file_handling) - } - fn file_handling(file_path: &Path) -> Result<(), String> { - if !file_path.extension().map(|extension| extension == "rs").unwrap_or(false) { - return Ok(()); + walk_dir( + rust_path.join("tests/ui"), + |_dir| Ok(()), + |file_path| { + if callback(file_path) { + Ok(()) + } else { + remove_file(file_path).map_err(|e| e.to_string()) + } + }, + )?; + } else { + walk_dir( + rust_path.join("tests/ui"), + |dir| { + let dir_name = dir.file_name().and_then(|name| name.to_str()).unwrap_or(""); + if [ + "abi", + "extern", + "unsized-locals", + "proc-macro", + "threads-sendsync", + "borrowck", + "test-attrs", + ] + .iter() + .any(|name| *name == dir_name) + { + std::fs::remove_dir_all(dir).map_err(|error| { + format!("Failed to remove folder `{}`: {:?}", dir.display(), error) + })?; + } + Ok(()) + }, + |_| Ok(()), + )?; + + // These two functions are used to remove files that are known to not be working currently + // with the GCC backend to reduce noise. + fn dir_handling(dir: &Path) -> Result<(), String> { + if dir.file_name().map(|name| name == "auxiliary").unwrap_or(true) { + return Ok(()); + } + walk_dir(dir, dir_handling, file_handling) } - let path_str = file_path.display().to_string().replace("\\", "/"); - if should_not_remove_test(&path_str) { - return Ok(()); - } else if should_remove_test(file_path)? { - return remove_file(&file_path); + fn file_handling(file_path: &Path) -> Result<(), String> { + if !file_path.extension().map(|extension| extension == "rs").unwrap_or(false) { + return Ok(()); + } + let path_str = file_path.display().to_string().replace("\\", "/"); + if should_not_remove_test(&path_str) { + return Ok(()); + } else if should_remove_test(file_path)? { + return remove_file(&file_path); + } + Ok(()) } - Ok(()) - } - - walk_dir(rust_path.join("tests/ui"), dir_handling, file_handling)?; + walk_dir(rust_path.join("tests/ui"), dir_handling, file_handling)?; + } let nb_parts = args.nb_parts.unwrap_or(0); if nb_parts > 0 { let current_part = args.current_part.unwrap(); @@ -1004,8 +1045,8 @@ where } fn test_rustc(env: &Env, args: &TestArg) -> Result<(), String> { - test_rustc_inner(env, args, |_| Ok(false), "run-make")?; - test_rustc_inner(env, args, |_| Ok(false), "ui") + test_rustc_inner(env, args, |_| Ok(false), None, "run-make")?; + test_rustc_inner(env, args, |_| Ok(false), None, "ui") } fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { @@ -1013,6 +1054,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { env, args, prepare_files_callback_failing("tests/failing-run-make-tests.txt", "run-make"), + None, "run-make", ); @@ -1020,6 +1062,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { env, args, prepare_files_callback_failing("tests/failing-ui-tests.txt", "ui"), + None, "ui", ); @@ -1031,16 +1074,28 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> { env, args, prepare_files_callback_success("tests/failing-ui-tests.txt", "ui"), + None, "ui", )?; test_rustc_inner( env, args, prepare_files_callback_success("tests/failing-run-make-tests.txt", "run-make"), + None, "run-make", ) } +fn test_failing_ui_pattern_tests(env: &Env, args: &TestArg) -> Result<(), String> { + test_rustc_inner( + env, + args, + |_| Ok(false), + Some(Box::new(|path| should_remove_test(path).unwrap_or(false))), + "ui", + ) +} + fn prepare_files_callback_failing<'a>( file_path: &'a str, test_type: &'a str, From 94d6b2338576e0108848c8708d128ab319dd5ef2 Mon Sep 17 00:00:00 2001 From: lordforever Date: Mon, 3 Jun 2024 01:03:19 +0530 Subject: [PATCH 2/6] ICE UI tests handled --- .github/workflows/failures.yml | 112 +++++++++++++++++---------------- build_system/src/test.rs | 14 ++--- tests/failing-ice-tests.txt | 32 ++++++++++ 3 files changed, 97 insertions(+), 61 deletions(-) create mode 100644 tests/failing-ice-tests.txt diff --git a/.github/workflows/failures.yml b/.github/workflows/failures.yml index 2287df5ccb3..b06b56aa192 100644 --- a/.github/workflows/failures.yml +++ b/.github/workflows/failures.yml @@ -31,76 +31,80 @@ jobs: env_extra: "TEST_FLAGS='-Cpanic=abort -Zpanic-abort-tests' GCC_EXEC_PREFIX=/usr/lib/gcc/" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3 - # `rustup show` installs from rust-toolchain.toml - - name: Setup rust toolchain - run: rustup show + # `rustup show` installs from rust-toolchain.toml + - name: Setup rust toolchain + run: rustup show - - name: Setup rust cache - uses: Swatinem/rust-cache@v2 + - name: Setup rust cache + uses: Swatinem/rust-cache@v2 - - name: Install packages - run: sudo apt-get install ninja-build ripgrep + - name: Install packages + run: sudo apt-get install ninja-build ripgrep - - name: Install libgccjit12 - if: matrix.libgccjit_version.gcc == 'libgccjit12.so' - run: sudo apt-get install libgccjit-12-dev + - name: Install libgccjit12 + if: matrix.libgccjit_version.gcc == 'libgccjit12.so' + run: sudo apt-get install libgccjit-12-dev - - name: Setup path to libgccjit - if: matrix.libgccjit_version.gcc == 'libgccjit12.so' - run: | + - name: Setup path to libgccjit + if: matrix.libgccjit_version.gcc == 'libgccjit12.so' + run: | echo 'gcc-path = "/usr/lib/gcc/x86_64-linux-gnu/12"' > config.toml echo "LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12" >> $GITHUB_ENV echo "LD_LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12" >> $GITHUB_ENV - - name: Download artifact - if: matrix.libgccjit_version.gcc != 'libgccjit12.so' - run: curl -LO https://github.com/rust-lang/gcc/releases/latest/download/gcc-13.deb + - name: Download artifact + if: matrix.libgccjit_version.gcc != 'libgccjit12.so' + run: curl -LO https://github.com/rust-lang/gcc/releases/latest/download/gcc-13.deb - - name: Setup path to libgccjit - if: matrix.libgccjit_version.gcc != 'libgccjit12.so' - run: | + - name: Setup path to libgccjit + if: matrix.libgccjit_version.gcc != 'libgccjit12.so' + run: | sudo dpkg --force-overwrite -i gcc-13.deb echo 'gcc-path = "/usr/lib"' > config.toml echo "LIBRARY_PATH=/usr/lib" >> $GITHUB_ENV echo "LD_LIBRARY_PATH=/usr/lib" >> $GITHUB_ENV - - name: Set env - run: | - echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV + - name: Set env + run: | + echo "workspace="$GITHUB_WORKSPACE >> $GITHUB_ENV - #- name: Cache rust repository + #- name: Cache rust repository #uses: actions/cache@v3 #id: cache-rust-repository #with: - #path: rust - #key: ${{ runner.os }}-packages-${{ hashFiles('rust/.git/HEAD') }} - - - name: Git config - run: | - git config --global user.email "user@example.com" - git config --global user.name "User" - - - name: Prepare dependencies - if: matrix.libgccjit_version.gcc == 'libgccjit12.so' - run: ./y.sh prepare --libgccjit12-patches - - - name: Prepare dependencies - if: matrix.libgccjit_version.gcc != 'libgccjit12.so' - run: ./y.sh prepare - - - name: Add more failing tests because the sysroot is not compiled with LTO - run: cat tests/failing-non-lto-tests.txt >> tests/failing-ui-tests.txt - - - name: Run tests - id: tests - run: | - ${{ matrix.libgccjit_version.env_extra }} ./y.sh test --release --clean --build-sysroot --test-failing-rustc ${{ matrix.libgccjit_version.extra }} | tee output_log - rg --text "test result" output_log >> $GITHUB_STEP_SUMMARY - - - name: Run failing ui pattern tests - id: ui-tests - run: | - ${{ matrix.libgccjit_version.env_extra }} ./y.sh test --release --clean --build-sysroot --test-failing-ui-pattern-tests ${{ matrix.libgccjit_version.extra }} | tee output_log - rg --text "test result" output_log >> $GITHUB_STEP_SUMMARY + #path: rust + #key: ${{ runner.os }}-packages-${{ hashFiles('rust/.git/HEAD') }} + + - name: Git config + run: | + git config --global user.email "user@example.com" + git config --global user.name "User" + + - name: Prepare dependencies + if: matrix.libgccjit_version.gcc == 'libgccjit12.so' + run: ./y.sh prepare --libgccjit12-patches + + - name: Prepare dependencies + if: matrix.libgccjit_version.gcc != 'libgccjit12.so' + run: ./y.sh prepare + + - name: Add more failing tests because the sysroot is not compiled with LTO + run: cat tests/failing-non-lto-tests.txt >> tests/failing-ui-tests.txt + + - name: Run tests + id: tests + run: | + ${{ matrix.libgccjit_version.env_extra }} ./y.sh test --release --clean --build-sysroot --test-failing-rustc ${{ matrix.libgccjit_version.extra }} | tee output_log + rg --text "test result" output_log >> $GITHUB_STEP_SUMMARY + + - name: Run failing ui pattern tests for ICE + id: ui-tests + run: | + ${{ matrix.libgccjit_version.env_extra }} ./y.sh test --release --clean --build-sysroot --test-failing-ui-pattern-tests ${{ matrix.libgccjit_version.extra }} | tee output_log_ui + if grep -q "the compiler unexpectedly panicked" output_log_ui; then + echo "Error: 'the compiler unexpectedly panicked' found in output logs. CI Error!!" + exit 1 + fi + rg --text "test result" output_log_ui >> $GITHUB_STEP_SUMMARY diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 8484ab4544f..5ee2086e172 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -1053,7 +1053,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { let result1 = test_rustc_inner( env, args, - prepare_files_callback_failing("tests/failing-run-make-tests.txt", "run-make"), + prepare_files_callback_retain("tests/failing-run-make-tests.txt", "run-make"), None, "run-make", ); @@ -1061,7 +1061,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { let result2 = test_rustc_inner( env, args, - prepare_files_callback_failing("tests/failing-ui-tests.txt", "ui"), + prepare_files_callback_retain("tests/failing-ui-tests.txt", "ui"), None, "ui", ); @@ -1073,14 +1073,14 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> { test_rustc_inner( env, args, - prepare_files_callback_success("tests/failing-ui-tests.txt", "ui"), + prepare_files_callback_remove("tests/failing-ui-tests.txt", "ui"), None, "ui", )?; test_rustc_inner( env, args, - prepare_files_callback_success("tests/failing-run-make-tests.txt", "run-make"), + prepare_files_callback_remove("tests/failing-run-make-tests.txt", "run-make"), None, "run-make", ) @@ -1090,13 +1090,13 @@ fn test_failing_ui_pattern_tests(env: &Env, args: &TestArg) -> Result<(), String test_rustc_inner( env, args, - |_| Ok(false), + prepare_files_callback_remove("tests/failing-ice-tests.txt", "ui"), Some(Box::new(|path| should_remove_test(path).unwrap_or(false))), "ui", ) } -fn prepare_files_callback_failing<'a>( +fn prepare_files_callback_retain<'a>( file_path: &'a str, test_type: &'a str, ) -> impl Fn(&Path) -> Result + 'a { @@ -1159,7 +1159,7 @@ fn prepare_files_callback_failing<'a>( } } -fn prepare_files_callback_success<'a>( +fn prepare_files_callback_remove<'a>( file_path: &'a str, test_type: &'a str, ) -> impl Fn(&Path) -> Result + 'a { diff --git a/tests/failing-ice-tests.txt b/tests/failing-ice-tests.txt new file mode 100644 index 00000000000..485b298bfa3 --- /dev/null +++ b/tests/failing-ice-tests.txt @@ -0,0 +1,32 @@ +tests/ui/treat-err-as-bug/span_delayed_bug.rs +tests/ui/treat-err-as-bug/err.rs +tests/ui/simd/not-out-of-bounds.rs +tests/ui/simd/monomorphize-shuffle-index.rs +tests/ui/simd/masked-load-store-build-fail.rs +tests/ui/simd/intrinsic/generic-shuffle.rs +tests/ui/simd/intrinsic/generic-elements.rs +tests/ui/simd/intrinsic/generic-cast.rs +tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs +tests/ui/simd/intrinsic/generic-arithmetic-2.rs +tests/ui/panics/default-backtrace-ice.rs +tests/ui/mir/lint/storage-live.rs +tests/ui/layout/valid_range_oob.rs +tests/ui/higher-ranked/trait-bounds/future.rs +tests/ui/consts/const-eval/const-eval-query-stack.rs +tests/ui/simd/masked-load-store.rs +tests/ui/simd/issue-39720.rs +tests/ui/simd/intrinsic/ptr-cast.rs +tests/ui/sepcomp/sepcomp-statics.rs +tests/ui/sepcomp/sepcomp-fns.rs +tests/ui/sepcomp/sepcomp-fns-backwards.rs +tests/ui/sepcomp/sepcomp-extern.rs +tests/ui/sepcomp/sepcomp-cci.rs +tests/ui/lto/thin-lto-inlines2.rs +tests/ui/lto/weak-works.rs +tests/ui/lto/thin-lto-inlines.rs +tests/ui/lto/thin-lto-global-allocator.rs +tests/ui/lto/msvc-imp-present.rs +tests/ui/lto/dylib-works.rs +tests/ui/lto/all-crates.rs +tests/ui/issues/issue-47364.rs +tests/ui/functions-closures/parallel-codegen-closures.rs From 02d63cbefaf496c98d267a3682ffe447ed0c449e Mon Sep 17 00:00:00 2001 From: lordforever Date: Thu, 6 Jun 2024 20:47:58 +0530 Subject: [PATCH 3/6] more failing tests --- tests/failing-ice-tests.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/failing-ice-tests.txt b/tests/failing-ice-tests.txt index 485b298bfa3..2084f86b62e 100644 --- a/tests/failing-ice-tests.txt +++ b/tests/failing-ice-tests.txt @@ -30,3 +30,7 @@ tests/ui/lto/dylib-works.rs tests/ui/lto/all-crates.rs tests/ui/issues/issue-47364.rs tests/ui/functions-closures/parallel-codegen-closures.rs +tests/ui/sepcomp/sepcomp-unwind.rs +tests/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs +tests/ui/extern/issue-64655-allow-unwind-when-calling-panic-directly.rs +tests/ui/unwind-no-uwtable.rs From ad82635689a67aa0834020ac2f166a4c4ad6bb2e Mon Sep 17 00:00:00 2001 From: lordforever Date: Sun, 9 Jun 2024 14:43:57 +0530 Subject: [PATCH 4/6] improvs --- .github/workflows/failures.yml | 3 +-- build_system/src/test.rs | 34 ++++++++++++++++++++++------------ 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/.github/workflows/failures.yml b/.github/workflows/failures.yml index b06b56aa192..66129f805d4 100644 --- a/.github/workflows/failures.yml +++ b/.github/workflows/failures.yml @@ -102,9 +102,8 @@ jobs: - name: Run failing ui pattern tests for ICE id: ui-tests run: | - ${{ matrix.libgccjit_version.env_extra }} ./y.sh test --release --clean --build-sysroot --test-failing-ui-pattern-tests ${{ matrix.libgccjit_version.extra }} | tee output_log_ui + ${{ matrix.libgccjit_version.env_extra }} ./y.sh test --release --test-failing-ui-pattern-tests ${{ matrix.libgccjit_version.extra }} | tee output_log_ui if grep -q "the compiler unexpectedly panicked" output_log_ui; then echo "Error: 'the compiler unexpectedly panicked' found in output logs. CI Error!!" exit 1 fi - rg --text "test result" output_log_ui >> $GITHUB_STEP_SUMMARY diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 5ee2086e172..70f3e7d1abe 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -812,7 +812,7 @@ fn extended_sysroot_tests(env: &Env, args: &TestArg) -> Result<(), String> { Ok(()) } -fn should_not_remove_test(file: &str) -> bool { +fn valid_ui_error_pattern_test(file: &str) -> bool { // contains //~ERROR, but shouldn't be removed [ "issues/auxiliary/issue-3136-a.rs", @@ -828,7 +828,7 @@ fn should_not_remove_test(file: &str) -> bool { } #[rustfmt::skip] -fn should_remove_test(file_path: &Path) -> Result { +fn contains_ui_error_patterns(file_path: &Path) -> Result { // Tests generating errors. let file = File::open(file_path) .map_err(|error| format!("Failed to read `{}`: {:?}", file_path.display(), error))?; @@ -860,6 +860,14 @@ fn should_remove_test(file_path: &Path) -> Result { Ok(false) } +// # Parameters +// +// * `env`: An environment variable that provides context for the function. +// * `args`: The arguments passed to the test. This could include things like the flags, config etc. +// * `prepare_files_callback`: A callback function that prepares the files needed for the test. Its used to remove/retain tests giving Error to run various rust test suits. +// * `should_run_test_callback`: An optional callback function that determines whether a test should be run or not. Used to run tests following specific conditions by defining conditions in bool returning function and sending it as an argument. +// * `test_type`: A string that indicates the type of the test being run. +// fn test_rustc_inner( env: &Env, args: &TestArg, @@ -881,7 +889,9 @@ where } if test_type == "ui" { + // uses contains_ui_error_patterns function being sent as callback to run only only error pattern tests if let Some(callback) = should_run_test_callback { + // Redefining walk_dir to handle subdirectories fn walk_dir( dir_path: PathBuf, dir_callback: F, @@ -955,9 +965,9 @@ where return Ok(()); } let path_str = file_path.display().to_string().replace("\\", "/"); - if should_not_remove_test(&path_str) { + if valid_ui_error_pattern_test(&path_str) { return Ok(()); - } else if should_remove_test(file_path)? { + } else if contains_ui_error_patterns(file_path)? { return remove_file(&file_path); } Ok(()) @@ -1053,7 +1063,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { let result1 = test_rustc_inner( env, args, - prepare_files_callback_retain("tests/failing-run-make-tests.txt", "run-make"), + retain_files_callback("tests/failing-run-make-tests.txt", "run-make"), None, "run-make", ); @@ -1061,7 +1071,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { let result2 = test_rustc_inner( env, args, - prepare_files_callback_retain("tests/failing-ui-tests.txt", "ui"), + retain_files_callback("tests/failing-ui-tests.txt", "ui"), None, "ui", ); @@ -1073,14 +1083,14 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> { test_rustc_inner( env, args, - prepare_files_callback_remove("tests/failing-ui-tests.txt", "ui"), + remove_files_callback("tests/failing-ui-tests.txt", "ui"), None, "ui", )?; test_rustc_inner( env, args, - prepare_files_callback_remove("tests/failing-run-make-tests.txt", "run-make"), + remove_files_callback("tests/failing-run-make-tests.txt", "run-make"), None, "run-make", ) @@ -1090,13 +1100,13 @@ fn test_failing_ui_pattern_tests(env: &Env, args: &TestArg) -> Result<(), String test_rustc_inner( env, args, - prepare_files_callback_remove("tests/failing-ice-tests.txt", "ui"), - Some(Box::new(|path| should_remove_test(path).unwrap_or(false))), + remove_files_callback("tests/failing-ice-tests.txt", "ui"), + Some(Box::new(|path| contains_ui_error_patterns(path).unwrap_or(false))), "ui", ) } -fn prepare_files_callback_retain<'a>( +fn retain_files_callback<'a>( file_path: &'a str, test_type: &'a str, ) -> impl Fn(&Path) -> Result + 'a { @@ -1159,7 +1169,7 @@ fn prepare_files_callback_retain<'a>( } } -fn prepare_files_callback_remove<'a>( +fn remove_files_callback<'a>( file_path: &'a str, test_type: &'a str, ) -> impl Fn(&Path) -> Result + 'a { From cb2dcd0e672db5ed910413c8bcbe8c532cae9be6 Mon Sep 17 00:00:00 2001 From: lordforever Date: Mon, 10 Jun 2024 13:37:59 +0530 Subject: [PATCH 5/6] callback to bool --- build_system/src/test.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 70f3e7d1abe..1562a8c7ef5 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -865,14 +865,14 @@ fn contains_ui_error_patterns(file_path: &Path) -> Result { // * `env`: An environment variable that provides context for the function. // * `args`: The arguments passed to the test. This could include things like the flags, config etc. // * `prepare_files_callback`: A callback function that prepares the files needed for the test. Its used to remove/retain tests giving Error to run various rust test suits. -// * `should_run_test_callback`: An optional callback function that determines whether a test should be run or not. Used to run tests following specific conditions by defining conditions in bool returning function and sending it as an argument. +// * `run_error_pattern_test`: A boolean that determines whether to run only error pattern tests. // * `test_type`: A string that indicates the type of the test being run. // fn test_rustc_inner( env: &Env, args: &TestArg, prepare_files_callback: F, - should_run_test_callback: Option bool>>, + run_error_pattern_test: bool, test_type: &str, ) -> Result<(), String> where @@ -890,7 +890,7 @@ where if test_type == "ui" { // uses contains_ui_error_patterns function being sent as callback to run only only error pattern tests - if let Some(callback) = should_run_test_callback { + if run_error_pattern_test { // Redefining walk_dir to handle subdirectories fn walk_dir( dir_path: PathBuf, @@ -919,7 +919,7 @@ where rust_path.join("tests/ui"), |_dir| Ok(()), |file_path| { - if callback(file_path) { + if contains_ui_error_patterns(file_path)? { Ok(()) } else { remove_file(file_path).map_err(|e| e.to_string()) @@ -1055,8 +1055,8 @@ where } fn test_rustc(env: &Env, args: &TestArg) -> Result<(), String> { - test_rustc_inner(env, args, |_| Ok(false), None, "run-make")?; - test_rustc_inner(env, args, |_| Ok(false), None, "ui") + test_rustc_inner(env, args, |_| Ok(false), false, "run-make")?; + test_rustc_inner(env, args, |_| Ok(false), false, "ui") } fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { @@ -1064,7 +1064,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { env, args, retain_files_callback("tests/failing-run-make-tests.txt", "run-make"), - None, + false, "run-make", ); @@ -1072,7 +1072,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> { env, args, retain_files_callback("tests/failing-ui-tests.txt", "ui"), - None, + false, "ui", ); @@ -1084,14 +1084,14 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> { env, args, remove_files_callback("tests/failing-ui-tests.txt", "ui"), - None, + false, "ui", )?; test_rustc_inner( env, args, remove_files_callback("tests/failing-run-make-tests.txt", "run-make"), - None, + false, "run-make", ) } @@ -1101,7 +1101,7 @@ fn test_failing_ui_pattern_tests(env: &Env, args: &TestArg) -> Result<(), String env, args, remove_files_callback("tests/failing-ice-tests.txt", "ui"), - Some(Box::new(|path| contains_ui_error_patterns(path).unwrap_or(false))), + true, "ui", ) } From 0074d9e69b15a9046c54f05fd01af7c43e5e0071 Mon Sep 17 00:00:00 2001 From: lordforever Date: Tue, 11 Jun 2024 02:06:10 +0530 Subject: [PATCH 6/6] walk_dir recursive --- build_system/src/build.rs | 17 ++++++++------- build_system/src/prepare.rs | 15 ++++++++------ build_system/src/test.rs | 41 +++++++++---------------------------- build_system/src/utils.rs | 10 ++++++++- 4 files changed, 38 insertions(+), 45 deletions(-) diff --git a/build_system/src/build.rs b/build_system/src/build.rs index ac428b4cec0..d465ab7e506 100644 --- a/build_system/src/build.rs +++ b/build_system/src/build.rs @@ -68,7 +68,7 @@ fn cleanup_sysroot_previous_build(start_dir: &Path) { // Clean target dir except for build scripts and incremental cache let _ = walk_dir( start_dir.join("target"), - |dir: &Path| { + &mut |dir: &Path| { for top in &["debug", "release"] { let _ = fs::remove_dir_all(dir.join(top).join("build")); let _ = fs::remove_dir_all(dir.join(top).join("deps")); @@ -77,7 +77,7 @@ fn cleanup_sysroot_previous_build(start_dir: &Path) { let _ = walk_dir( dir.join(top), - |sub_dir: &Path| { + &mut |sub_dir: &Path| { if sub_dir .file_name() .map(|filename| filename.to_str().unwrap().starts_with("libsysroot")) @@ -87,7 +87,7 @@ fn cleanup_sysroot_previous_build(start_dir: &Path) { } Ok(()) }, - |file: &Path| { + &mut |file: &Path| { if file .file_name() .map(|filename| filename.to_str().unwrap().starts_with("libsysroot")) @@ -97,11 +97,13 @@ fn cleanup_sysroot_previous_build(start_dir: &Path) { } Ok(()) }, + false, ); } Ok(()) }, - |_| Ok(()), + &mut |_| Ok(()), + false, ); let _ = fs::remove_file(start_dir.join("Cargo.lock")); @@ -166,14 +168,15 @@ pub fn build_sysroot(env: &HashMap, config: &ConfigInfo) -> Resu // Copy files to sysroot let sysroot_path = start_dir.join(format!("sysroot/lib/rustlib/{}/lib/", config.target_triple)); create_dir(&sysroot_path)?; - let copier = |dir_to_copy: &Path| { + let mut copier = |dir_to_copy: &Path| { // FIXME: should not use shell command! run_command(&[&"cp", &"-r", &dir_to_copy, &sysroot_path], None).map(|_| ()) }; walk_dir( start_dir.join(&format!("target/{}/{}/deps", config.target_triple, channel)), - copier, - copier, + &mut copier.clone(), + &mut copier, + false, )?; // Copy the source files to the sysroot (Rust for Linux needs this). diff --git a/build_system/src/prepare.rs b/build_system/src/prepare.rs index a085d863616..00aa632165e 100644 --- a/build_system/src/prepare.rs +++ b/build_system/src/prepare.rs @@ -72,30 +72,33 @@ fn prepare_libcore( let mut patches = Vec::new(); walk_dir( "patches", - |_| Ok(()), - |file_path: &Path| { + &mut |_| Ok(()), + &mut |file_path: &Path| { patches.push(file_path.to_path_buf()); Ok(()) }, + false, )?; if cross_compile { walk_dir( "patches/cross_patches", - |_| Ok(()), - |file_path: &Path| { + &mut |_| Ok(()), + &mut |file_path: &Path| { patches.push(file_path.to_path_buf()); Ok(()) }, + false, )?; } if libgccjit12_patches { walk_dir( "patches/libgccjit12", - |_| Ok(()), - |file_path: &Path| { + &mut |_| Ok(()), + &mut |file_path: &Path| { patches.push(file_path.to_path_buf()); Ok(()) }, + false, )?; } patches.sort(); diff --git a/build_system/src/test.rs b/build_system/src/test.rs index 1562a8c7ef5..462d20d728d 100644 --- a/build_system/src/test.rs +++ b/build_system/src/test.rs @@ -889,47 +889,24 @@ where } if test_type == "ui" { - // uses contains_ui_error_patterns function being sent as callback to run only only error pattern tests if run_error_pattern_test { - // Redefining walk_dir to handle subdirectories - fn walk_dir( - dir_path: PathBuf, - dir_callback: F, - file_callback: G, - ) -> Result<(), String> - where - F: Fn(&Path) -> Result<(), String> + Copy, - G: Fn(&Path) -> Result<(), String> + Copy, - { - if dir_path.is_dir() { - for entry in std::fs::read_dir(dir_path).unwrap() { - let entry = entry; - let path = entry.unwrap().path(); - if path.is_dir() { - dir_callback(&path)?; - walk_dir(path, dir_callback, file_callback)?; // Recursive call - } else if path.is_file() { - file_callback(&path)?; - } - } - } - Ok(()) - } + // After we removed the error tests that are known to panic with rustc_codegen_gcc, we now remove the passing tests since this runs the error tests. walk_dir( rust_path.join("tests/ui"), - |_dir| Ok(()), - |file_path| { + &mut |_dir| Ok(()), + &mut |file_path| { if contains_ui_error_patterns(file_path)? { Ok(()) } else { remove_file(file_path).map_err(|e| e.to_string()) } }, + true, )?; } else { walk_dir( rust_path.join("tests/ui"), - |dir| { + &mut |dir| { let dir_name = dir.file_name().and_then(|name| name.to_str()).unwrap_or(""); if [ "abi", @@ -949,7 +926,8 @@ where } Ok(()) }, - |_| Ok(()), + &mut |_| Ok(()), + false, )?; // These two functions are used to remove files that are known to not be working currently @@ -958,7 +936,8 @@ where if dir.file_name().map(|name| name == "auxiliary").unwrap_or(true) { return Ok(()); } - walk_dir(dir, dir_handling, file_handling) + + walk_dir(dir, &mut dir_handling, &mut file_handling, false) } fn file_handling(file_path: &Path) -> Result<(), String> { if !file_path.extension().map(|extension| extension == "rs").unwrap_or(false) { @@ -973,7 +952,7 @@ where Ok(()) } - walk_dir(rust_path.join("tests/ui"), dir_handling, file_handling)?; + walk_dir(rust_path.join("tests/ui"), &mut dir_handling, &mut file_handling, false)?; } let nb_parts = args.nb_parts.unwrap_or(0); if nb_parts > 0 { diff --git a/build_system/src/utils.rs b/build_system/src/utils.rs index cdda9d4a81e..3bba8df6c65 100644 --- a/build_system/src/utils.rs +++ b/build_system/src/utils.rs @@ -343,7 +343,12 @@ pub fn git_clone_root_dir( git_clone_inner(to_clone, &dest_parent_dir.join(&repo_name), shallow_clone, repo_name) } -pub fn walk_dir(dir: P, mut dir_cb: D, mut file_cb: F) -> Result<(), String> +pub fn walk_dir( + dir: P, + dir_cb: &mut D, + file_cb: &mut F, + recursive: bool, +) -> Result<(), String> where P: AsRef, D: FnMut(&Path) -> Result<(), String>, @@ -358,6 +363,9 @@ where let entry_path = entry.path(); if entry_path.is_dir() { dir_cb(&entry_path)?; + if recursive { + walk_dir(entry_path, dir_cb, file_cb, recursive)?; // Recursive call + } } else { file_cb(&entry_path)?; }