Skip to content

Commit e86aff8

Browse files
committed
test: make enabled_if tests more resiliant
Signed-off-by: Ali Caglayan <[email protected]>
1 parent 5a70c48 commit e86aff8

File tree

1 file changed

+18
-4
lines changed
  • test/blackbox-tests/test-cases/test-build-if

1 file changed

+18
-4
lines changed

test/blackbox-tests/test-cases/test-build-if/feature.t

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,34 @@ the test runs as part of @runtest
1313
> (enabled_if %{env:ENABLED=false}))
1414
> EOF
1515

16-
$ touch t.ml
16+
$ compiled_flag="t compiled"
17+
$ ran_flag="t ran"
18+
19+
$ cat > t.ml <<EOF
20+
> module T : sig
21+
> val message : string
22+
> [@@alert message "$compiled_flag"]
23+
> end = struct
24+
> let message = "$ran_flag"
25+
> end
26+
>
27+
> let () =
28+
> Printf.printf "%s" T.message
29+
> ;;
30+
> EOF
1731

1832
We test the various combinations:
1933

2034
$ test_one () {
2135
> dune clean
22-
> output=$( dune build "$1" --display short 2>&1 )
36+
> output=$( dune build "$1" 2>&1 )
2337
> echo When building $1 with ENABLED=${ENABLED:-unset}:
24-
> if echo $output|grep -q ocamlopt ; then
38+
> if echo $output | grep -q "$compiled_flag" ; then
2539
> echo ' build was done: YES'
2640
> else
2741
> echo ' build was done: NO'
2842
> fi
29-
> if echo $output|grep -q "alias t" ; then
43+
> if echo $output | grep -q "$ran_flag" ; then
3044
> echo ' test did run: YES'
3145
> else
3246
> echo ' test did run: NO'

0 commit comments

Comments
 (0)