|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -euo pipefail |
| 4 | + |
1 | 5 | shopt -s nullglob |
2 | 6 |
|
3 | 7 | for file in src/*.{res,resi}; do |
4 | 8 | output="$(dirname $file)/expected/$(basename $file).json" |
5 | 9 | ../../_build/install/default/bin/rescript-tools doc $file > $output |
6 | 10 | # # CI. We use LF, and the CI OCaml fork prints CRLF. Convert. |
7 | | - if [ "$RUNNER_OS" == "Windows" ]; then |
| 11 | + if [ "${RUNNER_OS:-}" == "Windows" ]; then |
8 | 12 | perl -pi -e 's/\r\n/\n/g' -- $output |
9 | 13 | fi |
10 | 14 | done |
11 | 15 |
|
12 | 16 | for file in ppx/*.res; do |
13 | 17 | output="src/expected/$(basename $file).jsout" |
14 | 18 | ../../cli/bsc.js -ppx "../../_build/install/default/bin/rescript-tools ppx" $file > $output |
15 | | - if [ "$RUNNER_OS" == "Windows" ]; then |
| 19 | + if [ "${RUNNER_OS:-}" == "Windows" ]; then |
16 | 20 | perl -pi -e 's/\r\n/\n/g' -- $output |
17 | 21 | fi |
18 | 22 | done |
19 | 23 |
|
20 | 24 | # Test format-codeblocks command |
21 | 25 | for file in src/docstrings-format/*.{res,resi,md}; do |
22 | 26 | output="src/expected/$(basename $file).expected" |
23 | | - ../../_build/install/default/bin/rescript-tools format-codeblocks "$file" --stdout > $output |
24 | | - if [ "$RUNNER_OS" == "Windows" ]; then |
| 27 | + if [ "$(basename "$file")" == "FormatDocstringsTestError.res" ]; then |
| 28 | + if ../../_build/install/default/bin/rescript-tools format-codeblocks "$file" --stdout > "$output" 2>/dev/null; then |
| 29 | + echo "Expected format-codeblocks to fail for $file" >&2 |
| 30 | + exit 1 |
| 31 | + fi |
| 32 | + else |
| 33 | + ../../_build/install/default/bin/rescript-tools format-codeblocks "$file" --stdout > "$output" |
| 34 | + fi |
| 35 | + if [ "${RUNNER_OS:-}" == "Windows" ]; then |
25 | 36 | perl -pi -e 's/\r\n/\n/g' -- $output |
26 | 37 | fi |
27 | 38 | done |
28 | 39 |
|
29 | 40 | # Test extract-codeblocks command |
30 | 41 | for file in src/docstrings-format/*.{res,resi,md}; do |
31 | 42 | output="src/expected/$(basename $file).extracted.json.expected" |
32 | | - ../../_build/install/default/bin/rescript-tools extract-codeblocks "$file" --transform-assert-equal > $output |
33 | | - if [ "$RUNNER_OS" == "Windows" ]; then |
| 43 | + if [ "$(basename "$file")" == "FormatDocstringsTestError.res" ]; then |
| 44 | + if ../../_build/install/default/bin/rescript-tools extract-codeblocks "$file" --transform-assert-equal > "$output" 2>/dev/null; then |
| 45 | + echo "Expected extract-codeblocks to fail for $file" >&2 |
| 46 | + exit 1 |
| 47 | + fi |
| 48 | + else |
| 49 | + ../../_build/install/default/bin/rescript-tools extract-codeblocks "$file" --transform-assert-equal > "$output" |
| 50 | + fi |
| 51 | + if [ "${RUNNER_OS:-}" == "Windows" ]; then |
34 | 52 | perl -pi -e 's/\r\n/\n/g' -- $output |
35 | 53 | fi |
36 | 54 | done |
|
39 | 57 | for file in src/migrate/*.{res,resi}; do |
40 | 58 | output="src/expected/$(basename $file).expected" |
41 | 59 | ../../_build/install/default/bin/rescript-tools migrate "$file" --stdout > $output |
42 | | - if [ "$RUNNER_OS" == "Windows" ]; then |
| 60 | + if [ "${RUNNER_OS:-}" == "Windows" ]; then |
43 | 61 | perl -pi -e 's/\r\n/\n/g' -- $output |
44 | 62 | fi |
45 | 63 | done |
|
0 commit comments