Skip to content
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

test: Remove all ~[T] from tests, libgetopts, compiletest, librustdoc, and libnum #12837

Closed
wants to merge 3 commits into from
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
36 changes: 18 additions & 18 deletions src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extern crate test;
extern crate getopts;

use std::os;
use std::vec_ng::Vec;
use std::io;
use std::io::fs;
use getopts::{optopt, optflag, reqopt};
Expand All @@ -39,15 +40,15 @@ pub mod errors;

pub fn main() {
let args = os::args();
let config = parse_config(args);
let config = parse_config(args.move_iter().collect());
log_config(&config);
run_tests(&config);
}

pub fn parse_config(args: ~[~str]) -> config {
pub fn parse_config(args: Vec<~str> ) -> config {

let groups : ~[getopts::OptGroup] =
~[reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"),
let groups : Vec<getopts::OptGroup> =
vec!(reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"),
reqopt("", "run-lib-path", "path to target shared libraries", "PATH"),
reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"),
optopt("", "clang-path", "path to executable for codegen tests", "PATH"),
Expand Down Expand Up @@ -75,28 +76,27 @@ pub fn parse_config(args: ~[~str]) -> config {
optopt("", "adb-path", "path to the android debugger", "PATH"),
optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH"),
optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite", "A.B"),
optflag("h", "help", "show this message"),
];
optflag("h", "help", "show this message"));

assert!(!args.is_empty());
let argv0 = args[0].clone();
let argv0 = (*args.get(0)).clone();
let args_ = args.tail();
if args[1] == ~"-h" || args[1] == ~"--help" {
if *args.get(1) == ~"-h" || *args.get(1) == ~"--help" {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
println!("{}", getopts::usage(message, groups));
println!("{}", getopts::usage(message, groups.as_slice()));
println!("");
fail!()
}

let matches =
&match getopts::getopts(args_, groups) {
&match getopts::getopts(args_, groups.as_slice()) {
Ok(m) => m,
Err(f) => fail!("{}", f.to_err_msg())
};

if matches.opt_present("h") || matches.opt_present("help") {
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
println!("{}", getopts::usage(message, groups));
println!("{}", getopts::usage(message, groups.as_slice()));
println!("");
fail!()
}
Expand All @@ -119,7 +119,7 @@ pub fn parse_config(args: ~[~str]) -> config {
run_ignored: matches.opt_present("ignored"),
filter:
if !matches.free.is_empty() {
Some(matches.free[0].clone())
Some((*matches.free.get(0)).clone())
} else {
None
},
Expand Down Expand Up @@ -235,7 +235,7 @@ pub fn run_tests(config: &config) {
// parallel (especially when we have lots and lots of child processes).
// For context, see #8904
io::test::raise_fd_limit();
let res = test::run_tests_console(&opts, tests);
let res = test::run_tests_console(&opts, tests.move_iter().collect());
match res {
Ok(true) => {}
Ok(false) => fail!("Some tests failed"),
Expand All @@ -259,10 +259,10 @@ pub fn test_opts(config: &config) -> test::TestOpts {
}
}

pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
pub fn make_tests(config: &config) -> Vec<test::TestDescAndFn> {
debug!("making tests from {}",
config.src_base.display());
let mut tests = ~[];
let mut tests = Vec::new();
let dirs = fs::readdir(&config.src_base).unwrap();
for file in dirs.iter() {
let file = file.clone();
Expand All @@ -284,10 +284,10 @@ pub 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"]
mode_pretty => vec!(~".rs"),
_ => vec!(~".rc", ~".rs")
};
let invalid_prefixes = ~[~".", ~"#", ~"~"];
let invalid_prefixes = vec!(~".", ~"#", ~"~");
let name = testfile.filename_str().unwrap();

let mut valid = false;
Expand Down
13 changes: 7 additions & 6 deletions src/compiletest/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
// except according to those terms.

use std::io::{BufferedReader, File};
use std::vec_ng::Vec;

pub struct ExpectedError { line: uint, kind: ~str, msg: ~str }

// Load any test directives embedded in the file
pub fn load_errors(testfile: &Path) -> ~[ExpectedError] {
pub fn load_errors(testfile: &Path) -> Vec<ExpectedError> {

let mut error_patterns = ~[];
let mut error_patterns = Vec::new();
let mut rdr = BufferedReader::new(File::open(testfile).unwrap());
let mut line_num = 1u;
for ln in rdr.lines() {
Expand All @@ -25,12 +26,12 @@ pub fn load_errors(testfile: &Path) -> ~[ExpectedError] {
return error_patterns;
}

fn parse_expected(line_num: uint, line: ~str) -> ~[ExpectedError] {
fn parse_expected(line_num: uint, line: ~str) -> Vec<ExpectedError> {
let line = line.trim();
let error_tag = ~"//~";
let mut idx;
match line.find_str(error_tag) {
None => return ~[],
None => return Vec::new(),
Some(nn) => { idx = (nn as uint) + error_tag.len(); }
}

Expand All @@ -57,6 +58,6 @@ fn parse_expected(line_num: uint, line: ~str) -> ~[ExpectedError] {

debug!("line={} kind={} msg={}", line_num - adjust_line, kind, msg);

return ~[ExpectedError{line: line_num - adjust_line, kind: kind,
msg: msg}];
return vec!(ExpectedError{line: line_num - adjust_line, kind: kind,
msg: msg});
}
24 changes: 13 additions & 11 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,24 @@ use common::config;
use common;
use util;

use std::vec_ng::Vec;

pub struct TestProps {
// Lines that should be expected, in order, on standard out
error_patterns: ~[~str],
error_patterns: Vec<~str> ,
// Extra flags to pass to the compiler
compile_flags: Option<~str>,
// If present, the name of a file that this test should match when
// pretty-printed
pp_exact: Option<Path>,
// Modules from aux directory that should be compiled
aux_builds: ~[~str],
aux_builds: Vec<~str> ,
// Environment settings to use during execution
exec_env: ~[(~str,~str)],
exec_env: Vec<(~str,~str)> ,
// Commands to be given to the debugger, when testing debug info
debugger_cmds: ~[~str],
debugger_cmds: Vec<~str> ,
// Lines to check if they appear in the expected debugger output
check_lines: ~[~str],
check_lines: Vec<~str> ,
// Flag to force a crate to be built with the host architecture
force_host: bool,
// Check stdout for error-pattern output as well as stderr
Expand All @@ -38,13 +40,13 @@ pub struct TestProps {

// Load any test directives embedded in the file
pub fn load_props(testfile: &Path) -> TestProps {
let mut error_patterns = ~[];
let mut aux_builds = ~[];
let mut exec_env = ~[];
let mut error_patterns = Vec::new();
let mut aux_builds = Vec::new();
let mut exec_env = Vec::new();
let mut compile_flags = None;
let mut pp_exact = None;
let mut debugger_cmds = ~[];
let mut check_lines = ~[];
let mut debugger_cmds = Vec::new();
let mut check_lines = Vec::new();
let mut force_host = false;
let mut check_stdout = false;
let mut no_prefer_dynamic = false;
Expand Down Expand Up @@ -182,7 +184,7 @@ fn parse_no_prefer_dynamic(line: &str) -> bool {
fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
parse_name_value_directive(line, ~"exec-env").map(|nv| {
// nv is either FOO or FOO=BAR
let mut strs: ~[~str] = nv.splitn('=', 1).map(|s| s.to_owned()).collect();
let mut strs: Vec<~str> = nv.splitn('=', 1).map(|s| s.to_owned()).collect();

match strs.len() {
1u => (strs.pop().unwrap(), ~""),
Expand Down
18 changes: 11 additions & 7 deletions src/compiletest/procsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
use std::os;
use std::str;
use std::io::process::{ProcessExit, Process, ProcessConfig, ProcessOutput};
use std::vec_ng::Vec;
use std::vec_ng;

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

let mut env = os::env();

Expand All @@ -35,11 +37,11 @@ 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) -> Vec<(~str,~str)> {
// Make sure we include the aux directory in the path
let aux_path = prog + ".libaux";

let mut env = os::env();
let mut env: Vec<(~str,~str)> = os::env().move_iter().collect();
let var = if cfg!(target_os = "macos") {
"DYLD_LIBRARY_PATH"
} else {
Expand All @@ -62,10 +64,11 @@ pub struct Result {status: ProcessExit, out: ~str, err: ~str}
pub fn run(lib_path: &str,
prog: &str,
args: &[~str],
env: ~[(~str, ~str)],
env: Vec<(~str, ~str)> ,
input: Option<~str>) -> Option<Result> {

let env = env + target_env(lib_path, prog);
let env = vec_ng::append(env.clone(),
target_env(lib_path, prog).as_slice());
let mut opt_process = Process::configure(ProcessConfig {
program: prog,
args: args,
Expand Down Expand Up @@ -93,10 +96,11 @@ pub fn run(lib_path: &str,
pub fn run_background(lib_path: &str,
prog: &str,
args: &[~str],
env: ~[(~str, ~str)],
env: Vec<(~str, ~str)> ,
input: Option<~str>) -> Option<Process> {

let env = env + target_env(lib_path, prog);
let env = vec_ng::append(env.clone(),
target_env(lib_path, prog).as_slice());
let opt_process = Process::configure(ProcessConfig {
program: prog,
args: args,
Expand Down
Loading