Skip to content

Commit af79a5a

Browse files
pcwaltonhuonw
authored andcommitted
test: Make manual changes to deal with the fallout from removal of
`~[T]` in test, libgetopts, compiletest, librustdoc, and libnum.
1 parent 579eb24 commit af79a5a

File tree

236 files changed

+1435
-1311
lines changed

Some content is hidden

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

236 files changed

+1435
-1311
lines changed

src/compiletest/compiletest.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extern crate getopts;
2121
extern crate log;
2222

2323
use std::os;
24+
use std::vec_ng::Vec;
2425
use std::io;
2526
use std::io::fs;
2627
use getopts::{optopt, optflag, reqopt};
@@ -43,15 +44,15 @@ pub mod errors;
4344

4445
pub fn main() {
4546
let args = os::args();
46-
let config = parse_config(args);
47+
let config = parse_config(args.move_iter().collect());
4748
log_config(&config);
4849
run_tests(&config);
4950
}
5051

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

53-
let groups : ~[getopts::OptGroup] =
54-
~[reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"),
54+
let groups : Vec<getopts::OptGroup> =
55+
vec!(reqopt("", "compile-lib-path", "path to host shared libraries", "PATH"),
5556
reqopt("", "run-lib-path", "path to target shared libraries", "PATH"),
5657
reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"),
5758
optopt("", "clang-path", "path to executable for codegen tests", "PATH"),
@@ -79,28 +80,27 @@ pub fn parse_config(args: ~[~str]) -> config {
7980
optopt("", "adb-path", "path to the android debugger", "PATH"),
8081
optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH"),
8182
optopt("", "test-shard", "run shard A, of B shards, worth of the testsuite", "A.B"),
82-
optflag("h", "help", "show this message"),
83-
];
83+
optflag("h", "help", "show this message"));
8484

8585
assert!(!args.is_empty());
86-
let argv0 = args[0].clone();
86+
let argv0 = (*args.get(0)).clone();
8787
let args_ = args.tail();
88-
if args[1] == ~"-h" || args[1] == ~"--help" {
88+
if *args.get(1) == ~"-h" || *args.get(1) == ~"--help" {
8989
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
90-
println!("{}", getopts::usage(message, groups));
90+
println!("{}", getopts::usage(message, groups.as_slice()));
9191
println!("");
9292
fail!()
9393
}
9494

9595
let matches =
96-
&match getopts::getopts(args_, groups) {
96+
&match getopts::getopts(args_, groups.as_slice()) {
9797
Ok(m) => m,
9898
Err(f) => fail!("{}", f.to_err_msg())
9999
};
100100

101101
if matches.opt_present("h") || matches.opt_present("help") {
102102
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
103-
println!("{}", getopts::usage(message, groups));
103+
println!("{}", getopts::usage(message, groups.as_slice()));
104104
println!("");
105105
fail!()
106106
}
@@ -123,7 +123,7 @@ pub fn parse_config(args: ~[~str]) -> config {
123123
run_ignored: matches.opt_present("ignored"),
124124
filter:
125125
if !matches.free.is_empty() {
126-
Some(matches.free[0].clone())
126+
Some((*matches.free.get(0)).clone())
127127
} else {
128128
None
129129
},
@@ -239,7 +239,7 @@ pub fn run_tests(config: &config) {
239239
// parallel (especially when we have lots and lots of child processes).
240240
// For context, see #8904
241241
io::test::raise_fd_limit();
242-
let res = test::run_tests_console(&opts, tests);
242+
let res = test::run_tests_console(&opts, tests.move_iter().collect());
243243
match res {
244244
Ok(true) => {}
245245
Ok(false) => fail!("Some tests failed"),
@@ -263,10 +263,10 @@ pub fn test_opts(config: &config) -> test::TestOpts {
263263
}
264264
}
265265

266-
pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
266+
pub fn make_tests(config: &config) -> Vec<test::TestDescAndFn> {
267267
debug!("making tests from {}",
268268
config.src_base.display());
269-
let mut tests = ~[];
269+
let mut tests = Vec::new();
270270
let dirs = fs::readdir(&config.src_base).unwrap();
271271
for file in dirs.iter() {
272272
let file = file.clone();
@@ -288,10 +288,10 @@ pub fn is_test(config: &config, testfile: &Path) -> bool {
288288
// Pretty-printer does not work with .rc files yet
289289
let valid_extensions =
290290
match config.mode {
291-
mode_pretty => ~[~".rs"],
292-
_ => ~[~".rc", ~".rs"]
291+
mode_pretty => vec!(~".rs"),
292+
_ => vec!(~".rc", ~".rs")
293293
};
294-
let invalid_prefixes = ~[~".", ~"#", ~"~"];
294+
let invalid_prefixes = vec!(~".", ~"#", ~"~");
295295
let name = testfile.filename_str().unwrap();
296296

297297
let mut valid = false;

src/compiletest/errors.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
// except according to those terms.
1010

1111
use std::io::{BufferedReader, File};
12+
use std::vec_ng::Vec;
1213

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

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

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

28-
fn parse_expected(line_num: uint, line: ~str) -> ~[ExpectedError] {
29+
fn parse_expected(line_num: uint, line: ~str) -> Vec<ExpectedError> {
2930
let line = line.trim();
3031
let error_tag = ~"//~";
3132
let mut idx;
3233
match line.find_str(error_tag) {
33-
None => return ~[],
34+
None => return Vec::new(),
3435
Some(nn) => { idx = (nn as uint) + error_tag.len(); }
3536
}
3637

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

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

60-
return ~[ExpectedError{line: line_num - adjust_line, kind: kind,
61-
msg: msg}];
61+
return vec!(ExpectedError{line: line_num - adjust_line, kind: kind,
62+
msg: msg});
6263
}

src/compiletest/header.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,24 @@ use common::config;
1212
use common;
1313
use util;
1414

15+
use std::vec_ng::Vec;
16+
1517
pub struct TestProps {
1618
// Lines that should be expected, in order, on standard out
17-
error_patterns: ~[~str],
19+
error_patterns: Vec<~str> ,
1820
// Extra flags to pass to the compiler
1921
compile_flags: Option<~str>,
2022
// If present, the name of a file that this test should match when
2123
// pretty-printed
2224
pp_exact: Option<Path>,
2325
// Modules from aux directory that should be compiled
24-
aux_builds: ~[~str],
26+
aux_builds: Vec<~str> ,
2527
// Environment settings to use during execution
26-
exec_env: ~[(~str,~str)],
28+
exec_env: Vec<(~str,~str)> ,
2729
// Commands to be given to the debugger, when testing debug info
28-
debugger_cmds: ~[~str],
30+
debugger_cmds: Vec<~str> ,
2931
// Lines to check if they appear in the expected debugger output
30-
check_lines: ~[~str],
32+
check_lines: Vec<~str> ,
3133
// Flag to force a crate to be built with the host architecture
3234
force_host: bool,
3335
// Check stdout for error-pattern output as well as stderr
@@ -38,13 +40,13 @@ pub struct TestProps {
3840

3941
// Load any test directives embedded in the file
4042
pub fn load_props(testfile: &Path) -> TestProps {
41-
let mut error_patterns = ~[];
42-
let mut aux_builds = ~[];
43-
let mut exec_env = ~[];
43+
let mut error_patterns = Vec::new();
44+
let mut aux_builds = Vec::new();
45+
let mut exec_env = Vec::new();
4446
let mut compile_flags = None;
4547
let mut pp_exact = None;
46-
let mut debugger_cmds = ~[];
47-
let mut check_lines = ~[];
48+
let mut debugger_cmds = Vec::new();
49+
let mut check_lines = Vec::new();
4850
let mut force_host = false;
4951
let mut check_stdout = false;
5052
let mut no_prefer_dynamic = false;
@@ -183,7 +185,7 @@ fn parse_no_prefer_dynamic(line: &str) -> bool {
183185
fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
184186
parse_name_value_directive(line, ~"exec-env").map(|nv| {
185187
// nv is either FOO or FOO=BAR
186-
let mut strs: ~[~str] = nv.splitn('=', 1).map(|s| s.to_owned()).collect();
188+
let mut strs: Vec<~str> = nv.splitn('=', 1).map(|s| s.to_owned()).collect();
187189

188190
match strs.len() {
189191
1u => (strs.pop().unwrap(), ~""),

src/compiletest/procsrv.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
use std::os;
1212
use std::str;
1313
use std::io::process::{ProcessExit, Process, ProcessConfig, ProcessOutput};
14+
use std::vec;
1415

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

1819
let mut env = os::env();
1920

@@ -35,11 +36,11 @@ fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {
3536
#[cfg(target_os = "linux")]
3637
#[cfg(target_os = "macos")]
3738
#[cfg(target_os = "freebsd")]
38-
fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {
39+
fn target_env(lib_path: &str, prog: &str) -> Vec<(~str,~str)> {
3940
// Make sure we include the aux directory in the path
4041
let aux_path = prog + ".libaux";
4142

42-
let mut env = os::env();
43+
let mut env: Vec<(~str,~str)> = os::env().move_iter().collect();
4344
let var = if cfg!(target_os = "macos") {
4445
"DYLD_LIBRARY_PATH"
4546
} else {
@@ -62,10 +63,11 @@ pub struct Result {status: ProcessExit, out: ~str, err: ~str}
6263
pub fn run(lib_path: &str,
6364
prog: &str,
6465
args: &[~str],
65-
env: ~[(~str, ~str)],
66+
env: Vec<(~str, ~str)> ,
6667
input: Option<~str>) -> Option<Result> {
6768

68-
let env = env + target_env(lib_path, prog);
69+
let env = vec::append(env.clone(),
70+
target_env(lib_path, prog).as_slice());
6971
let mut opt_process = Process::configure(ProcessConfig {
7072
program: prog,
7173
args: args,
@@ -93,10 +95,11 @@ pub fn run(lib_path: &str,
9395
pub fn run_background(lib_path: &str,
9496
prog: &str,
9597
args: &[~str],
96-
env: ~[(~str, ~str)],
98+
env: Vec<(~str, ~str)> ,
9799
input: Option<~str>) -> Option<Process> {
98100

99-
let env = env + target_env(lib_path, prog);
101+
let env = vec::append(env.clone(),
102+
target_env(lib_path, prog).as_slice());
100103
let opt_process = Process::configure(ProcessConfig {
101104
program: prog,
102105
args: args,

0 commit comments

Comments
 (0)