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 6655c63 commit dc2ecc4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
10 changes: 8 additions & 2 deletions tests/cancellation.hancho
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# tests/cancellation.hancho
from hancho import *

touch = Rule(command = "touch {files_out}")
build_config.defaults(
command_path = Path.cwd(),
source_path = Path.cwd(),
build_path = Path.cwd() / "build",
)

touch = build_config.rule(command = "touch {rel_build_files}")

fail = Rule(command = "(exit 255)")
fail = build_config.rule(command = "(exit 255)")

task_that_fails = fail ([], "fail_result.txt")
task_that_passes = touch([], "pass_result.txt")
Expand Down
24 changes: 12 additions & 12 deletions tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,18 +240,18 @@ def test_arbitrary_flags(self):
)
self.assertTrue(path.exists("build/some/other/dir/result.txt"))

# def test_sync_command(self):
# """The 'command' field of rules should be OK handling a sync function"""
# run_hancho("sync_command")
# self.assertTrue(path.exists("build/result.txt"))
#
# def test_cancellation(self):
# """A task that receives a cancellation exception should not run."""
# self.assertNotEqual(0, run_hancho("cancellation"))
# self.assertTrue(Path("build/pass_result.txt").exists())
# self.assertFalse(Path("build/fail_result.txt").exists())
# self.assertFalse(Path("build/should_not_be_created.txt").exists())
#
def test_sync_command(self):
"""The 'command' field of rules should be OK handling a sync function"""
run_hancho("sync_command")
self.assertTrue(path.exists("build/result.txt"))

def test_cancellation(self):
"""A task that receives a cancellation exception should not run."""
self.assertNotEqual(0, run_hancho("cancellation"))
self.assertTrue(Path("build/pass_result.txt").exists())
self.assertFalse(Path("build/fail_result.txt").exists())
self.assertFalse(Path("build/should_not_be_created.txt").exists())

# def test_task_creates_task(self):
# """Tasks using callbacks can create new tasks when they run."""
# self.assertEqual(0, run_hancho("task_creates_task"))
Expand Down
15 changes: 9 additions & 6 deletions tests/sync_command.hancho
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from hancho import *

def sync_command(task):
Path(task.files_out[0]).touch()
return task.files_out

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

def sync_command(task):
Path(task.abs_build_files[0]).touch()
return task.abs_build_files

rule = build_config.rule(command = sync_command)
rule(__file__, "result.txt")

0 comments on commit dc2ecc4

Please sign in to comment.