Skip to content

ui pattern failure tests #524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/failures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,13 @@ jobs:
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
155 changes: 105 additions & 50 deletions build_system/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -860,6 +864,7 @@ fn test_rustc_inner<F>(
env: &Env,
args: &TestArg,
prepare_files_callback: F,
should_run_test_callback: Option<Box<dyn Fn(&Path) -> bool>>,
test_type: &str,
) -> Result<(), String>
where
Expand All @@ -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<F, G>(
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();
Expand Down Expand Up @@ -1004,22 +1045,24 @@ 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> {
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",
);

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",
);

Expand All @@ -1030,18 +1073,30 @@ 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",
)
}

fn prepare_files_callback_failing<'a>(
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))),
"ui",
)
}

fn prepare_files_callback_retain<'a>(
file_path: &'a str,
test_type: &'a str,
) -> impl Fn(&Path) -> Result<bool, String> + 'a {
Expand Down Expand Up @@ -1104,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<bool, String> + 'a {
Expand Down
36 changes: 36 additions & 0 deletions tests/failing-ice-tests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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
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
Loading