From be4fba34cb4bd74ca72d2fa2ca41c8a640709548 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 15 Apr 2021 22:12:08 -0600 Subject: add a test for not rebuilding up-to-date targets --- tests/update_logic.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/update_logic.rs (limited to 'tests') diff --git a/tests/update_logic.rs b/tests/update_logic.rs new file mode 100644 index 0000000..2b74606 --- /dev/null +++ b/tests/update_logic.rs @@ -0,0 +1,48 @@ +use std::fs; +use std::path::Path; +use std::process::{Command, Output}; + +use eyre::{Result, WrapErr}; + +type R = Result<()>; + +fn make(dir: impl AsRef) -> Result { + Command::new(env!("CARGO_BIN_EXE_makers")) + .current_dir(dir) + .output() + .wrap_err("") +} + +#[test] +fn basic_test() -> R { + let dir = tempfile::tempdir()?; + let file = " +based-on-what: based-on-this +\techo hi + "; + fs::write(dir.path().join("Makefile"), file)?; + let result = make(&dir)?; + assert!(!result.status.success()); + assert!(String::from_utf8(result.stderr)?.contains("based-on-this")); + + fs::write(dir.path().join("based-on-this"), "")?; + let result = make(&dir)?; + assert!(result.status.success()); + assert!(String::from_utf8(result.stdout)?.contains("echo hi")); + + let result = make(&dir)?; + assert!(result.status.success()); + assert!(String::from_utf8(result.stdout)?.contains("echo hi")); + + fs::write(dir.path().join("based-on-what"), "")?; + let result = make(&dir)?; + assert!(result.status.success()); + assert!(!String::from_utf8(result.stdout)?.contains("echo hi")); + + fs::write(dir.path().join("based-on-this"), "")?; + let result = make(&dir)?; + assert!(result.status.success()); + assert!(String::from_utf8(result.stdout)?.contains("echo hi")); + + Ok(()) +} -- cgit v1.2.3