-
Notifications
You must be signed in to change notification settings - Fork 482
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·66 lines (59 loc) · 2.42 KB
/
test.sh
File metadata and controls
executable file
·66 lines (59 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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
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
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
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
perl -pi -e 's/\r\n/\n/g' -- $output
fi
done
# Test migrate command
for file in src/migrate/*.{res,resi}; do
output="src/expected/$(basename $file).expected"
# Capture stderr too so warnings would surface in expected output if they occur.
../../_build/install/default/bin/rescript-tools migrate "$file" --stdout > $output 2>&1
if [ "$RUNNER_OS" == "Windows" ]; then
perl -pi -e 's/\r\n/\n/g' -- $output
fi
done
# Move migrated files to expected directory so they can be compiled in the project
for file in src/migrate/StdlibMigration_*.res; do
expected_file="src/expected/$(basename $file).expected"
output="src/migrate/migrated/Migrated_$(basename $file)"
echo "// This file is autogenerated so it can be type checked.
// It's the migrated version of $file." > "$output" && cat "$expected_file" >> "$output"
../../cli/rescript.js format "$output"
done
warningYellow='\033[0;33m'
successGreen='\033[0;32m'
reset='\033[0m'
diff=$(git ls-files --modified src/expected)
if [[ $diff = "" ]]; then
printf "${successGreen}✅ No unstaged tests difference.${reset}\n"
else
printf "${warningYellow}⚠️ There are unstaged differences in tests/! Did you break a test?\n${diff}\n${reset}"
git --no-pager diff src/expected
exit 1
fi