@@ -12,6 +12,7 @@ pub mod diff;
1212pub mod env_checked;
1313pub mod external_deps;
1414pub mod fs_wrapper;
15+ pub mod path_helpers;
1516pub mod run;
1617pub mod targets;
1718
@@ -67,18 +68,10 @@ pub use artifact_names::{
6768 bin_name, dynamic_lib_extension, dynamic_lib_name, rust_lib_name, static_lib_name,
6869} ;
6970
70- use command:: { Command , CompletedProcess } ;
71-
72- /// Returns the path for a local test file.
73- pub fn path < P : AsRef < Path > > ( p : P ) -> PathBuf {
74- cwd ( ) . join ( p. as_ref ( ) )
75- }
71+ /// Path-related helpers.
72+ pub use path_helpers:: { cwd, cygpath_windows, path, source_root} ;
7673
77- /// Path to the root rust-lang/rust source checkout.
78- #[ must_use]
79- pub fn source_root ( ) -> PathBuf {
80- env_var ( "SOURCE_ROOT" ) . into ( )
81- }
74+ use command:: { Command , CompletedProcess } ;
8275
8376/// Creates a new symlink to a path on the filesystem, adjusting for Windows or Unix.
8477#[ cfg( target_family = "windows" ) ]
@@ -108,12 +101,6 @@ pub fn create_symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) {
108101 ) ) ;
109102}
110103
111- /// Return the current working directory.
112- #[ must_use]
113- pub fn cwd ( ) -> PathBuf {
114- std:: env:: current_dir ( ) . unwrap ( )
115- }
116-
117104// FIXME(Oneirical): This will no longer be required after compiletest receives the ability
118105// to manipulate read-only files. See https://github.com/rust-lang/rust/issues/126334
119106/// Ensure that the path P is read-only while the test runs, and restore original permissions
@@ -227,23 +214,6 @@ pub fn count_regex_matches_in_files_with_extension(re: ®ex::Regex, ext: &str)
227214 count
228215}
229216
230- /// Use `cygpath -w` on a path to get a Windows path string back. This assumes that `cygpath` is
231- /// available on the platform!
232- #[ track_caller]
233- #[ must_use]
234- pub fn cygpath_windows < P : AsRef < Path > > ( path : P ) -> String {
235- let caller = panic:: Location :: caller ( ) ;
236- let mut cygpath = Command :: new ( "cygpath" ) ;
237- cygpath. arg ( "-w" ) ;
238- cygpath. arg ( path. as_ref ( ) ) ;
239- let output = cygpath. run ( ) ;
240- if !output. status ( ) . success ( ) {
241- handle_failed_output ( & cygpath, output, caller. line ( ) ) ;
242- }
243- // cygpath -w can attach a newline
244- output. stdout_utf8 ( ) . trim ( ) . to_string ( )
245- }
246-
247217pub ( crate ) fn handle_failed_output (
248218 cmd : & Command ,
249219 output : CompletedProcess ,
0 commit comments