1
1
use std:: collections:: { BTreeSet , HashMap , HashSet } ;
2
- use std:: ffi:: OsString ;
3
- use std:: path:: { Path , PathBuf } ;
4
2
use std:: process:: Command ;
5
3
use std:: str:: FromStr ;
6
4
use std:: sync:: OnceLock ;
7
5
use std:: { fmt, iter} ;
8
6
9
7
use build_helper:: git:: GitConfig ;
8
+ use camino:: { Utf8Path , Utf8PathBuf } ;
10
9
use semver:: Version ;
11
10
use serde:: de:: { Deserialize , Deserializer , Error as _} ;
12
11
13
12
pub use self :: Mode :: * ;
14
13
use crate :: executor:: { ColorConfig , OutputFormat } ;
15
- use crate :: util:: { PathBufExt , add_dylib_path} ;
14
+ use crate :: util:: { Utf8PathBufExt , add_dylib_path} ;
16
15
17
16
macro_rules! string_enum {
18
17
( $( #[ $meta: meta] ) * $vis: vis enum $name: ident { $( $variant: ident => $repr: expr, ) * } ) => {
@@ -183,25 +182,25 @@ pub struct Config {
183
182
pub fail_fast : bool ,
184
183
185
184
/// The library paths required for running the compiler.
186
- pub compile_lib_path : PathBuf ,
185
+ pub compile_lib_path : Utf8PathBuf ,
187
186
188
187
/// The library paths required for running compiled programs.
189
- pub run_lib_path : PathBuf ,
188
+ pub run_lib_path : Utf8PathBuf ,
190
189
191
190
/// The rustc executable.
192
- pub rustc_path : PathBuf ,
191
+ pub rustc_path : Utf8PathBuf ,
193
192
194
193
/// The cargo executable.
195
- pub cargo_path : Option < PathBuf > ,
194
+ pub cargo_path : Option < Utf8PathBuf > ,
196
195
197
196
/// Rustc executable used to compile run-make recipes.
198
- pub stage0_rustc_path : Option < PathBuf > ,
197
+ pub stage0_rustc_path : Option < Utf8PathBuf > ,
199
198
200
199
/// The rustdoc executable.
201
- pub rustdoc_path : Option < PathBuf > ,
200
+ pub rustdoc_path : Option < Utf8PathBuf > ,
202
201
203
202
/// The coverage-dump executable.
204
- pub coverage_dump_path : Option < PathBuf > ,
203
+ pub coverage_dump_path : Option < Utf8PathBuf > ,
205
204
206
205
/// The Python executable to use for LLDB and htmldocck.
207
206
pub python : String ,
@@ -213,27 +212,27 @@ pub struct Config {
213
212
pub jsondoclint_path : Option < String > ,
214
213
215
214
/// The LLVM `FileCheck` binary path.
216
- pub llvm_filecheck : Option < PathBuf > ,
215
+ pub llvm_filecheck : Option < Utf8PathBuf > ,
217
216
218
217
/// Path to LLVM's bin directory.
219
- pub llvm_bin_dir : Option < PathBuf > ,
218
+ pub llvm_bin_dir : Option < Utf8PathBuf > ,
220
219
221
220
/// The path to the Clang executable to run Clang-based tests with. If
222
221
/// `None` then these tests will be ignored.
223
222
pub run_clang_based_tests_with : Option < String > ,
224
223
225
224
/// The directory containing the sources.
226
- pub src_root : PathBuf ,
225
+ pub src_root : Utf8PathBuf ,
227
226
/// The directory containing the test suite sources. Must be a subdirectory of `src_root`.
228
- pub src_test_suite_root : PathBuf ,
227
+ pub src_test_suite_root : Utf8PathBuf ,
229
228
230
229
/// Root build directory (e.g. `build/`).
231
- pub build_root : PathBuf ,
230
+ pub build_root : Utf8PathBuf ,
232
231
/// Test suite specific build directory (e.g. `build/host/test/ui/`).
233
- pub build_test_suite_root : PathBuf ,
232
+ pub build_test_suite_root : Utf8PathBuf ,
234
233
235
234
/// The directory containing the compiler sysroot
236
- pub sysroot_base : PathBuf ,
235
+ pub sysroot_base : Utf8PathBuf ,
237
236
238
237
/// The number of the stage under test.
239
238
pub stage : u32 ,
@@ -301,7 +300,7 @@ pub struct Config {
301
300
pub host : String ,
302
301
303
302
/// Path to / name of the Microsoft Console Debugger (CDB) executable
304
- pub cdb : Option < OsString > ,
303
+ pub cdb : Option < Utf8PathBuf > ,
305
304
306
305
/// Version of CDB
307
306
pub cdb_version : Option < [ u16 ; 4 ] > ,
@@ -322,7 +321,7 @@ pub struct Config {
322
321
pub system_llvm : bool ,
323
322
324
323
/// Path to the android tools
325
- pub android_cross_path : PathBuf ,
324
+ pub android_cross_path : Utf8PathBuf ,
326
325
327
326
/// Extra parameter to run adb on arm-linux-androideabi
328
327
pub adb_path : String ,
@@ -346,7 +345,7 @@ pub struct Config {
346
345
pub color : ColorConfig ,
347
346
348
347
/// where to find the remote test client process, if we're using it
349
- pub remote_test_client : Option < PathBuf > ,
348
+ pub remote_test_client : Option < Utf8PathBuf > ,
350
349
351
350
/// mode describing what file the actual ui output will be compared to
352
351
pub compare_mode : Option < CompareMode > ,
@@ -414,7 +413,7 @@ pub struct Config {
414
413
/// Path to minicore aux library, used for `no_core` tests that need `core` stubs in
415
414
/// cross-compilation scenarios that do not otherwise want/need to `-Zbuild-std`. Used in e.g.
416
415
/// ABI tests.
417
- pub minicore_path : PathBuf ,
416
+ pub minicore_path : Utf8PathBuf ,
418
417
}
419
418
420
419
impl Config {
@@ -804,8 +803,8 @@ fn serde_parse_u32<'de, D: Deserializer<'de>>(deserializer: D) -> Result<u32, D:
804
803
805
804
#[ derive( Debug , Clone ) ]
806
805
pub struct TestPaths {
807
- pub file : PathBuf , // e.g., compile-test/foo/bar/baz.rs
808
- pub relative_dir : PathBuf , // e.g., foo/bar
806
+ pub file : Utf8PathBuf , // e.g., compile-test/foo/bar/baz.rs
807
+ pub relative_dir : Utf8PathBuf , // e.g., foo/bar
809
808
}
810
809
811
810
/// Used by `ui` tests to generate things like `foo.stderr` from `foo.rs`.
@@ -814,7 +813,7 @@ pub fn expected_output_path(
814
813
revision : Option < & str > ,
815
814
compare_mode : & Option < CompareMode > ,
816
815
kind : & str ,
817
- ) -> PathBuf {
816
+ ) -> Utf8PathBuf {
818
817
assert ! ( UI_EXTENSIONS . contains( & kind) ) ;
819
818
let mut parts = Vec :: new ( ) ;
820
819
@@ -865,7 +864,7 @@ pub const UI_COVERAGE_MAP: &str = "cov-map";
865
864
/// ```
866
865
///
867
866
/// This is created early when tests are collected to avoid race conditions.
868
- pub fn output_relative_path ( config : & Config , relative_dir : & Path ) -> PathBuf {
867
+ pub fn output_relative_path ( config : & Config , relative_dir : & Utf8Path ) -> Utf8PathBuf {
869
868
config. build_test_suite_root . join ( relative_dir)
870
869
}
871
870
@@ -874,10 +873,10 @@ pub fn output_testname_unique(
874
873
config : & Config ,
875
874
testpaths : & TestPaths ,
876
875
revision : Option < & str > ,
877
- ) -> PathBuf {
876
+ ) -> Utf8PathBuf {
878
877
let mode = config. compare_mode . as_ref ( ) . map_or ( "" , |m| m. to_str ( ) ) ;
879
878
let debugger = config. debugger . as_ref ( ) . map_or ( "" , |m| m. to_str ( ) ) ;
880
- PathBuf :: from ( & testpaths. file . file_stem ( ) . unwrap ( ) )
879
+ Utf8PathBuf :: from ( & testpaths. file . file_stem ( ) . unwrap ( ) )
881
880
. with_extra_extension ( config. mode . output_dir_disambiguator ( ) )
882
881
. with_extra_extension ( revision. unwrap_or ( "" ) )
883
882
. with_extra_extension ( mode)
@@ -887,20 +886,32 @@ pub fn output_testname_unique(
887
886
/// Absolute path to the directory where all output for the given
888
887
/// test/revision should reside. Example:
889
888
/// /path/to/build/host-tuple/test/ui/relative/testname.revision.mode/
890
- pub fn output_base_dir ( config : & Config , testpaths : & TestPaths , revision : Option < & str > ) -> PathBuf {
889
+ pub fn output_base_dir (
890
+ config : & Config ,
891
+ testpaths : & TestPaths ,
892
+ revision : Option < & str > ,
893
+ ) -> Utf8PathBuf {
891
894
output_relative_path ( config, & testpaths. relative_dir )
892
895
. join ( output_testname_unique ( config, testpaths, revision) )
893
896
}
894
897
895
898
/// Absolute path to the base filename used as output for the given
896
899
/// test/revision. Example:
897
900
/// /path/to/build/host-tuple/test/ui/relative/testname.revision.mode/testname
898
- pub fn output_base_name ( config : & Config , testpaths : & TestPaths , revision : Option < & str > ) -> PathBuf {
901
+ pub fn output_base_name (
902
+ config : & Config ,
903
+ testpaths : & TestPaths ,
904
+ revision : Option < & str > ,
905
+ ) -> Utf8PathBuf {
899
906
output_base_dir ( config, testpaths, revision) . join ( testpaths. file . file_stem ( ) . unwrap ( ) )
900
907
}
901
908
902
909
/// Absolute path to the directory to use for incremental compilation. Example:
903
910
/// /path/to/build/host-tuple/test/ui/relative/testname.mode/testname.inc
904
- pub fn incremental_dir ( config : & Config , testpaths : & TestPaths , revision : Option < & str > ) -> PathBuf {
911
+ pub fn incremental_dir (
912
+ config : & Config ,
913
+ testpaths : & TestPaths ,
914
+ revision : Option < & str > ,
915
+ ) -> Utf8PathBuf {
905
916
output_base_name ( config, testpaths, revision) . with_extension ( "inc" )
906
917
}
0 commit comments