Skip to content

Commit

Permalink
testsuite: test template expansion in environment variables
Browse files Browse the repository at this point in the history
Problem: There are no tests that ensure valid mustache templates
provided to the Flux cli submission command `--env` option are expanded
in the final job and task environment.

Add some tests to t2620-job-shell-mustache.t that test this
functionality.
  • Loading branch information
grondo committed Jan 6, 2025
1 parent d1ba9d8 commit c2312c4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion t/t2620-job-shell-mustache.t
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,18 @@ test_expect_success 'mustache: unsupported tag is left alone' '
test_debug "cat output.4" &&
test "$(cat output.4)" = "{{foo}} {{node.foo}} {{task.foo}}"
'

test_expect_success 'mustache: mustache templates can be rendered in env' '
flux run --env=TEST={{tmpdir}} -N2 \
sh -c "test \$TEST = \$FLUX_JOB_TMPDIR"
'
test_expect_success 'mustache: env variables can have per-task tags' '
flux run --env=TEST={{taskid}} -N2 -n4 \
sh -c "test \$TEST = \$FLUX_TASK_RANK" &&
flux run --env=T1={{size}} --env=T2={{taskid}} -N2 -n4 \
sh -c "test \$T1 -eq 4 -a \$T2 = \$FLUX_TASK_RANK"
'
test_expect_success 'mustache: invalid tags in env vars are left unexpanded' '
flux run --env=TEST={{task.foo}} \
sh -c "test \$TEST = {{task.foo}}"
'
test_done

0 comments on commit c2312c4

Please sign in to comment.