Skip to main content

Running Scripts

Run predefined REPL command sequences from coco.nut:

coco lab run <script-name>

coco lab init

Loads and compiles the logic from the manifest already configured in coco.nut, and registers the default_user. The project must already be initialized (use coco nut init to create a new coco.nut).

Defining Scripts

In coco.nut:

[lab.scripts]
test-toggle = ["engines", "users", "logics"]
my-test = ["compile MyLogic", "deploy MyLogic.Init()", "invoke MyLogic.Run()"]

Scripts created by default with coco nut init.

Bash Verification Scripts

The [scripts] section defines bash commands that can run lab scripts and verify output:

[scripts]
test = '''
PASS=0
FAIL=0
TEST_RESULTS=$(coco lab run my-test 2>&1)

echo "$TEST_RESULTS" | grep -q 'expected_output' \
&& { echo 'PASS: test name'; PASS=$((PASS+1)); } \
|| { echo 'FAIL: test name'; FAIL=$((FAIL+1)); }

echo "Results: $PASS passed, $FAIL failed out of $((PASS+FAIL)) tests"
if [ "$FAIL" -gt 0 ]; then exit 1; fi
'''

Run with: coco nut run test

CLI Flags

FlagDescription
-c, --configConfig name from [lab.config.name]
-e, --envEnvironment (default: main)
-s, --suppressSuppress output
coco lab run test-toggle -s