diff --git a/tests/runtime/job-finish-without-launch/.wakeroot b/tests/runtime/job-finish-without-launch/.wakeroot new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/tests/runtime/job-finish-without-launch/.wakeroot @@ -0,0 +1 @@ +{} diff --git a/tests/runtime/job-finish-without-launch/pass.sh b/tests/runtime/job-finish-without-launch/pass.sh new file mode 100755 index 000000000..7da241202 --- /dev/null +++ b/tests/runtime/job-finish-without-launch/pass.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -ex + +WAKE="${1:+$1/wake}" +WAKE="${WAKE:-wake}" + +rm -f wake.db wake.log +"${WAKE}" -v test + +echo "prim_job_finish without prim_job_launch passed!" diff --git a/tests/runtime/job-finish-without-launch/test.wake b/tests/runtime/job-finish-without-launch/test.wake new file mode 100644 index 000000000..adaee37be --- /dev/null +++ b/tests/runtime/job-finish-without-launch/test.wake @@ -0,0 +1,61 @@ +package cli + +from wake import _ + +export def testPassLaunch _ = + def job = + makeExecPlan ("echo", "ping", Nil) Nil + | setPlanPersistence ReRun + | runJobWith defaultRunner + + require True = job.isJobOk + else failWithError "Expected job to succeed." + + Pass "Good launch test passed." + +def failLaunchRunner = + def run (job: Job) (input: RunnerInput): Result RunnerOutput Error = + def err = makeError "Intentional launch failure." + def _ = primJobFailLaunch job err + + failWithError "Intentional launch failure." + + makeRunner "fail-launch-runner" run + +export def testFailLaunch _ = + def job = + makeExecPlan ("echo", "ping", Nil) Nil + | setPlanPersistence ReRun + | runJobWith failLaunchRunner + + require False = job.isJobOk + else failWithError "Expected job to fail due to a (purposefully) bad runner, but it succeeded." + + Pass "Properly-handled launch-failure test safely caught the bad job." + +def abruptLaunchRunner = + def run (job: Job) (input: RunnerInput): Result RunnerOutput Error = + failWithError "Intentional launch failure." + + makeRunner "fail-launch-runner" run + +export def testAbruptLaunch _ = + def job = + makeExecPlan ("echo", "ping", Nil) Nil + | setPlanPersistence ReRun + | runJobWith abruptLaunchRunner + + # Implicit return category: The issue with the runner ordering (`primJobLaunch`+`primJobFinish`) + # addressed in #1670 would cause a panic and the remainder of the test would not run. + + require False = job.isJobOk + else failWithError "Expected job to fail due to a (purposefully) bad runner, but it succeeded." + + Pass "Out-of-order launch-failure test passed." + +export def test _ = + require Pass _ = testPassLaunch Nil + require Pass _ = testFailLaunch Nil + require Pass _ = testAbruptLaunch Nil + + Pass "All launch tests passed."