Skip to content

Commit cb2dcd0

Browse files
committed
callback to bool
1 parent ad82635 commit cb2dcd0

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Diff for: build_system/src/test.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -865,14 +865,14 @@ fn contains_ui_error_patterns(file_path: &Path) -> Result<bool, String> {
865865
// * `env`: An environment variable that provides context for the function.
866866
// * `args`: The arguments passed to the test. This could include things like the flags, config etc.
867867
// * `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.
868-
// * `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.
868+
// * `run_error_pattern_test`: A boolean that determines whether to run only error pattern tests.
869869
// * `test_type`: A string that indicates the type of the test being run.
870870
//
871871
fn test_rustc_inner<F>(
872872
env: &Env,
873873
args: &TestArg,
874874
prepare_files_callback: F,
875-
should_run_test_callback: Option<Box<dyn Fn(&Path) -> bool>>,
875+
run_error_pattern_test: bool,
876876
test_type: &str,
877877
) -> Result<(), String>
878878
where
@@ -890,7 +890,7 @@ where
890890

891891
if test_type == "ui" {
892892
// uses contains_ui_error_patterns function being sent as callback to run only only error pattern tests
893-
if let Some(callback) = should_run_test_callback {
893+
if run_error_pattern_test {
894894
// Redefining walk_dir to handle subdirectories
895895
fn walk_dir<F, G>(
896896
dir_path: PathBuf,
@@ -919,7 +919,7 @@ where
919919
rust_path.join("tests/ui"),
920920
|_dir| Ok(()),
921921
|file_path| {
922-
if callback(file_path) {
922+
if contains_ui_error_patterns(file_path)? {
923923
Ok(())
924924
} else {
925925
remove_file(file_path).map_err(|e| e.to_string())
@@ -1055,24 +1055,24 @@ where
10551055
}
10561056

10571057
fn test_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
1058-
test_rustc_inner(env, args, |_| Ok(false), None, "run-make")?;
1059-
test_rustc_inner(env, args, |_| Ok(false), None, "ui")
1058+
test_rustc_inner(env, args, |_| Ok(false), false, "run-make")?;
1059+
test_rustc_inner(env, args, |_| Ok(false), false, "ui")
10601060
}
10611061

10621062
fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
10631063
let result1 = test_rustc_inner(
10641064
env,
10651065
args,
10661066
retain_files_callback("tests/failing-run-make-tests.txt", "run-make"),
1067-
None,
1067+
false,
10681068
"run-make",
10691069
);
10701070

10711071
let result2 = test_rustc_inner(
10721072
env,
10731073
args,
10741074
retain_files_callback("tests/failing-ui-tests.txt", "ui"),
1075-
None,
1075+
false,
10761076
"ui",
10771077
);
10781078

@@ -1084,14 +1084,14 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
10841084
env,
10851085
args,
10861086
remove_files_callback("tests/failing-ui-tests.txt", "ui"),
1087-
None,
1087+
false,
10881088
"ui",
10891089
)?;
10901090
test_rustc_inner(
10911091
env,
10921092
args,
10931093
remove_files_callback("tests/failing-run-make-tests.txt", "run-make"),
1094-
None,
1094+
false,
10951095
"run-make",
10961096
)
10971097
}
@@ -1101,7 +1101,7 @@ fn test_failing_ui_pattern_tests(env: &Env, args: &TestArg) -> Result<(), String
11011101
env,
11021102
args,
11031103
remove_files_callback("tests/failing-ice-tests.txt", "ui"),
1104-
Some(Box::new(|path| contains_ui_error_patterns(path).unwrap_or(false))),
1104+
true,
11051105
"ui",
11061106
)
11071107
}

0 commit comments

Comments
 (0)