Skip to content

Commit

Permalink
Interpolate step/test/suite names (after env)
Browse files Browse the repository at this point in the history
This ensures that names are interpolated, if everything succeeds before
it, including env interpolation. If something fails before names are
interpolated, they will remain and be printed uninterpolated.
  • Loading branch information
jonsmock committed Sep 24, 2024
1 parent 3c82f08 commit 2f40c56
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
3 changes: 2 additions & 1 deletion examples/00-intro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ tests:
run: ["echo", "array", "of", "arguments"]

expressions:
name: Expressions test
name: Expressions ${{ env.TEST_EXPR }}
env:
BAR: ${{ 1 + 1 }}
TEST_EXPR: test
steps:
- exec: node1
run: |
Expand Down
6 changes: 3 additions & 3 deletions schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ additionalProperties: false
required: []
properties:
env: { "$ref": "#/$defs/env" }
name: { type: string }
name: { type: string, expression: InterpolatedText }
tests:
type: object
additionalProperties:
Expand All @@ -22,7 +22,7 @@ properties:
required: []
properties:
env: { "$ref": "#/$defs/env" }
name: { type: string }
name: { type: string, expression: InterpolatedText }
depends:
oneOf:
- type: string
Expand All @@ -44,7 +44,7 @@ properties:
oneOf:
- { type: string, expression: Expression }
- { type: array, items: { type: string, expression: Expression } }
name: { type: string }
name: { type: string, expression: InterpolatedText }
if: { type: string, expression: Expression, default: "success()" }
index: { type: integer }
run:
Expand Down
15 changes: 10 additions & 5 deletions src/dctest/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ Options:
(as-> m
(update-in m [:context :env] merge (get-in m [:results :env])))

(interpolate-key :name)
(interpolate-key :exec)
(interpolate-key :run)
(update-in [:results :index] #(or % 1))
Expand Down Expand Up @@ -286,6 +287,7 @@ Options:
(as-> m
(update-in m [:context :env] merge (get-in m [:results :env])))

(interpolate-key :name)
(execute-test-steps)
(assoc-in [:results :outcome] :passed))

Expand Down Expand Up @@ -347,18 +349,21 @@ Options:
(P/-> {:context orig-context
:results (assoc suite :outcome :pending)}

(while-> (comp pending? :results)

(interpolate-key :env)
(as-> m
(update-in m [:context :env] merge (get-in m [:results :env])))

(interpolate-key :name))

(as-> m
(let [opts (get-in m [:context :opts])]
(log opts) ; breath between suites
(log opts " " (get-in m [:results :name]))
m))

(while-> (comp pending? :results)

(interpolate-key :env)
(as-> m
(update-in m [:context :env] merge (get-in m [:results :env])))

(run-tests)
(assoc-in [:results :outcome] :passed))

Expand Down

0 comments on commit 2f40c56

Please sign in to comment.