From b3f9ca84ac195be461bd80679eca2f3f1fe9a25d Mon Sep 17 00:00:00 2001 From: Austin Appleby Date: Tue, 26 Mar 2024 01:41:16 -0700 Subject: [PATCH] checkpoint --- hancho.py | 2 +- tests/missing_dep.hancho | 12 +++++++++--- tests/missing_named_dep.hancho | 11 ----------- tests/run_tests.py | 23 +++++++++++------------ 4 files changed, 21 insertions(+), 27 deletions(-) delete mode 100644 tests/missing_named_dep.hancho diff --git a/hancho.py b/hancho.py index 77555a0..b5d1d94 100755 --- a/hancho.py +++ b/hancho.py @@ -358,7 +358,7 @@ def expand_template(self, template): def eval_macro(self, macro): """Evaluates the contents of a "{macro}" string.""" if self.depth > MAX_EXPAND_DEPTH: - raise RecursionError(f"Expanding '{template}' failed to terminate") + raise RecursionError(f"Expanding '{macro}' failed to terminate") self.depth += 1 # pylint: disable=eval-used try: diff --git a/tests/missing_dep.hancho b/tests/missing_dep.hancho index 1846e3f..3c4155f 100644 --- a/tests/missing_dep.hancho +++ b/tests/missing_dep.hancho @@ -1,9 +1,15 @@ from hancho import * -rules = load("rules.hancho") +build_config.defaults( + command_path = Path.cwd(), + source_path = Path.cwd() / "src", + build_path = Path.cwd() / "build", +) + +rules = load("rules.hancho", build_config) rules.touch_outputs( - "src/test.cpp", + "test.cpp", "result.txt", - deps = ["src/does_not_exist.txt"] + command_files = ["missing_dep.txt"] ) diff --git a/tests/missing_named_dep.hancho b/tests/missing_named_dep.hancho deleted file mode 100644 index 4534091..0000000 --- a/tests/missing_named_dep.hancho +++ /dev/null @@ -1,11 +0,0 @@ -from hancho import * - -rules = load("rules.hancho") - -rules.touch_outputs( - "src/test.cpp", - "result.txt", - named_deps = { - "dummy" : "src/does_not_exist.txt" - } -) diff --git a/tests/run_tests.py b/tests/run_tests.py index 942b5fb..0288668 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -110,18 +110,17 @@ def test_missing_input(self): self.assertTrue("FileNotFoundError" in result.stderr) self.assertTrue("does_not_exist.txt" in result.stderr) -# def test_missing_named_dep(self): -# """Missing named dep should fail""" -# self.assertNotEqual(0, run_hancho("missing_named_dep")) -# -# def test_missing_dep(self): -# """Missing dep should fail""" -# self.assertNotEqual(0, run_hancho("missing_dep")) -# -# def test_expand_failed_to_terminate(self): -# """A recursive text template should cause an 'expand failed to terminate' error.""" -# self.assertNotEqual(0, run_hancho("expand_failed_to_terminate")) -# + def test_missing_dep(self): + """Missing dep should fail""" + result = run_hancho("missing_dep") + self.assertTrue("FileNotFoundError" in result.stderr) + self.assertTrue("missing_dep.txt" in result.stderr) + + def test_expand_failed_to_terminate(self): + """A recursive text template should cause an 'expand failed to terminate' error.""" + result = run_hancho("expand_failed_to_terminate") + self.assertTrue("RecursionError: Expanding '{flarp}' failed to terminate" in result.stderr) + # def test_garbage_command(self): # """Non-existent command line commands should cause Hancho to fail the build.""" # self.assertNotEqual(0, run_hancho("garbage_command"))