11use std:: collections:: { BTreeSet , HashMap , HashSet } ;
2- use std:: ffi:: OsString ;
3- use std:: path:: { Path , PathBuf } ;
42use std:: process:: Command ;
53use std:: str:: FromStr ;
64use std:: sync:: OnceLock ;
75use std:: { fmt, iter} ;
86
97use build_helper:: git:: GitConfig ;
8+ use camino:: { Utf8Path , Utf8PathBuf } ;
109use semver:: Version ;
1110use serde:: de:: { Deserialize , Deserializer , Error as _} ;
1211
1312pub use self :: Mode :: * ;
1413use crate :: executor:: { ColorConfig , OutputFormat } ;
15- use crate :: util:: { PathBufExt , add_dylib_path} ;
14+ use crate :: util:: { Utf8PathBufExt , add_dylib_path} ;
1615
1716macro_rules! string_enum {
1817 ( $( #[ $meta: meta] ) * $vis: vis enum $name: ident { $( $variant: ident => $repr: expr, ) * } ) => {
@@ -183,25 +182,25 @@ pub struct Config {
183182 pub fail_fast : bool ,
184183
185184 /// The library paths required for running the compiler.
186- pub compile_lib_path : PathBuf ,
185+ pub compile_lib_path : Utf8PathBuf ,
187186
188187 /// The library paths required for running compiled programs.
189- pub run_lib_path : PathBuf ,
188+ pub run_lib_path : Utf8PathBuf ,
190189
191190 /// The rustc executable.
192- pub rustc_path : PathBuf ,
191+ pub rustc_path : Utf8PathBuf ,
193192
194193 /// The cargo executable.
195- pub cargo_path : Option < PathBuf > ,
194+ pub cargo_path : Option < Utf8PathBuf > ,
196195
197196 /// Rustc executable used to compile run-make recipes.
198- pub stage0_rustc_path : Option < PathBuf > ,
197+ pub stage0_rustc_path : Option < Utf8PathBuf > ,
199198
200199 /// The rustdoc executable.
201- pub rustdoc_path : Option < PathBuf > ,
200+ pub rustdoc_path : Option < Utf8PathBuf > ,
202201
203202 /// The coverage-dump executable.
204- pub coverage_dump_path : Option < PathBuf > ,
203+ pub coverage_dump_path : Option < Utf8PathBuf > ,
205204
206205 /// The Python executable to use for LLDB and htmldocck.
207206 pub python : String ,
@@ -213,27 +212,27 @@ pub struct Config {
213212 pub jsondoclint_path : Option < String > ,
214213
215214 /// The LLVM `FileCheck` binary path.
216- pub llvm_filecheck : Option < PathBuf > ,
215+ pub llvm_filecheck : Option < Utf8PathBuf > ,
217216
218217 /// Path to LLVM's bin directory.
219- pub llvm_bin_dir : Option < PathBuf > ,
218+ pub llvm_bin_dir : Option < Utf8PathBuf > ,
220219
221220 /// The path to the Clang executable to run Clang-based tests with. If
222221 /// `None` then these tests will be ignored.
223222 pub run_clang_based_tests_with : Option < String > ,
224223
225224 /// The directory containing the sources.
226- pub src_root : PathBuf ,
225+ pub src_root : Utf8PathBuf ,
227226 /// 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 ,
229228
230229 /// Root build directory (e.g. `build/`).
231- pub build_root : PathBuf ,
230+ pub build_root : Utf8PathBuf ,
232231 /// 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 ,
234233
235234 /// The directory containing the compiler sysroot
236- pub sysroot_base : PathBuf ,
235+ pub sysroot_base : Utf8PathBuf ,
237236
238237 /// The number of the stage under test.
239238 pub stage : u32 ,
@@ -301,7 +300,7 @@ pub struct Config {
301300 pub host : String ,
302301
303302 /// Path to / name of the Microsoft Console Debugger (CDB) executable
304- pub cdb : Option < OsString > ,
303+ pub cdb : Option < Utf8PathBuf > ,
305304
306305 /// Version of CDB
307306 pub cdb_version : Option < [ u16 ; 4 ] > ,
@@ -322,7 +321,7 @@ pub struct Config {
322321 pub system_llvm : bool ,
323322
324323 /// Path to the android tools
325- pub android_cross_path : PathBuf ,
324+ pub android_cross_path : Utf8PathBuf ,
326325
327326 /// Extra parameter to run adb on arm-linux-androideabi
328327 pub adb_path : String ,
@@ -346,7 +345,7 @@ pub struct Config {
346345 pub color : ColorConfig ,
347346
348347 /// 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 > ,
350349
351350 /// mode describing what file the actual ui output will be compared to
352351 pub compare_mode : Option < CompareMode > ,
@@ -414,7 +413,7 @@ pub struct Config {
414413 /// Path to minicore aux library, used for `no_core` tests that need `core` stubs in
415414 /// cross-compilation scenarios that do not otherwise want/need to `-Zbuild-std`. Used in e.g.
416415 /// ABI tests.
417- pub minicore_path : PathBuf ,
416+ pub minicore_path : Utf8PathBuf ,
418417}
419418
420419impl Config {
@@ -804,8 +803,8 @@ fn serde_parse_u32<'de, D: Deserializer<'de>>(deserializer: D) -> Result<u32, D:
804803
805804#[ derive( Debug , Clone ) ]
806805pub 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
809808}
810809
811810/// Used by `ui` tests to generate things like `foo.stderr` from `foo.rs`.
@@ -814,7 +813,7 @@ pub fn expected_output_path(
814813 revision : Option < & str > ,
815814 compare_mode : & Option < CompareMode > ,
816815 kind : & str ,
817- ) -> PathBuf {
816+ ) -> Utf8PathBuf {
818817 assert ! ( UI_EXTENSIONS . contains( & kind) ) ;
819818 let mut parts = Vec :: new ( ) ;
820819
@@ -865,7 +864,7 @@ pub const UI_COVERAGE_MAP: &str = "cov-map";
865864/// ```
866865///
867866/// 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 {
869868 config. build_test_suite_root . join ( relative_dir)
870869}
871870
@@ -874,10 +873,10 @@ pub fn output_testname_unique(
874873 config : & Config ,
875874 testpaths : & TestPaths ,
876875 revision : Option < & str > ,
877- ) -> PathBuf {
876+ ) -> Utf8PathBuf {
878877 let mode = config. compare_mode . as_ref ( ) . map_or ( "" , |m| m. to_str ( ) ) ;
879878 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 ( ) )
881880 . with_extra_extension ( config. mode . output_dir_disambiguator ( ) )
882881 . with_extra_extension ( revision. unwrap_or ( "" ) )
883882 . with_extra_extension ( mode)
@@ -887,20 +886,32 @@ pub fn output_testname_unique(
887886/// Absolute path to the directory where all output for the given
888887/// test/revision should reside. Example:
889888/// /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 {
891894 output_relative_path ( config, & testpaths. relative_dir )
892895 . join ( output_testname_unique ( config, testpaths, revision) )
893896}
894897
895898/// Absolute path to the base filename used as output for the given
896899/// test/revision. Example:
897900/// /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 {
899906 output_base_dir ( config, testpaths, revision) . join ( testpaths. file . file_stem ( ) . unwrap ( ) )
900907}
901908
902909/// Absolute path to the directory to use for incremental compilation. Example:
903910/// /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 {
905916 output_base_name ( config, testpaths, revision) . with_extension ( "inc" )
906917}
0 commit comments