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 b3f9ca8 commit 33de91c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
8 changes: 7 additions & 1 deletion tests/garbage_command.hancho
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
from hancho import *

garbage_command = Rule(command = "aklsjdflksjdlfkjldfk")
build_config.defaults(
command_path = Path.cwd(),
source_path = Path.cwd(),
build_path = Path.cwd() / "build",
)

garbage_command = build_config.rule(command = "aklsjdflksjdlfkjldfk")
garbage_command(__file__, "result.txt")
35 changes: 27 additions & 8 deletions tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ def run(cmd):

def run_hancho(name):
"""Runs a Hancho build script and returns a subprocess.CompletedProcess."""
return subprocess.run(f"python3 ../hancho.py {name}.hancho", shell=True, text=True, capture_output=True)
return subprocess.run(
f"python3 ../hancho.py {name}.hancho",
shell=True,
text=True,
capture_output=True,
)


################################################################################

Expand Down Expand Up @@ -77,7 +83,10 @@ def test_should_pass(self):
def test_should_fail(self):
"""Sanity check"""
result = run_hancho("should_fail")
self.assertTrue("ValueError: Command '(exit 255)' exited with return code 255" in result.stderr)
self.assertTrue(
"ValueError: Command '(exit 255)' exited with return code 255"
in result.stderr
)

def test_check_output(self):
"""A build rule that doesn't update one of its outputs should fail"""
Expand All @@ -102,7 +111,10 @@ def test_command_missing(self):
def test_missing_field(self):
"""Missing fields should raise an error when expanded"""
result = run_hancho("missing_field")
self.assertTrue("NameError: name 'this_field_does_not_exist' is not defined" in result.stderr)
self.assertTrue(
"NameError: name 'this_field_does_not_exist' is not defined"
in result.stderr
)

def test_missing_input(self):
"""We should fail if an input is missing"""
Expand All @@ -119,12 +131,19 @@ def test_missing_dep(self):
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)
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."""
result = run_hancho("garbage_command")
self.assertTrue(
"ValueError: Command 'aklsjdflksjdlfkjldfk' exited with return code 127"
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"))
#
# def test_garbage_template(self):
# """Templates that can't be eval()d should cause Hancho to fail the build."""
# self.assertNotEqual(0, run_hancho("garbage_template"))
Expand Down

0 comments on commit 33de91c

Please sign in to comment.