Skip to content

Commit 38b1bf8

Browse files
committed
test: Make manual changes to deal with the fallout from removal of
`~[T]` in test, libgetopts, compiletest, librustdoc, and libnum.
1 parent 7a41465 commit 38b1bf8

File tree

249 files changed

+1756
-1570
lines changed

Some content is hidden

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

249 files changed

+1756
-1570
lines changed

src/compiletest/compiletest.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ extern crate test;
1717
extern crate getopts;
1818

1919
use std::os;
20+
use std::vec_ng::Vec;
2021
use std::io;
2122
use std::io::fs;
2223
use getopts::{optopt, optflag, reqopt};
@@ -39,15 +40,15 @@ pub mod errors;
3940

4041
pub fn main() {
4142
let args = os::args();
42-
let config = parse_config(args);
43+
let config = parse_config(args.move_iter().collect());
4344
log_config(&config);
4445
run_tests(&config);
4546
}
4647

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

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

8181
assert!(!args.is_empty());
82-
let argv0 = args[0].clone();
82+
let argv0 = (*args.get(0)).clone();
8383
let args_ = args.tail();
84-
if args[1] == ~"-h" || args[1] == ~"--help" {
84+
if *args.get(1) == ~"-h" || *args.get(1) == ~"--help" {
8585
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
86-
println!("{}", getopts::usage(message, groups));
86+
println!("{}", getopts::usage(message, groups.as_slice()));
8787
println!("");
8888
fail!()
8989
}
9090

9191
let matches =
92-
&match getopts::getopts(args_, groups) {
92+
&match getopts::getopts(args_, groups.as_slice()) {
9393
Ok(m) => m,
9494
Err(f) => fail!("{}", f.to_err_msg())
9595
};
9696

9797
if matches.opt_present("h") || matches.opt_present("help") {
9898
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
99-
println!("{}", getopts::usage(message, groups));
99+
println!("{}", getopts::usage(message, groups.as_slice()));
100100
println!("");
101101
fail!()
102102
}
@@ -119,7 +119,7 @@ pub fn parse_config(args: ~[~str]) -> config {
119119
run_ignored: matches.opt_present("ignored"),
120120
filter:
121121
if !matches.free.is_empty() {
122-
Some(matches.free[0].clone())
122+
Some((*matches.free.get(0)).clone())
123123
} else {
124124
None
125125
},
@@ -235,7 +235,7 @@ pub fn run_tests(config: &config) {
235235
// parallel (especially when we have lots and lots of child processes).
236236
// For context, see #8904
237237
io::test::raise_fd_limit();
238-
let res = test::run_tests_console(&opts, tests);
238+
let res = test::run_tests_console(&opts, tests.move_iter().collect());
239239
match res {
240240
Ok(true) => {}
241241
Ok(false) => fail!("Some tests failed"),
@@ -259,10 +259,10 @@ pub fn test_opts(config: &config) -> test::TestOpts {
259259
}
260260
}
261261

262-
pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
262+
pub fn make_tests(config: &config) -> Vec<test::TestDescAndFn> {
263263
debug!("making tests from {}",
264264
config.src_base.display());
265-
let mut tests = ~[];
265+
let mut tests = Vec::new();
266266
let dirs = fs::readdir(&config.src_base).unwrap();
267267
for file in dirs.iter() {
268268
let file = file.clone();
@@ -284,10 +284,10 @@ pub fn is_test(config: &config, testfile: &Path) -> bool {
284284
// Pretty-printer does not work with .rc files yet
285285
let valid_extensions =
286286
match config.mode {
287-
mode_pretty => ~[~".rs"],
288-
_ => ~[~".rc", ~".rs"]
287+
mode_pretty => vec!(~".rs"),
288+
_ => vec!(~".rc", ~".rs")
289289
};
290-
let invalid_prefixes = ~[~".", ~"#", ~"~"];
290+
let invalid_prefixes = vec!(~".", ~"#", ~"~");
291291
let name = testfile.filename_str().unwrap();
292292

293293
let mut valid = false;

src/compiletest/errors.rs

+7-6
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

+13-11
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;
@@ -182,7 +184,7 @@ fn parse_no_prefer_dynamic(line: &str) -> bool {
182184
fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
183185
parse_name_value_directive(line, ~"exec-env").map(|nv| {
184186
// nv is either FOO or FOO=BAR
185-
let mut strs: ~[~str] = nv.splitn('=', 1).map(|s| s.to_owned()).collect();
187+
let mut strs: Vec<~str> = nv.splitn('=', 1).map(|s| s.to_owned()).collect();
186188

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

src/compiletest/procsrv.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
use std::os;
1212
use std::str;
1313
use std::io::process::{ProcessExit, Process, ProcessConfig, ProcessOutput};
14+
use std::vec_ng::Vec;
15+
use std::vec_ng;
1416

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

1820
let mut env = os::env();
1921

@@ -35,11 +37,11 @@ fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {
3537
#[cfg(target_os = "linux")]
3638
#[cfg(target_os = "macos")]
3739
#[cfg(target_os = "freebsd")]
38-
fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {
40+
fn target_env(lib_path: &str, prog: &str) -> Vec<(~str,~str)> {
3941
// Make sure we include the aux directory in the path
4042
let aux_path = prog + ".libaux";
4143

42-
let mut env = os::env();
44+
let mut env: Vec<(~str,~str)> = os::env().move_iter().collect();
4345
let var = if cfg!(target_os = "macos") {
4446
"DYLD_LIBRARY_PATH"
4547
} else {
@@ -62,10 +64,11 @@ pub struct Result {status: ProcessExit, out: ~str, err: ~str}
6264
pub fn run(lib_path: &str,
6365
prog: &str,
6466
args: &[~str],
65-
env: ~[(~str, ~str)],
67+
env: Vec<(~str, ~str)> ,
6668
input: Option<~str>) -> Option<Result> {
6769

68-
let env = env + target_env(lib_path, prog);
70+
let env = vec_ng::append(env.clone(),
71+
target_env(lib_path, prog).as_slice());
6972
let mut opt_process = Process::configure(ProcessConfig {
7073
program: prog,
7174
args: args,
@@ -93,10 +96,11 @@ pub fn run(lib_path: &str,
9396
pub fn run_background(lib_path: &str,
9497
prog: &str,
9598
args: &[~str],
96-
env: ~[(~str, ~str)],
99+
env: Vec<(~str, ~str)> ,
97100
input: Option<~str>) -> Option<Process> {
98101

99-
let env = env + target_env(lib_path, prog);
102+
let env = vec_ng::append(env.clone(),
103+
target_env(lib_path, prog).as_slice());
100104
let opt_process = Process::configure(ProcessConfig {
101105
program: prog,
102106
args: args,

0 commit comments

Comments
 (0)