aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2024-11-11 17:15:08 -0700
committerMelody Horn <melody@boringcactus.com>2024-11-11 17:15:08 -0700
commit4f9299b4639802e05e1cb27d8eb40305ff8e110e (patch)
tree0da5529c68c82e97aed67d842e50f6285e79e6c2 /tests
parentfbbcf325b8bbe72f924da6a7cdb128d973ef0026 (diff)
downloadmakers-4f9299b4639802e05e1cb27d8eb40305ff8e110e.tar.gz
makers-4f9299b4639802e05e1cb27d8eb40305ff8e110e.zip
implement rule-specific macros for targets
Diffstat (limited to 'tests')
-rw-r--r--tests/rule_specific_macros.rs86
-rw-r--r--tests/update_logic.rs2
2 files changed, 86 insertions, 2 deletions
diff --git a/tests/rule_specific_macros.rs b/tests/rule_specific_macros.rs
new file mode 100644
index 0000000..8cc9c12
--- /dev/null
+++ b/tests/rule_specific_macros.rs
@@ -0,0 +1,86 @@
+mod utils;
+
+use std::fs;
+use utils::{make, R};
+
+#[test]
+#[cfg(feature = "full")]
+fn target_specific_macros() -> R {
+ let dir = tempfile::tempdir()?;
+
+ let file = "
+foo.h: EGG = bug
+foo.h:
+\techo $(EGG)
+ ";
+ fs::write(dir.path().join("Makefile"), file)?;
+
+ let result = make(&dir)?;
+ dbg!(&result);
+ assert!(result.status.success());
+ let stdout = String::from_utf8(result.stdout)?;
+ assert!(stdout.contains("echo bug"));
+
+ Ok(())
+}
+
+#[test]
+#[ignore = "not yet implemented"]
+#[cfg(feature = "full")]
+fn target_specific_macros_inherited() -> R {
+ let dir = tempfile::tempdir()?;
+
+ // example from https://www.gnu.org/software/make/manual/html_node/Target_002dspecific.html
+ let file = "
+CC=echo cc
+prog : CFLAGS = -g
+prog : prog.o foo.o bar.o
+ ";
+ fs::write(dir.path().join("Makefile"), file)?;
+ fs::write(dir.path().join("prog.c"), "")?;
+ fs::write(dir.path().join("foo.c"), "")?;
+ fs::write(dir.path().join("bar.c"), "")?;
+
+ let result = make(&dir)?;
+ dbg!(&result);
+ assert!(result.status.success());
+ let stdout = String::from_utf8(result.stdout)?;
+ assert!(stdout.contains("echo cc -g -c foo.c"));
+ assert!(stdout.contains("echo cc -g -c bar.o"));
+ assert!(stdout.contains("echo cc -g -c prog.c"));
+
+ Ok(())
+}
+
+#[test]
+#[ignore = "not yet implemented"]
+#[cfg(feature = "full")]
+fn inference_rule_specific_macros() -> R {
+ let dir = tempfile::tempdir()?;
+
+ // example from https://www.gnu.org/software/make/manual/html_node/Pattern_002dspecific.html
+ let file = "
+CC=echo cc
+%.o: %.c
+\t$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
+
+lib/%.o: CFLAGS := -fPIC -g
+%.o: CFLAGS := -g
+
+all: foo.o lib/bar.o
+ ";
+ fs::write(dir.path().join("Makefile"), file)?;
+ fs::write(dir.path().join("foo.c"), "")?;
+ fs::create_dir(dir.path().join("lib"))?;
+ fs::write(dir.path().join("bar.c"), "")?;
+
+ let result = make(&dir)?;
+ dbg!(&result);
+ assert!(result.status.success());
+ let stdout = String::from_utf8(result.stdout)?;
+ dbg!(&stdout);
+ assert!(stdout.contains("echo cc -g foo.c -o foo.o"));
+ assert!(stdout.contains("echo cc -fPIC -g lib/bar.c -o lib/bar.o"));
+
+ Ok(())
+}
diff --git a/tests/update_logic.rs b/tests/update_logic.rs
index 0c97ad5..6eefe6b 100644
--- a/tests/update_logic.rs
+++ b/tests/update_logic.rs
@@ -1,6 +1,4 @@
use std::fs;
-
-use eyre::WrapErr;
use std::thread::sleep;
use std::time::Duration;