diff --git a/tests/cancellation.hancho b/tests/cancellation.hancho index 6e084df..217369a 100644 --- a/tests/cancellation.hancho +++ b/tests/cancellation.hancho @@ -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") diff --git a/tests/run_tests.py b/tests/run_tests.py index 743ba2b..c8e607e 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -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")) diff --git a/tests/sync_command.hancho b/tests/sync_command.hancho index b1184cf..980d67d 100644 --- a/tests/sync_command.hancho +++ b/tests/sync_command.hancho @@ -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")