Skip to content

Commit

Permalink
ui pattern failure tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lordshashank committed May 26, 2024
1 parent d7c8e0f commit 0c497cc
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 92 deletions.
102 changes: 54 additions & 48 deletions .github/workflows/failures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]"
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 "[email protected]"
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: 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
144 changes: 100 additions & 44 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,91 @@ 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) {
println!("file is {:?}", &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 +1046,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"),
None,
"run-make",
);

let result2 = test_rustc_inner(
env,
args,
prepare_files_callback_failing("tests/failing-ui-tests.txt", "ui"),
None,
"ui",
);

Expand All @@ -1031,16 +1075,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,
Expand Down

0 comments on commit 0c497cc

Please sign in to comment.