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

API conventions cleanup #16436

Closed
wants to merge 6 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.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 11 additions & 11 deletions src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
}

fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
Path::new(m.opt_str(nm).unwrap())
Path::new(m.opt_str(nm).assert())
}

let filter = if !matches.free.is_empty() {
Expand All @@ -129,21 +129,21 @@ pub fn parse_config(args: Vec<String> ) -> Config {
};

Config {
compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
run_lib_path: matches.opt_str("run-lib-path").unwrap(),
compile_lib_path: matches.opt_str("compile-lib-path").assert(),
run_lib_path: matches.opt_str("run-lib-path").assert(),
rustc_path: opt_path(matches, "rustc-path"),
clang_path: matches.opt_str("clang-path").map(|s| Path::new(s)),
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| Path::new(s)),
src_base: opt_path(matches, "src-base"),
build_base: opt_path(matches, "build-base"),
aux_base: opt_path(matches, "aux-base"),
stage_id: matches.opt_str("stage-id").unwrap(),
stage_id: matches.opt_str("stage-id").assert(),
mode: FromStr::from_str(matches.opt_str("mode")
.unwrap()
.assert()
.as_slice()).expect("invalid mode"),
run_ignored: matches.opt_present("ignored"),
filter: filter,
cfail_regex: Regex::new(errors::EXPECTED_PATTERN).unwrap(),
cfail_regex: Regex::new(errors::EXPECTED_PATTERN).assert(),
logfile: matches.opt_str("logfile").map(|s| Path::new(s)),
save_metrics: matches.opt_str("save-metrics").map(|s| Path::new(s)),
ratchet_metrics:
Expand Down Expand Up @@ -257,7 +257,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.move_iter().collect());
let res = test::run_tests_console(&opts, tests.iter_owned().collect());
match res {
Ok(true) => {}
Ok(false) => fail!("Some tests failed"),
Expand Down Expand Up @@ -290,7 +290,7 @@ pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
debug!("making tests from {}",
config.src_base.display());
let mut tests = Vec::new();
let dirs = fs::readdir(&config.src_base).unwrap();
let dirs = fs::readdir(&config.src_base).assert();
for file in dirs.iter() {
let file = file.clone();
debug!("inspecting file {}", file.display());
Expand All @@ -315,7 +315,7 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
_ => vec!(".rc".to_string(), ".rs".to_string())
};
let invalid_prefixes = vec!(".".to_string(), "#".to_string(), "~".to_string());
let name = testfile.filename_str().unwrap();
let name = testfile.filename_str().assert();

let mut valid = false;

Expand Down Expand Up @@ -362,7 +362,7 @@ pub fn make_test_name(config: &Config, testfile: &Path) -> test::TestName {
pub fn make_test_closure(config: &Config, testfile: &Path) -> test::TestFn {
let config = (*config).clone();
// FIXME (#9639): This needs to handle non-utf8 paths
let testfile = testfile.as_str().unwrap().to_string();
let testfile = testfile.as_str().assert().to_string();
test::DynTestFn(proc() {
runtest::run(config, testfile)
})
Expand All @@ -371,7 +371,7 @@ pub fn make_test_closure(config: &Config, testfile: &Path) -> test::TestFn {
pub fn make_metrics_test_closure(config: &Config, testfile: &Path) -> test::TestFn {
let config = (*config).clone();
// FIXME (#9639): This needs to handle non-utf8 paths
let testfile = testfile.as_str().unwrap().to_string();
let testfile = testfile.as_str().assert().to_string();
test::DynMetricFn(proc(mm) {
runtest::run_metrics(config, testfile, mm)
})
Expand Down
4 changes: 2 additions & 2 deletions src/compiletest/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ pub static EXPECTED_PATTERN : &'static str = r"//~(?P<adjusts>\^*)\s*(?P<kind>\S

// Load any test directives embedded in the file
pub fn load_errors(re: &Regex, testfile: &Path) -> Vec<ExpectedError> {
let mut rdr = BufferedReader::new(File::open(testfile).unwrap());
let mut rdr = BufferedReader::new(File::open(testfile).assert());

rdr.lines().enumerate().filter_map(|(line_no, ln)| {
parse_expected(line_no + 1, ln.unwrap().as_slice(), re)
parse_expected(line_no + 1, ln.assert().as_slice(), re)
}).collect()
}

Expand Down
12 changes: 6 additions & 6 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
}
fn ignore_stage(config: &Config) -> String {
format!("ignore-{}",
config.stage_id.as_slice().split('-').next().unwrap())
config.stage_id.as_slice().split('-').next().assert())
}

let val = iter_header(testfile, |ln| {
Expand All @@ -167,12 +167,12 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
fn iter_header(testfile: &Path, it: |&str| -> bool) -> bool {
use std::io::{BufferedReader, File};

let mut rdr = BufferedReader::new(File::open(testfile).unwrap());
let mut rdr = BufferedReader::new(File::open(testfile).assert());
for ln in rdr.lines() {
// Assume that any directives will be found before the first
// module or function. This doesn't seem to be an optimization
// with a warm page cache. Maybe with a cold one.
let ln = ln.unwrap();
let ln = ln.assert();
if ln.as_slice().starts_with("fn") ||
ln.as_slice().starts_with("mod") {
return true;
Expand Down Expand Up @@ -238,10 +238,10 @@ fn parse_exec_env(line: &str) -> Option<(String, String)> {
.collect();

match strs.len() {
1u => (strs.pop().unwrap(), "".to_string()),
1u => (strs.pop().assert(), "".to_string()),
2u => {
let end = strs.pop().unwrap();
(strs.pop().unwrap(), end)
let end = strs.pop().assert();
(strs.pop().assert(), end)
}
n => fail!("Expected 1 or 2 strings, not {}", n)
}
Expand Down
16 changes: 8 additions & 8 deletions src/compiletest/procsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn add_target_env(cmd: &mut Command, lib_path: &str, aux_path: Option<&str>) {
// Add the new dylib search path var
let var = DynamicLibrary::envvar();
let newpath = DynamicLibrary::create_path(path.as_slice());
let newpath = String::from_utf8(newpath).unwrap();
let newpath = String::from_utf8(newpath).assert();
cmd.env(var.to_string(), newpath);
}

Expand All @@ -40,22 +40,22 @@ pub fn run(lib_path: &str,
let mut cmd = Command::new(prog);
cmd.args(args);
add_target_env(&mut cmd, lib_path, aux_path);
for (key, val) in env.move_iter() {
for (key, val) in env.iter_owned() {
cmd.env(key, val);
}

match cmd.spawn() {
Ok(mut process) => {
for input in input.iter() {
process.stdin.get_mut_ref().write(input.as_bytes()).unwrap();
process.stdin.as_mut().assert().write(input.as_bytes()).assert();
}
let ProcessOutput { status, output, error } =
process.wait_with_output().unwrap();
process.wait_with_output().assert();

Some(Result {
status: status,
out: String::from_utf8(output).unwrap(),
err: String::from_utf8(error).unwrap()
out: String::from_utf8(output).assert(),
err: String::from_utf8(error).assert()
})
},
Err(..) => None
Expand All @@ -72,14 +72,14 @@ pub fn run_background(lib_path: &str,
let mut cmd = Command::new(prog);
cmd.args(args);
add_target_env(&mut cmd, lib_path, aux_path);
for (key, val) in env.move_iter() {
for (key, val) in env.iter_owned() {
cmd.env(key, val);
}

match cmd.spawn() {
Ok(mut process) => {
for input in input.iter() {
process.stdin.get_mut_ref().write(input.as_bytes()).unwrap();
process.stdin.as_mut().assert().write(input.as_bytes()).assert();
}

Some(process)
Expand Down