Skip to content

Remove vecs_implicitly_copyable #6434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 38 additions & 27 deletions src/compiletest/compiletest.rc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

#[crate_type = "bin"];

#[allow(vecs_implicitly_copyable)];
#[allow(non_camel_case_types)];
#[allow(deprecated_pattern)];

extern mod std(vers = "0.7-pre");

Expand Down Expand Up @@ -43,8 +41,8 @@ pub mod errors;
pub fn main() {
let args = os::args();
let config = parse_config(args);
log_config(config);
run_tests(config);
log_config(&config);
run_tests(&config);
}

pub fn parse_config(args: ~[~str]) -> config {
Expand Down Expand Up @@ -89,30 +87,31 @@ pub fn parse_config(args: ~[~str]) -> config {
run_ignored: getopts::opt_present(matches, ~"ignored"),
filter:
if vec::len(matches.free) > 0u {
option::Some(matches.free[0])
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_str(getopts::opt_maybe_str(matches, ~"target")),
adb_path: opt_str(getopts::opt_maybe_str(matches, ~"adb-path")),
adb_test_dir: opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")),
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(),
adb_device_status:
if (opt_str(getopts::opt_maybe_str(matches, ~"target")) ==
if (opt_str2(getopts::opt_maybe_str(matches, ~"target")) ==
~"arm-linux-androideabi") {
if (opt_str(getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
if (opt_str2(getopts::opt_maybe_str(matches, ~"adb-test-dir")) !=
~"(none)" &&
opt_str(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")
}
}

pub fn log_config(config: config) {
pub fn log_config(config: &config) {
let c = config;
logv(c, fmt!("configuration:"));
logv(c, fmt!("compile_lib_path: %s", config.compile_lib_path));
Expand All @@ -123,9 +122,9 @@ pub fn log_config(config: config) {
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));
logv(c, fmt!("filter: %s", opt_str(config.filter)));
logv(c, fmt!("runtool: %s", opt_str(config.runtool)));
logv(c, fmt!("rustcflags: %s", opt_str(config.rustcflags)));
logv(c, fmt!("filter: %s", opt_str(&config.filter)));
logv(c, fmt!("runtool: %s", opt_str(&config.runtool)));
logv(c, fmt!("rustcflags: %s", opt_str(&config.rustcflags)));
logv(c, fmt!("jit: %b", config.jit));
logv(c, fmt!("newrt: %b", config.newrt));
logv(c, fmt!("target: %s", config.target));
Expand All @@ -136,8 +135,18 @@ pub fn log_config(config: config) {
logv(c, fmt!("\n"));
}

pub fn opt_str(maybestr: Option<~str>) -> ~str {
match maybestr { option::Some(s) => s, option::None => ~"(none)" }
pub fn opt_str<'a>(maybestr: &'a Option<~str>) -> &'a str {
match *maybestr {
option::None => "(none)",
option::Some(ref s) => {
let s: &'a str = *s;
s
}
}
}

pub fn opt_str2(maybestr: Option<~str>) -> ~str {
match maybestr { None => ~"(none)", Some(s) => { s } }
}

pub fn str_opt(maybestr: ~str) -> Option<~str> {
Expand Down Expand Up @@ -165,16 +174,16 @@ pub fn mode_str(mode: mode) -> ~str {
}
}

pub fn run_tests(config: config) {
pub fn run_tests(config: &config) {
let opts = test_opts(config);
let tests = make_tests(config);
let res = test::run_tests_console(&opts, tests);
if !res { fail!("Some tests failed"); }
}

pub fn test_opts(config: config) -> test::TestOpts {
pub fn test_opts(config: &config) -> test::TestOpts {
test::TestOpts {
filter: config.filter,
filter: copy config.filter,
run_ignored: config.run_ignored,
logfile: copy config.logfile,
run_tests: true,
Expand All @@ -184,7 +193,7 @@ pub fn test_opts(config: config) -> test::TestOpts {
}
}

pub fn make_tests(config: config) -> ~[test::TestDescAndFn] {
pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
debug!("making tests from %s",
config.src_base.to_str());
let mut tests = ~[];
Expand All @@ -198,7 +207,7 @@ pub fn make_tests(config: config) -> ~[test::TestDescAndFn] {
tests
}

pub fn is_test(config: config, testfile: &Path) -> bool {
pub fn is_test(config: &config, testfile: &Path) -> bool {
// Pretty-printer does not work with .rc files yet
let valid_extensions =
match config.mode {
Expand All @@ -221,7 +230,7 @@ pub fn is_test(config: config, testfile: &Path) -> bool {
return valid;
}

pub fn make_test(config: config, testfile: &Path) -> test::TestDescAndFn {
pub fn make_test(config: &config, testfile: &Path) -> test::TestDescAndFn {
test::TestDescAndFn {
desc: test::TestDesc {
name: make_test_name(config, testfile),
Expand All @@ -232,13 +241,15 @@ pub fn make_test(config: config, testfile: &Path) -> test::TestDescAndFn {
}
}

pub fn make_test_name(config: config, testfile: &Path) -> test::TestName {
pub fn make_test_name(config: &config, testfile: &Path) -> test::TestName {
test::DynTestName(fmt!("[%s] %s",
mode_str(config.mode),
testfile.to_str()))
}

pub fn make_test_closure(config: config, testfile: &Path) -> test::TestFn {
let testfile = testfile.to_str();
test::DynTestFn(|| runtest::run(config, testfile))
pub fn make_test_closure(config: &config, testfile: &Path) -> test::TestFn {
use core::cell::Cell;
let config = Cell(copy *config);
let testfile = Cell(testfile.to_str());
test::DynTestFn(|| { runtest::run(config.take(), testfile.take()) })
}
39 changes: 22 additions & 17 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ pub fn load_props(testfile: &Path) -> TestProps {
pp_exact = parse_pp_exact(ln, testfile);
}

for parse_aux_build(ln).each |ab| {
aux_builds.push(*ab);
match parse_aux_build(ln) {
Some(ab) => { aux_builds.push(ab); }
None => {}
}

for parse_exec_env(ln).each |ee| {
exec_env.push(*ee);
match parse_exec_env(ln) {
Some(ee) => { exec_env.push(ee); }
None => {}
}

match parse_debugger_cmd(ln) {
Expand All @@ -81,7 +83,7 @@ pub fn load_props(testfile: &Path) -> TestProps {
};
}

pub fn is_test_ignored(config: config, testfile: &Path) -> bool {
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_target()) { return true; }
Expand Down Expand Up @@ -111,44 +113,47 @@ fn iter_header(testfile: &Path, it: &fn(~str) -> bool) -> bool {
return true;
}

fn parse_error_pattern(line: ~str) -> Option<~str> {
fn parse_error_pattern(line: &str) -> Option<~str> {
parse_name_value_directive(line, ~"error-pattern")
}

fn parse_aux_build(line: ~str) -> Option<~str> {
fn parse_aux_build(line: &str) -> Option<~str> {
parse_name_value_directive(line, ~"aux-build")
}

fn parse_compile_flags(line: ~str) -> Option<~str> {
fn parse_compile_flags(line: &str) -> Option<~str> {
parse_name_value_directive(line, ~"compile-flags")
}

fn parse_debugger_cmd(line: ~str) -> Option<~str> {
fn parse_debugger_cmd(line: &str) -> Option<~str> {
parse_name_value_directive(line, ~"debugger")
}

fn parse_check_line(line: ~str) -> Option<~str> {
fn parse_check_line(line: &str) -> Option<~str> {
parse_name_value_directive(line, ~"check")
}

fn parse_exec_env(line: ~str) -> Option<(~str, ~str)> {
fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
do parse_name_value_directive(line, ~"exec-env").map |nv| {
// nv is either FOO or FOO=BAR
let mut strs = ~[];
for str::each_splitn_char(*nv, '=', 1u) |s| { strs.push(s.to_owned()); }
match strs.len() {
1u => (strs[0], ~""),
2u => (strs[0], strs[1]),
1u => (strs.pop(), ~""),
2u => {
let end = strs.pop();
(strs.pop(), end)
}
n => fail!("Expected 1 or 2 strings, not %u", n)
}
}
}

fn parse_pp_exact(line: ~str, testfile: &Path) -> Option<Path> {
fn parse_pp_exact(line: &str, testfile: &Path) -> Option<Path> {
match parse_name_value_directive(line, ~"pp-exact") {
Some(s) => Some(Path(s)),
None => {
if parse_name_directive(line, ~"pp-exact") {
if parse_name_directive(line, "pp-exact") {
Some(testfile.file_path())
} else {
None
Expand All @@ -157,11 +162,11 @@ fn parse_pp_exact(line: ~str, testfile: &Path) -> Option<Path> {
}
}

fn parse_name_directive(line: ~str, directive: ~str) -> bool {
fn parse_name_directive(line: &str, directive: &str) -> bool {
str::contains(line, directive)
}

fn parse_name_value_directive(line: ~str,
fn parse_name_value_directive(line: &str,
directive: ~str) -> Option<~str> {
let keycolon = directive + ~":";
match str::find_str(line, keycolon) {
Expand Down
14 changes: 7 additions & 7 deletions src/compiletest/procsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use core::run::spawn_process;
use core::run;

#[cfg(target_os = "win32")]
fn target_env(lib_path: ~str, prog: ~str) -> ~[(~str,~str)] {
fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {

let mut env = os::env();

Expand All @@ -27,7 +27,7 @@ fn target_env(lib_path: ~str, prog: ~str) -> ~[(~str,~str)] {
if k == ~"PATH" { (~"PATH", v + ~";" + lib_path + ~";" + aux_path) }
else { (k,v) }
};
if str::ends_with(prog, ~"rustc.exe") {
if str::ends_with(prog, "rustc.exe") {
env.push((~"RUST_THREADS", ~"1"));
}
return env;
Expand All @@ -36,16 +36,16 @@ fn target_env(lib_path: ~str, prog: ~str) -> ~[(~str,~str)] {
#[cfg(target_os = "linux")]
#[cfg(target_os = "macos")]
#[cfg(target_os = "freebsd")]
fn target_env(_lib_path: ~str, _prog: ~str) -> ~[(~str,~str)] {
fn target_env(_lib_path: &str, _prog: &str) -> ~[(~str,~str)] {
~[]
}

struct Result {status: int, out: ~str, err: ~str}
pub struct Result {status: int, out: ~str, err: ~str}

// FIXME (#2659): This code is duplicated in core::run::program_output
pub fn run(lib_path: ~str,
prog: ~str,
args: ~[~str],
pub fn run(lib_path: &str,
prog: &str,
args: &[~str],
env: ~[(~str, ~str)],
input: Option<~str>) -> Result {
let pipe_in = os::pipe();
Expand Down
Loading