committed by
Dan Gohman
parent
8fb681b86d
commit
90756a8a01
8
cranelift/src/clif-util.rs
Normal file → Executable file
8
cranelift/src/clif-util.rs
Normal file → Executable file
@@ -47,17 +47,17 @@ pub type CommandResult = Result<(), String>;
|
|||||||
|
|
||||||
fn add_input_file_arg<'a>() -> clap::Arg<'a, 'a> {
|
fn add_input_file_arg<'a>() -> clap::Arg<'a, 'a> {
|
||||||
Arg::with_name("file")
|
Arg::with_name("file")
|
||||||
.required(true)
|
.default_value("-")
|
||||||
.multiple(true)
|
.multiple(true)
|
||||||
.value_name("file")
|
.value_name("file")
|
||||||
.help("Specify file(s) to be used for test")
|
.help("Specify file(s) to be used for test. Defaults to reading from stdin.")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_single_input_file_arg<'a>() -> clap::Arg<'a, 'a> {
|
fn add_single_input_file_arg<'a>() -> clap::Arg<'a, 'a> {
|
||||||
Arg::with_name("single-file")
|
Arg::with_name("single-file")
|
||||||
.required(true)
|
.default_value("-")
|
||||||
.value_name("single-file")
|
.value_name("single-file")
|
||||||
.help("Specify a file to be used")
|
.help("Specify a file to be used. Defaults to reading from stdin.")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_pass_arg<'a>() -> clap::Arg<'a, 'a> {
|
fn add_pass_arg<'a>() -> clap::Arg<'a, 'a> {
|
||||||
|
|||||||
@@ -12,17 +12,29 @@ use target_lexicon::Triple;
|
|||||||
|
|
||||||
/// Read an entire file into a string.
|
/// Read an entire file into a string.
|
||||||
pub fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
|
pub fn read_to_string<P: AsRef<Path>>(path: P) -> io::Result<String> {
|
||||||
let mut file = File::open(path)?;
|
|
||||||
let mut buffer = String::new();
|
let mut buffer = String::new();
|
||||||
|
if path.as_ref() == Path::new("-") {
|
||||||
|
let stdin = io::stdin();
|
||||||
|
let mut stdin = stdin.lock();
|
||||||
|
stdin.read_to_string(&mut buffer)?;
|
||||||
|
} else {
|
||||||
|
let mut file = File::open(path)?;
|
||||||
file.read_to_string(&mut buffer)?;
|
file.read_to_string(&mut buffer)?;
|
||||||
|
}
|
||||||
Ok(buffer)
|
Ok(buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read an entire file into a vector of bytes.
|
/// Read an entire file into a vector of bytes.
|
||||||
pub fn read_to_end<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
|
pub fn read_to_end<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
|
||||||
let mut file = File::open(path)?;
|
|
||||||
let mut buffer = Vec::new();
|
let mut buffer = Vec::new();
|
||||||
|
if path.as_ref() == Path::new("-") {
|
||||||
|
let stdin = io::stdin();
|
||||||
|
let mut stdin = stdin.lock();
|
||||||
|
stdin.read_to_end(&mut buffer)?;
|
||||||
|
} else {
|
||||||
|
let mut file = File::open(path)?;
|
||||||
file.read_to_end(&mut buffer)?;
|
file.read_to_end(&mut buffer)?;
|
||||||
|
}
|
||||||
Ok(buffer)
|
Ok(buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ pub fn run_passes(verbose: bool, passes: &[String], target: &str, file: &String)
|
|||||||
let mut runner = TestRunner::new(verbose);
|
let mut runner = TestRunner::new(verbose);
|
||||||
|
|
||||||
let path = Path::new(file);
|
let path = Path::new(file);
|
||||||
if path.is_file() {
|
if path == Path::new("-") || path.is_file() {
|
||||||
runner.push_test(path);
|
runner.push_test(path);
|
||||||
} else {
|
} else {
|
||||||
runner.push_dir(path);
|
runner.push_dir(path);
|
||||||
|
|||||||
Reference in New Issue
Block a user