@@ -485,19 +485,25 @@ fn std_tests(env: &Env, args: &TestArg) -> Result<(), String> {
485
485
Ok ( ( ) )
486
486
}
487
487
488
- fn setup_rustc ( env : & mut Env , args : & TestArg ) -> Result < ( ) , String > {
488
+ fn setup_rustc ( env : & mut Env , args : & TestArg ) -> Result < PathBuf , String > {
489
489
let toolchain = format ! (
490
490
"+{channel}-{host}" ,
491
491
channel = get_toolchain( ) ?, // May also include date
492
492
host = args. config_info. host_triple
493
493
) ;
494
- let rust_dir = Some ( Path :: new ( "rust" ) ) ;
494
+ let rust_dir_path = Path :: new ( crate :: BUILD_DIR ) . join ( "rust" ) ;
495
495
// If the repository was already cloned, command will fail, so doesn't matter.
496
496
let _ = run_command_with_output_and_env (
497
- & [ & "git" , & "clone" , & "https://github.com/rust-lang/rust.git" ] ,
497
+ & [
498
+ & "git" ,
499
+ & "clone" ,
500
+ & "https://github.com/rust-lang/rust.git" ,
501
+ & rust_dir_path,
502
+ ] ,
498
503
None ,
499
504
Some ( env) ,
500
505
) ;
506
+ let rust_dir: Option < & Path > = Some ( & rust_dir_path) ;
501
507
run_command ( & [ & "git" , & "checkout" , & "--" , & "tests/" ] , rust_dir) ?;
502
508
run_command_with_output_and_env ( & [ & "git" , & "fetch" ] , rust_dir, Some ( env) ) ?;
503
509
let rustc_commit = match rustc_version_info ( env. get ( "RUSTC" ) . map ( |s| s. as_str ( ) ) ) ?. commit_hash {
@@ -561,8 +567,9 @@ fn setup_rustc(env: &mut Env, args: &TestArg) -> Result<(), String> {
561
567
String :: new ( )
562
568
}
563
569
} ;
570
+ let file_path = rust_dir_path. join ( "config.toml" ) ;
564
571
std:: fs:: write (
565
- "rust/config.toml" ,
572
+ & file_path ,
566
573
& format ! (
567
574
r#"change-id = 115898
568
575
@@ -587,13 +594,19 @@ download-ci-llvm = false
587
594
llvm_filecheck = llvm_filecheck. trim( ) ,
588
595
) ,
589
596
)
590
- . map_err ( |error| format ! ( "Failed to write into `rust/config.toml`: {:?}" , error) ) ?;
591
- Ok ( ( ) )
597
+ . map_err ( |error| {
598
+ format ! (
599
+ "Failed to write into `{}`: {:?}" ,
600
+ file_path. display( ) ,
601
+ error
602
+ )
603
+ } ) ?;
604
+ Ok ( rust_dir_path)
592
605
}
593
606
594
607
fn asm_tests ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
595
608
let mut env = env. clone ( ) ;
596
- setup_rustc ( & mut env, args) ?;
609
+ let rust_dir = setup_rustc ( & mut env, args) ?;
597
610
// FIXME: create a function "display_if_not_quiet" or something along the line.
598
611
println ! ( "[TEST] rustc asm test suite" ) ;
599
612
@@ -621,7 +634,7 @@ fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> {
621
634
)
622
635
. as_str ( ) ,
623
636
] ,
624
- Some ( Path :: new ( "rust" ) ) ,
637
+ Some ( & rust_dir ) ,
625
638
Some ( & env) ,
626
639
) ?;
627
640
Ok ( ( ) )
@@ -761,11 +774,11 @@ fn extended_rand_tests(env: &Env, args: &TestArg) -> Result<(), String> {
761
774
println ! ( "Not using GCC master branch. Skipping `extended_rand_tests`." ) ;
762
775
return Ok ( ( ) ) ;
763
776
}
764
- let path = Path :: new ( "rand" ) ;
765
- run_cargo_command ( & [ & "clean" ] , Some ( path) , env, args) ?;
777
+ let path = Path :: new ( crate :: BUILD_DIR ) . join ( "rand" ) ;
778
+ run_cargo_command ( & [ & "clean" ] , Some ( & path) , env, args) ?;
766
779
// FIXME: create a function "display_if_not_quiet" or something along the line.
767
780
println ! ( "[TEST] rust-random/rand" ) ;
768
- run_cargo_command ( & [ & "test" , & "--workspace" ] , Some ( path) , env, args) ?;
781
+ run_cargo_command ( & [ & "test" , & "--workspace" ] , Some ( & path) , env, args) ?;
769
782
Ok ( ( ) )
770
783
}
771
784
@@ -774,8 +787,8 @@ fn extended_regex_example_tests(env: &Env, args: &TestArg) -> Result<(), String>
774
787
println ! ( "Not using GCC master branch. Skipping `extended_regex_example_tests`." ) ;
775
788
return Ok ( ( ) ) ;
776
789
}
777
- let path = Path :: new ( "regex" ) ;
778
- run_cargo_command ( & [ & "clean" ] , Some ( path) , env, args) ?;
790
+ let path = Path :: new ( crate :: BUILD_DIR ) . join ( "regex" ) ;
791
+ run_cargo_command ( & [ & "clean" ] , Some ( & path) , env, args) ?;
779
792
// FIXME: create a function "display_if_not_quiet" or something along the line.
780
793
println ! ( "[TEST] rust-lang/regex example shootout-regex-dna" ) ;
781
794
let mut env = env. clone ( ) ;
@@ -788,14 +801,14 @@ fn extended_regex_example_tests(env: &Env, args: &TestArg) -> Result<(), String>
788
801
// Make sure `[codegen mono items] start` doesn't poison the diff
789
802
run_cargo_command (
790
803
& [ & "build" , & "--example" , & "shootout-regex-dna" ] ,
791
- Some ( path) ,
804
+ Some ( & path) ,
792
805
& env,
793
806
args,
794
807
) ?;
795
808
796
809
run_cargo_command_with_callback (
797
810
& [ & "run" , & "--example" , & "shootout-regex-dna" ] ,
798
- Some ( path) ,
811
+ Some ( & path) ,
799
812
& env,
800
813
args,
801
814
|cargo_command, cwd, env| {
@@ -838,6 +851,7 @@ fn extended_regex_tests(env: &Env, args: &TestArg) -> Result<(), String> {
838
851
env. get( "RUSTFLAGS" ) . cloned( ) . unwrap_or_default( )
839
852
) ;
840
853
env. insert ( "RUSTFLAGS" . to_string ( ) , rustflags) ;
854
+ let path = Path :: new ( crate :: BUILD_DIR ) . join ( "regex" ) ;
841
855
run_cargo_command (
842
856
& [
843
857
& "test" ,
@@ -850,7 +864,7 @@ fn extended_regex_tests(env: &Env, args: &TestArg) -> Result<(), String> {
850
864
& "-Zunstable-options" ,
851
865
& "-q" ,
852
866
] ,
853
- Some ( Path :: new ( "regex" ) ) ,
867
+ Some ( & path ) ,
854
868
& env,
855
869
args,
856
870
) ?;
@@ -928,17 +942,15 @@ fn should_remove_test(file_path: &Path) -> Result<bool, String> {
928
942
929
943
fn test_rustc_inner < F > ( env : & Env , args : & TestArg , prepare_files_callback : F ) -> Result < ( ) , String >
930
944
where
931
- F : Fn ( ) -> Result < bool , String > ,
945
+ F : Fn ( & Path ) -> Result < bool , String > ,
932
946
{
933
947
// FIXME: create a function "display_if_not_quiet" or something along the line.
934
948
println ! ( "[TEST] rust-lang/rust" ) ;
935
949
let mut env = env. clone ( ) ;
936
- setup_rustc ( & mut env, args) ?;
937
-
938
- let rust_path = Path :: new ( "rust" ) ;
950
+ let rust_path = setup_rustc ( & mut env, args) ?;
939
951
940
952
walk_dir (
941
- "rust/ tests/ui",
953
+ rust_path . join ( " tests/ui") ,
942
954
|dir| {
943
955
let dir_name = dir. file_name ( ) . and_then ( |name| name. to_str ( ) ) . unwrap_or ( "" ) ;
944
956
if [
@@ -1001,7 +1013,7 @@ where
1001
1013
1002
1014
walk_dir ( rust_path. join ( "tests/ui" ) , dir_handling, file_handling) ?;
1003
1015
1004
- if !prepare_files_callback ( ) ? {
1016
+ if !prepare_files_callback ( & rust_path ) ? {
1005
1017
// FIXME: create a function "display_if_not_quiet" or something along the line.
1006
1018
println ! ( "Keeping all UI tests" ) ;
1007
1019
}
@@ -1027,7 +1039,7 @@ where
1027
1039
& "-path" ,
1028
1040
& "*/auxiliary/*" ,
1029
1041
] ,
1030
- Some ( rust_path) ,
1042
+ Some ( & rust_path) ,
1031
1043
) ?
1032
1044
. stdout ,
1033
1045
)
@@ -1072,18 +1084,18 @@ where
1072
1084
& "--rustc-args" ,
1073
1085
& rustc_args,
1074
1086
] ,
1075
- Some ( rust_path) ,
1087
+ Some ( & rust_path) ,
1076
1088
Some ( & env) ,
1077
1089
) ?;
1078
1090
Ok ( ( ) )
1079
1091
}
1080
1092
1081
1093
fn test_rustc ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
1082
- test_rustc_inner ( env, args, || Ok ( false ) )
1094
+ test_rustc_inner ( env, args, |_ | Ok ( false ) )
1083
1095
}
1084
1096
1085
1097
fn test_failing_rustc ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
1086
- test_rustc_inner ( env, args, || {
1098
+ test_rustc_inner ( env, args, |rust_path | {
1087
1099
// Removing all tests.
1088
1100
run_command (
1089
1101
& [
@@ -1098,7 +1110,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
1098
1110
& "*/auxiliary/*" ,
1099
1111
& "-delete" ,
1100
1112
] ,
1101
- Some ( Path :: new ( "rust" ) ) ,
1113
+ Some ( rust_path ) ,
1102
1114
) ?;
1103
1115
// Putting back only the failing ones.
1104
1116
let path = "tests/failing-ui-tests.txt" ;
@@ -1108,10 +1120,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
1108
1120
. map ( |line| line. trim ( ) )
1109
1121
. filter ( |line| !line. is_empty ( ) )
1110
1122
{
1111
- run_command (
1112
- & [ & "git" , & "checkout" , & "--" , & file] ,
1113
- Some ( Path :: new ( "rust" ) ) ,
1114
- ) ?;
1123
+ run_command ( & [ & "git" , & "checkout" , & "--" , & file] , Some ( & rust_path) ) ?;
1115
1124
}
1116
1125
} else {
1117
1126
println ! (
@@ -1124,7 +1133,7 @@ fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
1124
1133
}
1125
1134
1126
1135
fn test_successful_rustc ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
1127
- test_rustc_inner ( env, args, || {
1136
+ test_rustc_inner ( env, args, |rust_path | {
1128
1137
// Removing the failing tests.
1129
1138
let path = "tests/failing-ui-tests.txt" ;
1130
1139
if let Ok ( files) = std:: fs:: read_to_string ( path) {
@@ -1133,7 +1142,7 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
1133
1142
. map ( |line| line. trim ( ) )
1134
1143
. filter ( |line| !line. is_empty ( ) )
1135
1144
{
1136
- let path = Path :: new ( "rust" ) . join ( file) ;
1145
+ let path = rust_path . join ( file) ;
1137
1146
remove_file ( & path) ?;
1138
1147
}
1139
1148
} else {
0 commit comments