Skip to content

Commit c284b8b

Browse files
committed
Start using core::path2::Path in a lot of places.
1 parent a8f1bee commit c284b8b

Some content is hidden

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

43 files changed

+1135
-1111
lines changed

src/cargo/cargo.rs

Lines changed: 242 additions & 235 deletions
Large diffs are not rendered by default.

src/cargo/pgp.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ fn supported() -> bool {
6363
r.status == 0
6464
}
6565

66-
fn init(root: ~str) {
67-
let p = path::connect(root, ~"gpg");
68-
if !os::path_is_dir(p) {
69-
os::make_dir(p, 0x1c0i32);
70-
let p = run::start_program(~"gpg", ~[~"--homedir", p, ~"--import"]);
66+
fn init(root: &Path) {
67+
let p = root.push("gpg");
68+
if !os::path_is_dir(&p) {
69+
os::make_dir(&p, 0x1c0i32);
70+
let p = run::start_program(~"gpg", ~[~"--homedir",
71+
p.to_str(),
72+
~"--import"]);
7173
p.input().write_str(signing_key());
7274
let s = p.finish();
7375
if s != 0 {
@@ -76,19 +78,22 @@ fn init(root: ~str) {
7678
}
7779
}
7880

79-
fn add(root: ~str, key: ~str) {
80-
let path = path::connect(root, ~"gpg");
81+
fn add(root: &Path, key: &Path) {
82+
let path = root.push("gpg");
8183
let p =
82-
run::program_output(~"gpg", ~[~"--homedir", path, ~"--import", key]);
84+
run::program_output(~"gpg", ~[~"--homedir", path.to_str(),
85+
~"--import", key.to_str()]);
8386
if p.status != 0 {
8487
fail ~"pgp add failed: " + p.out;
8588
}
8689
}
8790
88-
fn verify(root: ~str, data: ~str, sig: ~str, keyfp: ~str) -> bool {
89-
let path = path::connect(root, ~"gpg");
90-
let p = gpg(~[~"--homedir", path, ~"--with-fingerprint", ~"--verify", sig,
91-
data]);
91+
fn verify(root: &Path, data: &Path, sig: &Path, keyfp: ~str) -> bool {
92+
let path = root.push("gpg");
93+
let p = gpg(~[~"--homedir", path.to_str(),
94+
~"--with-fingerprint",
95+
~"--verify", sig.to_str(),
96+
data.to_str()]);
9297
let res = ~"Primary key fingerprint: " + keyfp;
9398
for str::split_char(p.err, '\n').each |line| {
9499
if line == res { return true; }

src/compiletest/common.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ type config = {
1010
run_lib_path: ~str,
1111

1212
// The rustc executable
13-
rustc_path: ~str,
13+
rustc_path: Path,
1414

1515
// The directory containing the tests to run
16-
src_base: ~str,
16+
src_base: Path,
1717

1818
// The directory where programs should be built
19-
build_base: ~str,
19+
build_base: Path,
2020

2121
// Directory for auxiliary libraries
22-
aux_base: ~str,
22+
aux_base: Path,
2323

2424
// The name of the stage being built (stage1, etc)
2525
stage_id: ~str,
@@ -34,7 +34,7 @@ type config = {
3434
filter: option<~str>,
3535

3636
// Write out a parseable log of tests that were run
37-
logfile: option<~str>,
37+
logfile: option<Path>,
3838

3939
// A command line to prefix program execution with,
4040
// for running under valgrind

src/compiletest/compiletest.rs

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,26 @@ fn parse_config(args: ~[~str]) -> config {
4242
err(f) => fail getopts::fail_str(f)
4343
};
4444

45+
fn opt_path(m: getopts::matches, nm: ~str) -> Path {
46+
Path(getopts::opt_str(m, nm))
47+
}
48+
4549
return {compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"),
4650
run_lib_path: getopts::opt_str(matches, ~"run-lib-path"),
47-
rustc_path: getopts::opt_str(matches, ~"rustc-path"),
48-
src_base: getopts::opt_str(matches, ~"src-base"),
49-
build_base: getopts::opt_str(matches, ~"build-base"),
50-
aux_base: getopts::opt_str(matches, ~"aux-base"),
51+
rustc_path: opt_path(matches, ~"rustc-path"),
52+
src_base: opt_path(matches, ~"src-base"),
53+
build_base: opt_path(matches, ~"build-base"),
54+
aux_base: opt_path(matches, ~"aux-base"),
5155
stage_id: getopts::opt_str(matches, ~"stage-id"),
5256
mode: str_mode(getopts::opt_str(matches, ~"mode")),
5357
run_ignored: getopts::opt_present(matches, ~"ignored"),
5458
filter:
5559
if vec::len(matches.free) > 0u {
5660
option::some(matches.free[0])
5761
} else { option::none },
58-
logfile: getopts::opt_maybe_str(matches, ~"logfile"),
62+
logfile: option::map(getopts::opt_maybe_str(matches,
63+
~"logfile"),
64+
|s| Path(s)),
5965
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
6066
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
6167
verbose: getopts::opt_present(matches, ~"verbose")};
@@ -66,9 +72,9 @@ fn log_config(config: config) {
6672
logv(c, fmt!("configuration:"));
6773
logv(c, fmt!("compile_lib_path: %s", config.compile_lib_path));
6874
logv(c, fmt!("run_lib_path: %s", config.run_lib_path));
69-
logv(c, fmt!("rustc_path: %s", config.rustc_path));
70-
logv(c, fmt!("src_base: %s", config.src_base));
71-
logv(c, fmt!("build_base: %s", config.build_base));
75+
logv(c, fmt!("rustc_path: %s", config.rustc_path.to_str()));
76+
logv(c, fmt!("src_base: %s", config.src_base.to_str()));
77+
logv(c, fmt!("build_base: %s", config.build_base.to_str()));
7278
logv(c, fmt!("stage_id: %s", config.stage_id));
7379
logv(c, fmt!("mode: %s", mode_str(config.mode)));
7480
logv(c, fmt!("run_ignored: %b", config.run_ignored));
@@ -122,34 +128,35 @@ fn test_opts(config: config) -> test::test_opts {
122128
run_ignored: config.run_ignored,
123129
logfile:
124130
match config.logfile {
125-
option::some(s) => option::some(s),
131+
option::some(s) => option::some(s.to_str()),
126132
option::none => option::none
127133
}
128134
}
129135
}
130136

131137
fn make_tests(config: config) -> ~[test::test_desc] {
132-
debug!("making tests from %s", config.src_base);
138+
debug!("making tests from %s",
139+
config.src_base.to_str());
133140
let mut tests = ~[];
134-
for os::list_dir_path(config.src_base).each |file| {
135-
let file = file;
136-
debug!("inspecting file %s", file);
141+
for os::list_dir_path(&config.src_base).each |file| {
142+
let file = copy file;
143+
debug!("inspecting file %s", file.to_str());
137144
if is_test(config, file) {
138145
vec::push(tests, make_test(config, file))
139146
}
140147
}
141148
return tests;
142149
}
143150

144-
fn is_test(config: config, testfile: ~str) -> bool {
151+
fn is_test(config: config, testfile: &Path) -> bool {
145152
// Pretty-printer does not work with .rc files yet
146153
let valid_extensions =
147154
match config.mode {
148155
mode_pretty => ~[~".rs"],
149156
_ => ~[~".rc", ~".rs"]
150157
};
151158
let invalid_prefixes = ~[~".", ~"#", ~"~"];
152-
let name = path::basename(testfile);
159+
let name = option::get(testfile.filename());
153160

154161
let mut valid = false;
155162

@@ -164,7 +171,7 @@ fn is_test(config: config, testfile: ~str) -> bool {
164171
return valid;
165172
}
166173

167-
fn make_test(config: config, testfile: ~str) ->
174+
fn make_test(config: config, testfile: &Path) ->
168175
test::test_desc {
169176
{
170177
name: make_test_name(config, testfile),
@@ -174,12 +181,13 @@ fn make_test(config: config, testfile: ~str) ->
174181
}
175182
}
176183

177-
fn make_test_name(config: config, testfile: ~str) -> ~str {
178-
fmt!("[%s] %s", mode_str(config.mode), testfile)
184+
fn make_test_name(config: config, testfile: &Path) -> ~str {
185+
fmt!("[%s] %s", mode_str(config.mode), testfile.to_str())
179186
}
180187

181-
fn make_test_closure(config: config, testfile: ~str) -> test::test_fn {
182-
fn~() { runtest::run(config, copy testfile) }
188+
fn make_test_closure(config: config, testfile: &Path) -> test::test_fn {
189+
let testfile = testfile.to_str();
190+
fn~() { runtest::run(config, testfile) }
183191
}
184192

185193
// Local Variables:

src/compiletest/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export expected_error;
66
type expected_error = { line: uint, kind: ~str, msg: ~str };
77

88
// Load any test directives embedded in the file
9-
fn load_errors(testfile: ~str) -> ~[expected_error] {
9+
fn load_errors(testfile: &Path) -> ~[expected_error] {
1010
let mut error_patterns = ~[];
1111
let rdr = result::get(io::file_reader(testfile));
1212
let mut line_num = 1u;

src/compiletest/header.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ type test_props = {
1414
compile_flags: option<~str>,
1515
// If present, the name of a file that this test should match when
1616
// pretty-printed
17-
pp_exact: option<~str>,
17+
pp_exact: option<Path>,
1818
// Modules from aux directory that should be compiled
1919
aux_builds: ~[~str],
2020
// Environment settings to use during execution
2121
exec_env: ~[(~str,~str)]
2222
};
2323

2424
// Load any test directives embedded in the file
25-
fn load_props(testfile: ~str) -> test_props {
25+
fn load_props(testfile: &Path) -> test_props {
2626
let mut error_patterns = ~[];
2727
let mut aux_builds = ~[];
2828
let mut exec_env = ~[];
@@ -59,7 +59,7 @@ fn load_props(testfile: ~str) -> test_props {
5959
};
6060
}
6161

62-
fn is_test_ignored(config: config, testfile: ~str) -> bool {
62+
fn is_test_ignored(config: config, testfile: &Path) -> bool {
6363
let mut found = false;
6464
for iter_header(testfile) |ln| {
6565
if parse_name_directive(ln, ~"xfail-test") { return true; }
@@ -74,7 +74,7 @@ fn is_test_ignored(config: config, testfile: ~str) -> bool {
7474
}
7575
}
7676
77-
fn iter_header(testfile: ~str, it: fn(~str) -> bool) -> bool {
77+
fn iter_header(testfile: &Path, it: fn(~str) -> bool) -> bool {
7878
let rdr = result::get(io::file_reader(testfile));
7979
while !rdr.eof() {
8080
let ln = rdr.read_line();
@@ -114,12 +114,12 @@ fn parse_exec_env(line: ~str) -> option<(~str, ~str)> {
114114
}
115115
}
116116

117-
fn parse_pp_exact(line: ~str, testfile: ~str) -> option<~str> {
117+
fn parse_pp_exact(line: ~str, testfile: &Path) -> option<Path> {
118118
match parse_name_value_directive(line, ~"pp-exact") {
119-
option::some(s) => option::some(s),
119+
option::some(s) => option::some(Path(s)),
120120
option::none => {
121121
if parse_name_directive(line, ~"pp-exact") {
122-
option::some(path::basename(testfile))
122+
option::some(testfile.file_path())
123123
} else {
124124
option::none
125125
}

0 commit comments

Comments
 (0)