Algo de formato
This commit is contained in:
parent
04565cb844
commit
f88b2601d4
|
@ -1,3 +1,3 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
std::process::abort();
|
std::process::abort();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
std::process::exit(0);
|
std::process::exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,18 +2,18 @@ use assert_cmd::Command;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn runs() {
|
fn runs() {
|
||||||
let mut cmd = Command::cargo_bin("hello").unwrap();
|
let mut cmd = Command::cargo_bin("hello").unwrap();
|
||||||
cmd.assert().success().stdout("Hello, world!\n");
|
cmd.assert().success().stdout("Hello, world!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn true_ok() {
|
fn true_ok() {
|
||||||
let mut cmd = Command::cargo_bin("true").unwrap();
|
let mut cmd = Command::cargo_bin("true").unwrap();
|
||||||
cmd.assert().success();
|
cmd.assert().success();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn false_not_ok() {
|
fn false_not_ok() {
|
||||||
let mut cmd = Command::cargo_bin("false").unwrap();
|
let mut cmd = Command::cargo_bin("false").unwrap();
|
||||||
cmd.assert().failure();
|
cmd.assert().failure();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,10 @@ fn main() {
|
||||||
.get_matches();
|
.get_matches();
|
||||||
// OJO: unwrap es seguro de llamar porque 'text' está forzado en tener al menos un valor
|
// OJO: unwrap es seguro de llamar porque 'text' está forzado en tener al menos un valor
|
||||||
let text = matches.values_of_lossy("text").unwrap();
|
let text = matches.values_of_lossy("text").unwrap();
|
||||||
let ending = if matches.is_present("omit_newline") { "" } else { "\n"};
|
let ending = if matches.is_present("omit_newline") {
|
||||||
|
""
|
||||||
|
} else {
|
||||||
|
"\n"
|
||||||
|
};
|
||||||
print!("{}{}", text.join(" "), ending);
|
print!("{}{}", text.join(" "), ending);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
use std::fs;
|
|
||||||
use assert_cmd::Command;
|
use assert_cmd::Command;
|
||||||
use predicates::prelude::*;
|
use predicates::prelude::*;
|
||||||
|
use std::fs;
|
||||||
|
|
||||||
type TestResult = Result<(), Box<dyn std::error::Error>>;
|
type TestResult = Result<(), Box<dyn std::error::Error>>;
|
||||||
|
|
||||||
fn run(args: &[&str], expected_file: &str) -> TestResult {
|
fn run(args: &[&str], expected_file: &str) -> TestResult {
|
||||||
let expected = fs::read_to_string(format!("{}{}", "tests/expected/", expected_file))?;
|
let expected = fs::read_to_string(format!("{}{}", "tests/expected/", expected_file))?;
|
||||||
Command::cargo_bin("echor")?.args(args).assert().success().stdout(expected);
|
Command::cargo_bin("echor")?
|
||||||
|
.args(args)
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout(expected);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue