From 88a12193365ae1a73d4840409cc7ef111b028eff Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Thu, 23 May 2013 09:39:48 -0700 Subject: [PATCH] cleanup warnings from compiletest --- src/compiletest/compiletest.rc | 72 +++++++++++++++++----------------- src/compiletest/header.rs | 7 ++-- src/compiletest/runtest.rs | 28 ++++++------- 3 files changed, 53 insertions(+), 54 deletions(-) diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc index f9ad0d5f925f..8147f8abb93d 100644 --- a/src/compiletest/compiletest.rc +++ b/src/compiletest/compiletest.rc @@ -50,20 +50,20 @@ pub fn main() { pub fn parse_config(args: ~[~str]) -> config { let opts = - ~[getopts::reqopt(~"compile-lib-path"), - getopts::reqopt(~"run-lib-path"), - getopts::reqopt(~"rustc-path"), getopts::reqopt(~"src-base"), - getopts::reqopt(~"build-base"), getopts::reqopt(~"aux-base"), - getopts::reqopt(~"stage-id"), - getopts::reqopt(~"mode"), getopts::optflag(~"ignored"), - getopts::optopt(~"runtool"), getopts::optopt(~"rustcflags"), - getopts::optflag(~"verbose"), - getopts::optopt(~"logfile"), - getopts::optflag(~"jit"), - getopts::optflag(~"newrt"), - getopts::optopt(~"target"), - getopts::optopt(~"adb-path"), - getopts::optopt(~"adb-test-dir") + ~[getopts::reqopt("compile-lib-path"), + getopts::reqopt("run-lib-path"), + getopts::reqopt("rustc-path"), getopts::reqopt("src-base"), + getopts::reqopt("build-base"), getopts::reqopt("aux-base"), + getopts::reqopt("stage-id"), + getopts::reqopt("mode"), getopts::optflag("ignored"), + getopts::optopt("runtool"), getopts::optopt("rustcflags"), + getopts::optflag("verbose"), + getopts::optopt("logfile"), + getopts::optflag("jit"), + getopts::optflag("newrt"), + getopts::optopt("target"), + getopts::optopt("adb-path"), + getopts::optopt("adb-test-dir") ]; assert!(!args.is_empty()); @@ -74,43 +74,43 @@ pub fn parse_config(args: ~[~str]) -> config { Err(f) => fail!(getopts::fail_str(f)) }; - fn opt_path(m: &getopts::Matches, nm: ~str) -> Path { + fn opt_path(m: &getopts::Matches, nm: &str) -> Path { Path(getopts::opt_str(m, nm)) } config { - compile_lib_path: getopts::opt_str(matches, ~"compile-lib-path"), - run_lib_path: getopts::opt_str(matches, ~"run-lib-path"), - 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"), + compile_lib_path: getopts::opt_str(matches, "compile-lib-path"), + run_lib_path: getopts::opt_str(matches, "run-lib-path"), + 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(copy matches.free[0]) } else { option::None }, - logfile: getopts::opt_maybe_str(matches, ~"logfile").map(|s| Path(*s)), - runtool: getopts::opt_maybe_str(matches, ~"runtool"), - rustcflags: getopts::opt_maybe_str(matches, ~"rustcflags"), - jit: getopts::opt_present(matches, ~"jit"), - newrt: getopts::opt_present(matches, ~"newrt"), - target: opt_str2(getopts::opt_maybe_str(matches, ~"target")).to_str(), - adb_path: opt_str2(getopts::opt_maybe_str(matches, ~"adb-path")).to_str(), + logfile: getopts::opt_maybe_str(matches, "logfile").map(|s| Path(*s)), + runtool: getopts::opt_maybe_str(matches, "runtool"), + rustcflags: getopts::opt_maybe_str(matches, "rustcflags"), + jit: getopts::opt_present(matches, "jit"), + newrt: getopts::opt_present(matches, "newrt"), + target: opt_str2(getopts::opt_maybe_str(matches, "target")).to_str(), + adb_path: opt_str2(getopts::opt_maybe_str(matches, "adb-path")).to_str(), adb_test_dir: - opt_str2(getopts::opt_maybe_str(matches, ~"adb-test-dir")).to_str(), + opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")).to_str(), adb_device_status: - if (opt_str2(getopts::opt_maybe_str(matches, ~"target")) == + if (opt_str2(getopts::opt_maybe_str(matches, "target")) == ~"arm-linux-androideabi") { - if (opt_str2(getopts::opt_maybe_str(matches, ~"adb-test-dir")) != + if (opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")) != ~"(none)" && - opt_str2(getopts::opt_maybe_str(matches, ~"adb-test-dir")) != + opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")) != ~"") { true } else { false } } else { false }, - verbose: getopts::opt_present(matches, ~"verbose") + verbose: getopts::opt_present(matches, "verbose") } } diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index b3205a486107..cc4320248cdf 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -87,10 +87,10 @@ pub fn load_props(testfile: &Path) -> TestProps { pub fn is_test_ignored(config: &config, testfile: &Path) -> bool { for iter_header(testfile) |ln| { - if parse_name_directive(ln, ~"xfail-test") { return true; } + if parse_name_directive(ln, "xfail-test") { return true; } if parse_name_directive(ln, xfail_target()) { return true; } if config.mode == common::mode_pretty && - parse_name_directive(ln, ~"xfail-pretty") { return true; } + parse_name_directive(ln, "xfail-pretty") { return true; } }; return false; @@ -107,8 +107,7 @@ fn iter_header(testfile: &Path, it: &fn(~str) -> bool) -> bool { // Assume that any directives will be found before the first // module or function. This doesn't seem to be an optimization // with a warm page cache. Maybe with a cold one. - if str::starts_with(ln, ~"fn") - || str::starts_with(ln, ~"mod") { + if str::starts_with(ln, "fn") || str::starts_with(ln, "mod") { return false; } else { if !(it(ln)) { return false; } } } diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index da81df0e404d..c1586a1b350f 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -25,7 +25,7 @@ use util::logv; pub fn run(config: config, testfile: ~str) { if config.verbose { // We're going to be dumping a lot of info. Start on a new line. - io::stdout().write_str(~"\n\n"); + io::stdout().write_str("\n\n"); } let testfile = Path(testfile); debug!("running %s", testfile.to_str()); @@ -231,7 +231,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) { // do not optimize debuginfo tests let mut config = match config.rustcflags { Some(ref flags) => config { - rustcflags: Some(str::replace(*flags, ~"-O", ~"")), + rustcflags: Some(str::replace(*flags, "-O", "")), .. copy *config }, None => copy *config @@ -249,19 +249,19 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) { // write debugger script let script_str = str::append(cmds, "\nquit\n"); debug!("script_str = %s", script_str); - dump_output_file(config, testfile, script_str, ~"debugger.script"); + dump_output_file(config, testfile, script_str, "debugger.script"); // run debugger script with gdb #[cfg(windows)] fn debugger() -> ~str { ~"gdb.exe" } #[cfg(unix)] fn debugger() -> ~str { ~"gdb" } - let debugger_script = make_out_name(config, testfile, ~"debugger.script"); + let debugger_script = make_out_name(config, testfile, "debugger.script"); let debugger_opts = ~[~"-quiet", ~"-batch", ~"-nx", ~"-command=" + debugger_script.to_str(), make_exe_name(config, testfile).to_str()]; let ProcArgs = ProcArgs {prog: debugger(), args: debugger_opts}; - ProcRes = compose_and_run(config, testfile, ProcArgs, ~[], ~"", None); + ProcRes = compose_and_run(config, testfile, ProcArgs, ~[], "", None); if ProcRes.status != 0 { fatal(~"gdb failed to execute"); } @@ -368,7 +368,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError], } // ignore this msg which gets printed at the end - if str::contains(line, ~"aborting due to") { + if str::contains(line, "aborting due to") { was_expected = true; } @@ -643,7 +643,7 @@ fn program_output(config: &config, testfile: &Path, lib_path: &str, prog: ~str, #[cfg(target_os = "macos")] #[cfg(target_os = "freebsd")] fn make_cmdline(_libpath: &str, prog: &str, args: &[~str]) -> ~str { - fmt!("%s %s", prog, str::connect(args, ~" ")) + fmt!("%s %s", prog, str::connect(args, " ")) } #[cfg(target_os = "win32")] @@ -668,7 +668,7 @@ fn dump_output_file(config: &config, testfile: &Path, out: &str, extension: &str) { let outfile = make_out_name(config, testfile, extension); let writer = - io::file_writer(&outfile, ~[io::Create, io::Truncate]).get(); + io::file_writer(&outfile, [io::Create, io::Truncate]).get(); writer.write_str(out); } @@ -692,8 +692,8 @@ fn output_base_name(config: &config, testfile: &Path) -> Path { fn maybe_dump_to_stdout(config: &config, out: &str, err: &str) { if config.verbose { - let sep1 = fmt!("------%s------------------------------", ~"stdout"); - let sep2 = fmt!("------%s------------------------------", ~"stderr"); + let sep1 = fmt!("------%s------------------------------", "stdout"); + let sep2 = fmt!("------%s------------------------------", "stderr"); let sep3 = ~"------------------------------------------"; io::stdout().write_line(sep1); io::stdout().write_line(out); @@ -781,10 +781,10 @@ fn _arm_exec_compiled_test(config: &config, props: &TestProps, newargs_err.push(newcmd_err); let procsrv::Result{ out: out_out, err: _out_err, status: out_status } = - procsrv::run(~"", config.adb_path, newargs_out, ~[(~"",~"")], + procsrv::run("", config.adb_path, newargs_out, ~[(~"",~"")], Some(~"")); let procsrv::Result{ out: err_out, err: _err_err, status: _err_status } = - procsrv::run(~"", config.adb_path, newargs_err, ~[(~"",~"")], + procsrv::run("", config.adb_path, newargs_err, ~[(~"",~"")], Some(~"")); dump_output(config, testfile, out_out, err_out); @@ -818,8 +818,8 @@ fn _arm_push_aux_shared_library(config: &config, testfile: &Path) { if (file.filetype() == Some(~".so")) { - let copy_result = procsrv::run(~"", config.adb_path, - ~[~"push", file.to_str(), copy config.adb_test_dir], + let copy_result = procsrv::run("", config.adb_path, + [~"push", file.to_str(), copy config.adb_test_dir], ~[(~"",~"")], Some(~"")); if config.verbose {