Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions tests/tools_tests/test.sh
Original file line number Diff line number Diff line change
@@ -1,36 +1,54 @@
#!/usr/bin/env bash

set -euo pipefail

shopt -s nullglob

for file in src/*.{res,resi}; do
output="$(dirname $file)/expected/$(basename $file).json"
../../_build/install/default/bin/rescript-tools doc $file > $output
# # CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
if [ "$RUNNER_OS" == "Windows" ]; then
if [ "${RUNNER_OS:-}" == "Windows" ]; then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-}

perl -pi -e 's/\r\n/\n/g' -- $output
fi
done

for file in ppx/*.res; do
output="src/expected/$(basename $file).jsout"
../../cli/bsc.js -ppx "../../_build/install/default/bin/rescript-tools ppx" $file > $output
if [ "$RUNNER_OS" == "Windows" ]; then
if [ "${RUNNER_OS:-}" == "Windows" ]; then
perl -pi -e 's/\r\n/\n/g' -- $output
fi
done

# Test format-codeblocks command
for file in src/docstrings-format/*.{res,resi,md}; do
output="src/expected/$(basename $file).expected"
../../_build/install/default/bin/rescript-tools format-codeblocks "$file" --stdout > $output
if [ "$RUNNER_OS" == "Windows" ]; then
if [ "$(basename "$file")" == "FormatDocstringsTestError.res" ]; then
if ../../_build/install/default/bin/rescript-tools format-codeblocks "$file" --stdout > "$output" 2>/dev/null; then
echo "Expected format-codeblocks to fail for $file" >&2
exit 1
fi
else
../../_build/install/default/bin/rescript-tools format-codeblocks "$file" --stdout > "$output"
fi
if [ "${RUNNER_OS:-}" == "Windows" ]; then
perl -pi -e 's/\r\n/\n/g' -- $output
fi
done

# Test extract-codeblocks command
for file in src/docstrings-format/*.{res,resi,md}; do
output="src/expected/$(basename $file).extracted.json.expected"
../../_build/install/default/bin/rescript-tools extract-codeblocks "$file" --transform-assert-equal > $output
if [ "$RUNNER_OS" == "Windows" ]; then
if [ "$(basename "$file")" == "FormatDocstringsTestError.res" ]; then
if ../../_build/install/default/bin/rescript-tools extract-codeblocks "$file" --transform-assert-equal > "$output" 2>/dev/null; then
echo "Expected extract-codeblocks to fail for $file" >&2
exit 1
fi
else
../../_build/install/default/bin/rescript-tools extract-codeblocks "$file" --transform-assert-equal > "$output"
fi
if [ "${RUNNER_OS:-}" == "Windows" ]; then
perl -pi -e 's/\r\n/\n/g' -- $output
fi
done
Expand All @@ -39,7 +57,7 @@ done
for file in src/migrate/*.{res,resi}; do
output="src/expected/$(basename $file).expected"
../../_build/install/default/bin/rescript-tools migrate "$file" --stdout > $output
if [ "$RUNNER_OS" == "Windows" ]; then
if [ "${RUNNER_OS:-}" == "Windows" ]; then
perl -pi -e 's/\r\n/\n/g' -- $output
fi
done
Expand Down
Loading