Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/runtime/job-finish-without-launch/.wakeroot
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
11 changes: 11 additions & 0 deletions tests/runtime/job-finish-without-launch/pass.sh
Original file line number Diff line number Diff line change
@@ -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!"
61 changes: 61 additions & 0 deletions tests/runtime/job-finish-without-launch/test.wake
Original file line number Diff line number Diff line change
@@ -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."
Loading