Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
aappleby committed Mar 26, 2024
1 parent cb53a26 commit b3f9ca8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 27 deletions.
2 changes: 1 addition & 1 deletion hancho.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 9 additions & 3 deletions tests/missing_dep.hancho
Original file line number Diff line number Diff line change
@@ -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"]
)
11 changes: 0 additions & 11 deletions tests/missing_named_dep.hancho

This file was deleted.

23 changes: 11 additions & 12 deletions tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down

0 comments on commit b3f9ca8

Please sign in to comment.