Permalink
Browse files

Start using core::path2::Path in a lot of places.

  • Loading branch information...
graydon committed Aug 24, 2012
1 parent a8f1bee commit c284b8b1dc348ab8b9c82350dd1b4e53fac1225c
Showing with 1,135 additions and 1,111 deletions.
  1. +242 −235 src/cargo/cargo.rs
  2. +17 −12 src/cargo/pgp.rs
  3. +5 −5 src/compiletest/common.rs
  4. +28 −20 src/compiletest/compiletest.rs
  5. +1 −1 src/compiletest/errors.rs
  6. +7 −7 src/compiletest/header.rs
  7. +69 −63 src/compiletest/runtest.rs
  8. +55 −48 src/fuzzer/fuzzer.rs
  9. +1 −1 src/libcore/core.rc
  10. +8 −2 src/libcore/core.rs
  11. +24 −21 src/libcore/io.rs
  12. +120 −128 src/libcore/os.rs
  13. +165 −129 src/libcore/path2.rs
  14. +8 −7 src/libstd/tempfile.rs
  15. +1 −1 src/libstd/test.rs
  16. +8 −9 src/libsyntax/ext/source_util.rs
  17. +13 −12 src/libsyntax/parse.rs
  18. +27 −28 src/libsyntax/parse/eval.rs
  19. +51 −78 src/rustc/back/link.rs
  20. +119 −136 src/rustc/back/rpath.rs
  21. +31 −34 src/rustc/driver/driver.rs
  22. +5 −3 src/rustc/driver/rustc.rs
  23. +3 −3 src/rustc/driver/session.rs
  24. +2 −2 src/rustc/metadata/creader.rs
  25. +5 −5 src/rustc/metadata/cstore.rs
  26. +40 −43 src/rustc/metadata/filesearch.rs
  27. +17 −15 src/rustc/metadata/loader.rs
  28. +1 −1 src/rustc/middle/trans/base.rs
  29. +7 −6 src/rustc/middle/trans/debuginfo.rs
  30. +3 −0 src/rustc/util/ppaux.rs
  31. +1 −1 src/rustdoc/astsrv.rs
  32. +14 −13 src/rustdoc/config.rs
  33. +2 −2 src/rustdoc/markdown_index_pass.rs
  34. +1 −1 src/rustdoc/markdown_pass.rs
  35. +16 −16 src/rustdoc/markdown_writer.rs
  36. +3 −3 src/rustdoc/parse.rs
  37. +2 −2 src/rustdoc/rustdoc.rs
  38. +3 −5 src/test/bench/core-std.rs
  39. +2 −1 src/test/bench/shootout-fasta.rs
  40. +3 −5 src/test/bench/shootout-k-nucleotide-pipes.rs
  41. +3 −5 src/test/bench/shootout-k-nucleotide.rs
  42. +1 −1 src/test/bench/shootout-mandelbrot.rs
  43. +1 −1 src/test/bench/task-perf-word-count-generic.rs
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -63,11 +63,13 @@ fn supported() -> bool {
r.status == 0
}
-fn init(root: ~str) {
- let p = path::connect(root, ~"gpg");
- if !os::path_is_dir(p) {
- os::make_dir(p, 0x1c0i32);
- let p = run::start_program(~"gpg", ~[~"--homedir", p, ~"--import"]);
+fn init(root: &Path) {
+ let p = root.push("gpg");
+ if !os::path_is_dir(&p) {
+ os::make_dir(&p, 0x1c0i32);
+ let p = run::start_program(~"gpg", ~[~"--homedir",
+ p.to_str(),
+ ~"--import"]);
p.input().write_str(signing_key());
let s = p.finish();
if s != 0 {
@@ -76,19 +78,22 @@ fn init(root: ~str) {
}
}
-fn add(root: ~str, key: ~str) {
- let path = path::connect(root, ~"gpg");
+fn add(root: &Path, key: &Path) {
+ let path = root.push("gpg");
let p =
- run::program_output(~"gpg", ~[~"--homedir", path, ~"--import", key]);
+ run::program_output(~"gpg", ~[~"--homedir", path.to_str(),
+ ~"--import", key.to_str()]);
if p.status != 0 {
fail ~"pgp add failed: " + p.out;
}
}
-fn verify(root: ~str, data: ~str, sig: ~str, keyfp: ~str) -> bool {
- let path = path::connect(root, ~"gpg");
- let p = gpg(~[~"--homedir", path, ~"--with-fingerprint", ~"--verify", sig,
- data]);
+fn verify(root: &Path, data: &Path, sig: &Path, keyfp: ~str) -> bool {
+ let path = root.push("gpg");
+ let p = gpg(~[~"--homedir", path.to_str(),
+ ~"--with-fingerprint",
+ ~"--verify", sig.to_str(),
+ data.to_str()]);
let res = ~"Primary key fingerprint: " + keyfp;
for str::split_char(p.err, '\n').each |line| {
if line == res { return true; }
View
@@ -10,16 +10,16 @@ type config = {
run_lib_path: ~str,
// The rustc executable
- rustc_path: ~str,
+ rustc_path: Path,
// The directory containing the tests to run
- src_base: ~str,
+ src_base: Path,
// The directory where programs should be built
- build_base: ~str,
+ build_base: Path,
// Directory for auxiliary libraries
- aux_base: ~str,
+ aux_base: Path,
// The name of the stage being built (stage1, etc)
stage_id: ~str,
@@ -34,7 +34,7 @@ type config = {
filter: option<~str>,
// Write out a parseable log of tests that were run
- logfile: option<~str>,
+ logfile: option<Path>,
// A command line to prefix program execution with,
// for running under valgrind
@@ -42,20 +42,26 @@ fn parse_config(args: ~[~str]) -> config {
err(f) => fail getopts::fail_str(f)
};
+ fn opt_path(m: getopts::matches, nm: ~str) -> Path {
+ Path(getopts::opt_str(m, nm))
+ }
+
return {compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"),
run_lib_path: getopts::opt_str(matches, ~"run-lib-path"),
- rustc_path: getopts::opt_str(matches, ~"rustc-path"),
- src_base: getopts::opt_str(matches, ~"src-base"),
- build_base: getopts::opt_str(matches, ~"build-base"),
- aux_base: getopts::opt_str(matches, ~"aux-base"),
+ rustc_path: opt_path(matches, ~"rustc-path"),
+ src_base: opt_path(matches, ~"src-base"),
+ build_base: opt_path(matches, ~"build-base"),
+ aux_base: opt_path(matches, ~"aux-base"),
stage_id: getopts::opt_str(matches, ~"stage-id"),
mode: str_mode(getopts::opt_str(matches, ~"mode")),
run_ignored: getopts::opt_present(matches, ~"ignored"),
filter:
if vec::len(matches.free) > 0u {
option::some(matches.free[0])
} else { option::none },
- logfile: getopts::opt_maybe_str(matches, ~"logfile"),
+ logfile: option::map(getopts::opt_maybe_str(matches,
+ ~"logfile"),
+ |s| Path(s)),
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"),
verbose: getopts::opt_present(matches, ~"verbose")};
@@ -66,9 +72,9 @@ fn log_config(config: config) {
logv(c, fmt!("configuration:"));
logv(c, fmt!("compile_lib_path: %s", config.compile_lib_path));
logv(c, fmt!("run_lib_path: %s", config.run_lib_path));
- logv(c, fmt!("rustc_path: %s", config.rustc_path));
- logv(c, fmt!("src_base: %s", config.src_base));
- logv(c, fmt!("build_base: %s", config.build_base));
+ logv(c, fmt!("rustc_path: %s", config.rustc_path.to_str()));
+ logv(c, fmt!("src_base: %s", config.src_base.to_str()));
+ logv(c, fmt!("build_base: %s", config.build_base.to_str()));
logv(c, fmt!("stage_id: %s", config.stage_id));
logv(c, fmt!("mode: %s", mode_str(config.mode)));
logv(c, fmt!("run_ignored: %b", config.run_ignored));
@@ -122,34 +128,35 @@ fn test_opts(config: config) -> test::test_opts {
run_ignored: config.run_ignored,
logfile:
match config.logfile {
- option::some(s) => option::some(s),
+ option::some(s) => option::some(s.to_str()),
option::none => option::none
}
}
}
fn make_tests(config: config) -> ~[test::test_desc] {
- debug!("making tests from %s", config.src_base);
+ debug!("making tests from %s",
+ config.src_base.to_str());
let mut tests = ~[];
- for os::list_dir_path(config.src_base).each |file| {
- let file = file;
- debug!("inspecting file %s", file);
+ for os::list_dir_path(&config.src_base).each |file| {
+ let file = copy file;
+ debug!("inspecting file %s", file.to_str());
if is_test(config, file) {
vec::push(tests, make_test(config, file))
}
}
return tests;
}
-fn is_test(config: config, testfile: ~str) -> bool {
+fn is_test(config: config, testfile: &Path) -> bool {
// Pretty-printer does not work with .rc files yet
let valid_extensions =
match config.mode {
mode_pretty => ~[~".rs"],
_ => ~[~".rc", ~".rs"]
};
let invalid_prefixes = ~[~".", ~"#", ~"~"];
- let name = path::basename(testfile);
+ let name = option::get(testfile.filename());
let mut valid = false;
@@ -164,7 +171,7 @@ fn is_test(config: config, testfile: ~str) -> bool {
return valid;
}
-fn make_test(config: config, testfile: ~str) ->
+fn make_test(config: config, testfile: &Path) ->
test::test_desc {
{
name: make_test_name(config, testfile),
@@ -174,12 +181,13 @@ fn make_test(config: config, testfile: ~str) ->
}
}
-fn make_test_name(config: config, testfile: ~str) -> ~str {
- fmt!("[%s] %s", mode_str(config.mode), testfile)
+fn make_test_name(config: config, testfile: &Path) -> ~str {
+ fmt!("[%s] %s", mode_str(config.mode), testfile.to_str())
}
-fn make_test_closure(config: config, testfile: ~str) -> test::test_fn {
- fn~() { runtest::run(config, copy testfile) }
+fn make_test_closure(config: config, testfile: &Path) -> test::test_fn {
+ let testfile = testfile.to_str();
+ fn~() { runtest::run(config, testfile) }
}
// Local Variables:
@@ -6,7 +6,7 @@ export expected_error;
type expected_error = { line: uint, kind: ~str, msg: ~str };
// Load any test directives embedded in the file
-fn load_errors(testfile: ~str) -> ~[expected_error] {
+fn load_errors(testfile: &Path) -> ~[expected_error] {
let mut error_patterns = ~[];
let rdr = result::get(io::file_reader(testfile));
let mut line_num = 1u;
View
@@ -14,15 +14,15 @@ type test_props = {
compile_flags: option<~str>,
// If present, the name of a file that this test should match when
// pretty-printed
- pp_exact: option<~str>,
+ pp_exact: option<Path>,
// Modules from aux directory that should be compiled
aux_builds: ~[~str],
// Environment settings to use during execution
exec_env: ~[(~str,~str)]
};
// Load any test directives embedded in the file
-fn load_props(testfile: ~str) -> test_props {
+fn load_props(testfile: &Path) -> test_props {
let mut error_patterns = ~[];
let mut aux_builds = ~[];
let mut exec_env = ~[];
@@ -59,7 +59,7 @@ fn load_props(testfile: ~str) -> test_props {
};
}
-fn is_test_ignored(config: config, testfile: ~str) -> bool {
+fn is_test_ignored(config: config, testfile: &Path) -> bool {
let mut found = false;
for iter_header(testfile) |ln| {
if parse_name_directive(ln, ~"xfail-test") { return true; }
@@ -74,7 +74,7 @@ fn is_test_ignored(config: config, testfile: ~str) -> bool {
}
}
-fn iter_header(testfile: ~str, it: fn(~str) -> bool) -> bool {
+fn iter_header(testfile: &Path, it: fn(~str) -> bool) -> bool {
let rdr = result::get(io::file_reader(testfile));
while !rdr.eof() {
let ln = rdr.read_line();
@@ -114,12 +114,12 @@ fn parse_exec_env(line: ~str) -> option<(~str, ~str)> {
}
}
-fn parse_pp_exact(line: ~str, testfile: ~str) -> option<~str> {
+fn parse_pp_exact(line: ~str, testfile: &Path) -> option<Path> {
match parse_name_value_directive(line, ~"pp-exact") {
- option::some(s) => option::some(s),
+ option::some(s) => option::some(Path(s)),
option::none => {
if parse_name_directive(line, ~"pp-exact") {
- option::some(path::basename(testfile))
+ option::some(testfile.file_path())
} else {
option::none
}
Oops, something went wrong.

0 comments on commit c284b8b

Please sign in to comment.