More tests
This commit is contained in:
parent
3c80f7f7ae
commit
383754d2fb
@ -13,8 +13,3 @@ clap = "^2.0.0"
|
|||||||
tempdir = "^0.3.5"
|
tempdir = "^0.3.5"
|
||||||
lazy_static = "^0.2.1"
|
lazy_static = "^0.2.1"
|
||||||
brev = "^0.1.6"
|
brev = "^0.1.6"
|
||||||
|
|
||||||
[[test]]
|
|
||||||
|
|
||||||
name = "integration"
|
|
||||||
path = "src/integration.rs"
|
|
||||||
|
10
justfile
10
justfile
@ -1,12 +1,6 @@
|
|||||||
test-all: test test-integration
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
cargo test --lib
|
cargo test --lib
|
||||||
|
|
||||||
test-integration: build
|
|
||||||
cargo test --test integration
|
|
||||||
|
|
||||||
|
|
||||||
test-quine:
|
test-quine:
|
||||||
cargo run -- quine clean
|
cargo run -- quine clean
|
||||||
|
|
||||||
@ -46,12 +40,12 @@ quine: create
|
|||||||
diff tmp/gen1.c tmp/gen2.c
|
diff tmp/gen1.c tmp/gen2.c
|
||||||
@echo 'It was a quine!'
|
@echo 'It was a quine!'
|
||||||
|
|
||||||
quine-text = "'int printf(const char*, ...); int main() { char *s = \"int printf(const char*, ...); int main() { char *s = %c%s%c; printf(s, 34, s, 34); return 0; }\"; printf(s, 34, s, 34); return 0; }'"
|
quine-text = "int printf(const char*, ...); int main() { char *s = \"int printf(const char*, ...); int main() { char *s = %c%s%c; printf(s, 34, s, 34); return 0; }\"; printf(s, 34, s, 34); return 0; }"
|
||||||
|
|
||||||
# create our quine
|
# create our quine
|
||||||
create:
|
create:
|
||||||
mkdir -p tmp
|
mkdir -p tmp
|
||||||
echo {{quine-text}} > tmp/gen0.c
|
echo '{{quine-text}}' > tmp/gen0.c
|
||||||
|
|
||||||
# clean up
|
# clean up
|
||||||
clean:
|
clean:
|
||||||
|
3
notes
3
notes
@ -2,9 +2,6 @@ notes
|
|||||||
-----
|
-----
|
||||||
|
|
||||||
- integration testing
|
- integration testing
|
||||||
. get value of variable --evaluate --variable
|
|
||||||
. run app with command line options and test full output (stderr and stdout)
|
|
||||||
. exercise all features and all command line options
|
|
||||||
. underline problem token in error messages
|
. underline problem token in error messages
|
||||||
|
|
||||||
- figure out argument passing:
|
- figure out argument passing:
|
||||||
|
@ -2,7 +2,7 @@ extern crate tempdir;
|
|||||||
extern crate brev;
|
extern crate brev;
|
||||||
|
|
||||||
use tempdir::TempDir;
|
use tempdir::TempDir;
|
||||||
use std::process::Command;
|
use super::std::process::Command;
|
||||||
|
|
||||||
fn integration_test(
|
fn integration_test(
|
||||||
name: &str,
|
name: &str,
|
||||||
@ -17,7 +17,7 @@ fn integration_test(
|
|||||||
let mut path = tmp.path().to_path_buf();
|
let mut path = tmp.path().to_path_buf();
|
||||||
path.push("justfile");
|
path.push("justfile");
|
||||||
brev::dump(path, justfile);
|
brev::dump(path, justfile);
|
||||||
let mut binary = std::env::current_dir().unwrap();
|
let mut binary = super::std::env::current_dir().unwrap();
|
||||||
binary.push("./target/debug/j");
|
binary.push("./target/debug/j");
|
||||||
let output = Command::new(binary)
|
let output = Command::new(binary)
|
||||||
.current_dir(tmp.path())
|
.current_dir(tmp.path())
|
||||||
@ -33,15 +33,15 @@ fn integration_test(
|
|||||||
failure = true;
|
failure = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let stdout = std::str::from_utf8(&output.stdout).unwrap();
|
let stdout = super::std::str::from_utf8(&output.stdout).unwrap();
|
||||||
if stdout != expected_stdout {
|
if stdout != expected_stdout {
|
||||||
println!("bad stdout: {:?} != {:?}", stdout, expected_stdout);
|
println!("bad stdout:\ngot:\n{}\n\nexpected:\n{}", stdout, expected_stdout);
|
||||||
failure = true;
|
failure = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let stderr = std::str::from_utf8(&output.stderr).unwrap();
|
let stderr = super::std::str::from_utf8(&output.stderr).unwrap();
|
||||||
if stderr != expected_stderr {
|
if stderr != expected_stderr {
|
||||||
println!("bad stderr: {:?} != {:?}", stderr, expected_stderr);
|
println!("bad stdout:\ngot:\n{}\n\nexpected:\n{}", stderr, expected_stderr);
|
||||||
failure = true;
|
failure = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,6 +160,29 @@ recipe:
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn debug() {
|
||||||
|
let text =
|
||||||
|
r#"hello = "foo"
|
||||||
|
bar = hello + hello
|
||||||
|
recipe:
|
||||||
|
echo {{hello + "bar" + bar}}"#;
|
||||||
|
integration_test(
|
||||||
|
"debug",
|
||||||
|
&["--debug"],
|
||||||
|
text,
|
||||||
|
0,
|
||||||
|
r#"bar = hello + hello # "foofoo"
|
||||||
|
|
||||||
|
hello = "foo" # "foo"
|
||||||
|
|
||||||
|
recipe:
|
||||||
|
echo {{hello + "bar" + bar # "foobarfoofoo"}}
|
||||||
|
"#,
|
||||||
|
"",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn status() {
|
fn status() {
|
||||||
let text =
|
let text =
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod unit;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod integration;
|
||||||
|
|
||||||
mod app;
|
mod app;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user