Skip to content

Commit 48fb58a

Browse files
committed
flatten test tasks and set preconditions on valid ystdlib-cpp libs
1 parent e3ba7ce commit 48fb58a

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

taskfile.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ includes:
44
build: "./taskfiles/build.yaml"
55
deps: "./taskfiles/deps.yaml"
66
lint: "./taskfiles/lint.yaml"
7-
test: "./taskfiles/test.yaml"
7+
test:
8+
taskfile: "./taskfiles/test.yaml"
9+
flatten: true
810
utils: "tools/yscope-dev-utils/taskfiles/utils.yaml"
911

1012
vars:

taskfiles/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ tasks:
3030
- "{{.TARGET}}"
3131

3232
unit-test-*:
33-
desc: "Builds unit test target for the specified library."
33+
desc: "Builds the unit test target for the specified library."
3434
vars:
3535
TEST_TARGET: >-
3636
{{printf "unit-test-%s" (index .MATCH 0)}}

taskfiles/test.yaml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
version: "3"
22

3+
vars:
4+
YSTDLIBS:
5+
- "testlib"
6+
37
tasks:
4-
all:
8+
test-all:
59
desc: "Runs all unit tests."
10+
deps:
11+
- "build:unit-test-all"
612
cmds:
7-
- task: "run-all"
13+
- "{{.G_TEST_BIN_DIR}}/unit-test-all"
814

9-
run-*:
10-
desc: "Runs unit test for the specified library."
15+
test-*:
16+
desc: "Runs unit tests for the specified library."
1117
vars:
18+
LIBRARY: >-
19+
{{index .MATCH 0}}
1220
TEST_TARGET: >-
13-
{{printf "unit-test-%s" (index .MATCH 0)}}
14-
deps:
15-
- task: ":build:{{.TEST_TARGET}}"
16-
cmd: "{{.G_TEST_BIN_DIR}}/{{.TEST_TARGET}}"
21+
{{printf "unit-test-%s" .LIBRARY}}
22+
preconditions:
23+
- sh: >-
24+
{{ has .LIBRARY .YSTDLIBS }}
25+
msg: |-
26+
{{.LIBRARY}} is not a valid ystdlib-cpp library!
27+
List of libraries:
28+
{{- range .YSTDLIBS }}
29+
{{.}}
30+
{{- end}}
31+
cmds:
32+
- task: "build:{{.TEST_TARGET}}"
33+
- "{{.G_TEST_BIN_DIR}}/{{.TEST_TARGET}}"

0 commit comments

Comments
 (0)