Skip to content

Commit 7b957a8

Browse files
committed
auto merge of #13056 : huonw/rust/devecing-tests, r=pnkfelix
test: Remove all `~[T]` from tests, libgetopts, compiletest, librustdoc, and libnum And most from libtest, libflate, and adds `deny(deprecated_owned_vector)`s to the smaller modules with that have zero (or nearly zero) uses of `~[T]`. Revival of #12837
2 parents a0f943c + 40a52c0 commit 7b957a8

File tree

298 files changed

+1897
-2027
lines changed

Some content is hidden

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

298 files changed

+1897
-2027
lines changed

src/compiletest/compiletest.rs

+17-18
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ pub mod errors;
4343

4444
pub fn main() {
4545
let args = os::args();
46-
let config = parse_config(args);
46+
let config = parse_config(args.move_iter().collect());
4747
log_config(&config);
4848
run_tests(&config);
4949
}
5050

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

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

8584
assert!(!args.is_empty());
86-
let argv0 = args[0].clone();
85+
let argv0 = (*args.get(0)).clone();
8786
let args_ = args.tail();
88-
if args[1] == ~"-h" || args[1] == ~"--help" {
87+
if *args.get(1) == ~"-h" || *args.get(1) == ~"--help" {
8988
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
90-
println!("{}", getopts::usage(message, groups));
89+
println!("{}", getopts::usage(message, groups.as_slice()));
9190
println!("");
9291
fail!()
9392
}
9493

9594
let matches =
96-
&match getopts::getopts(args_, groups) {
95+
&match getopts::getopts(args_, groups.as_slice()) {
9796
Ok(m) => m,
9897
Err(f) => fail!("{}", f.to_err_msg())
9998
};
10099

101100
if matches.opt_present("h") || matches.opt_present("help") {
102101
let message = format!("Usage: {} [OPTIONS] [TESTNAME...]", argv0);
103-
println!("{}", getopts::usage(message, groups));
102+
println!("{}", getopts::usage(message, groups.as_slice()));
104103
println!("");
105104
fail!()
106105
}
@@ -123,7 +122,7 @@ pub fn parse_config(args: ~[~str]) -> config {
123122
run_ignored: matches.opt_present("ignored"),
124123
filter:
125124
if !matches.free.is_empty() {
126-
Some(matches.free[0].clone())
125+
Some((*matches.free.get(0)).clone())
127126
} else {
128127
None
129128
},
@@ -239,7 +238,7 @@ pub fn run_tests(config: &config) {
239238
// parallel (especially when we have lots and lots of child processes).
240239
// For context, see #8904
241240
io::test::raise_fd_limit();
242-
let res = test::run_tests_console(&opts, tests);
241+
let res = test::run_tests_console(&opts, tests.move_iter().collect());
243242
match res {
244243
Ok(true) => {}
245244
Ok(false) => fail!("Some tests failed"),
@@ -263,10 +262,10 @@ pub fn test_opts(config: &config) -> test::TestOpts {
263262
}
264263
}
265264

266-
pub fn make_tests(config: &config) -> ~[test::TestDescAndFn] {
265+
pub fn make_tests(config: &config) -> Vec<test::TestDescAndFn> {
267266
debug!("making tests from {}",
268267
config.src_base.display());
269-
let mut tests = ~[];
268+
let mut tests = Vec::new();
270269
let dirs = fs::readdir(&config.src_base).unwrap();
271270
for file in dirs.iter() {
272271
let file = file.clone();
@@ -288,10 +287,10 @@ pub fn is_test(config: &config, testfile: &Path) -> bool {
288287
// Pretty-printer does not work with .rc files yet
289288
let valid_extensions =
290289
match config.mode {
291-
mode_pretty => ~[~".rs"],
292-
_ => ~[~".rc", ~".rs"]
290+
mode_pretty => vec!(~".rs"),
291+
_ => vec!(~".rc", ~".rs")
293292
};
294-
let invalid_prefixes = ~[~".", ~"#", ~"~"];
293+
let invalid_prefixes = vec!(~".", ~"#", ~"~");
295294
let name = testfile.filename_str().unwrap();
296295

297296
let mut valid = false;

src/compiletest/errors.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ use std::io::{BufferedReader, File};
1313
pub struct ExpectedError { line: uint, kind: ~str, msg: ~str }
1414

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

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

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

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

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

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

src/compiletest/header.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ use util;
1414

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

3939
// Load any test directives embedded in the file
4040
pub fn load_props(testfile: &Path) -> TestProps {
41-
let mut error_patterns = ~[];
42-
let mut aux_builds = ~[];
43-
let mut exec_env = ~[];
41+
let mut error_patterns = Vec::new();
42+
let mut aux_builds = Vec::new();
43+
let mut exec_env = Vec::new();
4444
let mut compile_flags = None;
4545
let mut pp_exact = None;
46-
let mut debugger_cmds = ~[];
47-
let mut check_lines = ~[];
46+
let mut debugger_cmds = Vec::new();
47+
let mut check_lines = Vec::new();
4848
let mut force_host = false;
4949
let mut check_stdout = false;
5050
let mut no_prefer_dynamic = false;
@@ -183,7 +183,7 @@ fn parse_no_prefer_dynamic(line: &str) -> bool {
183183
fn parse_exec_env(line: &str) -> Option<(~str, ~str)> {
184184
parse_name_value_directive(line, ~"exec-env").map(|nv| {
185185
// nv is either FOO or FOO=BAR
186-
let mut strs: ~[~str] = nv.splitn('=', 1).map(|s| s.to_owned()).collect();
186+
let mut strs: Vec<~str> = nv.splitn('=', 1).map(|s| s.to_owned()).collect();
187187

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

src/compiletest/procsrv.rs

+10-7
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)