Skip to content

Commit 73d3d00

Browse files
committed
path2: Replace the path module outright
Remove the old path. Rename path2 to path. Update all clients for the new path. Also make some miscellaneous changes to the Path APIs to help the adoption process.
1 parent 6741241 commit 73d3d00

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2504
-2992
lines changed

src/compiletest/compiletest.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ pub fn parse_config(args: ~[~str]) -> config {
102102
}
103103

104104
fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
105-
Path(m.opt_str(nm).unwrap())
105+
Path::from_str(m.opt_str(nm).unwrap())
106106
}
107107

108108
config {
109109
compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
110110
run_lib_path: matches.opt_str("run-lib-path").unwrap(),
111111
rustc_path: opt_path(matches, "rustc-path"),
112-
clang_path: matches.opt_str("clang-path").map(|s| Path(s)),
113-
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| Path(s)),
112+
clang_path: matches.opt_str("clang-path").map(|s| Path::from_str(s)),
113+
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| Path::from_str(s)),
114114
src_base: opt_path(matches, "src-base"),
115115
build_base: opt_path(matches, "build-base"),
116116
aux_base: opt_path(matches, "aux-base"),
@@ -123,10 +123,10 @@ pub fn parse_config(args: ~[~str]) -> config {
123123
} else {
124124
None
125125
},
126-
logfile: matches.opt_str("logfile").map(|s| Path(s)),
127-
save_metrics: matches.opt_str("save-metrics").map(|s| Path(s)),
126+
logfile: matches.opt_str("logfile").map(|s| Path::from_str(s)),
127+
save_metrics: matches.opt_str("save-metrics").map(|s| Path::from_str(s)),
128128
ratchet_metrics:
129-
matches.opt_str("ratchet-metrics").map(|s| Path(s)),
129+
matches.opt_str("ratchet-metrics").map(|s| Path::from_str(s)),
130130
ratchet_noise_percent:
131131
matches.opt_str("ratchet-noise-percent").and_then(|s| from_str::<f64>(s)),
132132
runtool: matches.opt_str("runtool"),
@@ -155,9 +155,9 @@ pub fn log_config(config: &config) {
155155
logv(c, format!("configuration:"));
156156
logv(c, format!("compile_lib_path: {}", config.compile_lib_path));
157157
logv(c, format!("run_lib_path: {}", config.run_lib_path));
158-
logv(c, format!("rustc_path: {}", config.rustc_path.to_str()));
159-
logv(c, format!("src_base: {}", config.src_base.to_str()));
160-
logv(c, format!("build_base: {}", config.build_base.to_str()));
158+
logv(c, format!("rustc_path: {}", config.rustc_path.display()));
159+
logv(c, format!("src_base: {}", config.src_base.display()));
160+
logv(c, format!("build_base: {}", config.build_base.display()));
161161
logv(c, format!("stage_id: {}", config.stage_id));
162162
logv(c, format!("mode: {}", mode_str(config.mode)));
163163
logv(c, format!("run_ignored: {}", config.run_ignored));
@@ -245,12 +245,12 @@ pub fn test_opts(config: &config) -> test::TestOpts {
245245

246246
pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
247247
debug2!("making tests from {}",
248-
config.src_base.to_str());
248+
config.src_base.display());
249249
let mut tests = ~[];
250250
let dirs = os::list_dir_path(&config.src_base);
251251
for file in dirs.iter() {
252252
let file = file.clone();
253-
debug2!("inspecting file {}", file.to_str());
253+
debug2!("inspecting file {}", file.display());
254254
if is_test(config, &file) {
255255
let t = do make_test(config, &file) {
256256
match config.mode {
@@ -272,7 +272,7 @@ pub fn is_test(config: &config, testfile: &Path) -> bool {
272272
_ => ~[~".rc", ~".rs"]
273273
};
274274
let invalid_prefixes = ~[~".", ~"#", ~"~"];
275-
let name = testfile.filename().unwrap();
275+
let name = testfile.filename_str().unwrap();
276276

277277
let mut valid = false;
278278

@@ -303,9 +303,9 @@ pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName {
303303

304304
// Try to elide redundant long paths
305305
fn shorten(path: &Path) -> ~str {
306-
let filename = path.filename();
307-
let p = path.pop();
308-
let dir = p.filename();
306+
let filename = path.filename_str();
307+
let p = path.dir_path();
308+
let dir = p.filename_str();
309309
format!("{}/{}", dir.unwrap_or(""), filename.unwrap_or(""))
310310
}
311311

@@ -317,13 +317,15 @@ pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName {
317317
pub fn make_test_closure(config: &config, testfile: &Path) -> test::TestFn {
318318
use std::cell::Cell;
319319
let config = Cell::new((*config).clone());
320-
let testfile = Cell::new(testfile.to_str());
320+
// FIXME (#9639): This needs to handle non-utf8 paths
321+
let testfile = Cell::new(testfile.as_str().unwrap().to_owned());
321322
test::DynTestFn(|| { runtest::run(config.take(), testfile.take()) })
322323
}
323324

324325
pub fn make_metrics_test_closure(config: &config, testfile: &Path) -> test::TestFn {
325326
use std::cell::Cell;
326327
let config = Cell::new((*config).clone());
327-
let testfile = Cell::new(testfile.to_str());
328+
// FIXME (#9639): This needs to handle non-utf8 paths
329+
let testfile = Cell::new(testfile.as_str().unwrap().to_owned());
328330
test::DynMetricFn(|mm| { runtest::run_metrics(config.take(), testfile.take(), mm) })
329331
}

src/compiletest/header.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
161161

162162
fn parse_pp_exact(line: &str, testfile: &Path) -> Option<Path> {
163163
match parse_name_value_directive(line, ~"pp-exact") {
164-
Some(s) => Some(Path(s)),
164+
Some(s) => Some(Path::from_str(s)),
165165
None => {
166166
if parse_name_directive(line, "pp-exact") {
167-
Some(testfile.file_path())
167+
testfile.file_path()
168168
} else {
169169
None
170170
}

0 commit comments

Comments
 (0)