aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-04-15 22:12:08 -0600
committerMelody Horn <melody@boringcactus.com>2021-04-15 22:12:08 -0600
commitbe4fba34cb4bd74ca72d2fa2ca41c8a640709548 (patch)
treee8cf108834a98ce07595a1f52ac468c173884546
parentdc9f24cd5b5cd9ae3e0aa86e661fc0cf30ac63ef (diff)
downloadmakers-be4fba34cb4bd74ca72d2fa2ca41c8a640709548.tar.gz
makers-be4fba34cb4bd74ca72d2fa2ca41c8a640709548.zip
add a test for not rebuilding up-to-date targets
-rw-r--r--tests/update_logic.rs48
1 files changed, 48 insertions, 0 deletions
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<Path>) -> Result<Output> {
+ 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(())
+}