-
Notifications
You must be signed in to change notification settings - Fork 484
Expand file tree
/
Copy pathsuite.sh
More file actions
executable file
·184 lines (155 loc) · 5.69 KB
/
Copy pathsuite.sh
File metadata and controls
executable file
·184 lines (155 loc) · 5.69 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/bin/bash
set -e
unset CLICOLOR_FORCE
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <rewatch executable>"
exit 1
fi
REWATCH_EXECUTABLE="$(realpath "$1")"
export REWATCH_EXECUTABLE
# Make sure we are in the right directory
cd $(dirname $0)
if [[ "$REWATCH_EXECUTABLE" == */cli/rescript.js ]]; then
echo "Using rewatch CLI script: $REWATCH_EXECUTABLE"
else
echo "Using rewatch executable: $REWATCH_EXECUTABLE"
eval $(node ./get_bin_paths.js)
export RESCRIPT_BSC_EXE
export RESCRIPT_RUNTIME
echo Using bsc executable: $RESCRIPT_BSC_EXE
echo Using runtime path: $RESCRIPT_RUNTIME
fi
source ./utils.sh
bold "Check for stale rescript processes"
STALE_PIDS=$(ps aux | grep "$REWATCH_EXECUTABLE" | grep -v grep | awk '{print $2}')
if [ -n "$STALE_PIDS" ]; then
error "Found stale rescript processes using this executable:"
ps aux | grep "$REWATCH_EXECUTABLE" | grep -v grep
exit 1
fi
success "No stale rescript processes found"
# The published ReScript versions model dependency layouts; compilation uses
# the repository-built compiler and runtime. See ../testrepo/README.md.
bold "Yarn install"
(cd ../testrepo && yarn)
node ./add-belt-dependencies.mjs
bold "Rescript version"
(cd ../testrepo && ./node_modules/.bin/rescript --version)
# we need to reset the yarn.lock and package.json to the original state
# so there is not diff in git. The CI will install new ReScript package
bold "Reset package.json and yarn.lock"
git checkout ../testrepo/yarn.lock &> /dev/null
git checkout ../testrepo/package.json &> /dev/null
success "Reset package.json and yarn.lock"
bold "Make sure the testrepo is clean"
if git diff --exit-code ../testrepo &> diff.txt;
then
rm diff.txt
success "Testrepo has no changes"
else
error "Testrepo is not clean to start with"
cat diff.txt
rm diff.txt
exit 1
fi
# sury-ppx 11.0.0-rc.0 only ships an arm64 binary for macOS. Temporarily
# disable the PPX fixture on Intel Macs until the package ships an x64 binary.
if [[ "$(uname -s)" == "Darwin" && "$(uname -m)" == "x86_64" ]]; then
PPX_CONFIG=../testrepo/packages/with-ppx/rescript.json
PPX_SOURCE=../testrepo/packages/with-ppx/src/FileWithPpx.res
PPX_OUTPUT=../testrepo/packages/with-ppx/src/FileWithPpx.mjs
PPX_BACKUP_DIR=$(mktemp -d)
PPX_FIXTURE_SHELL_PID=$BASHPID
cp "$PPX_CONFIG" "$PPX_BACKUP_DIR/rescript.json"
cp "$PPX_SOURCE" "$PPX_BACKUP_DIR/FileWithPpx.res"
cp "$PPX_OUTPUT" "$PPX_BACKUP_DIR/FileWithPpx.mjs"
cp "$(git rev-parse --git-path index)" "$PPX_BACKUP_DIR/index"
export GIT_INDEX_FILE="$PPX_BACKUP_DIR/index"
restore_ppx_fixture() {
if [ "$BASHPID" != "$PPX_FIXTURE_SHELL_PID" ]; then
return
fi
cp "$PPX_BACKUP_DIR/rescript.json" "$PPX_CONFIG"
cp "$PPX_BACKUP_DIR/FileWithPpx.res" "$PPX_SOURCE"
cp "$PPX_BACKUP_DIR/FileWithPpx.mjs" "$PPX_OUTPUT"
unset GIT_INDEX_FILE
rm -rf "$PPX_BACKUP_DIR"
}
trap restore_ppx_fixture EXIT
bold "Disable sury-ppx fixture on Intel macOS"
node -e '
const fs = require("fs");
const path = process.argv[1];
const config = JSON.parse(fs.readFileSync(path, "utf8"));
delete config["ppx-flags"];
fs.writeFileSync(path, `${JSON.stringify(config, null, 2)}\n`);
' "$PPX_CONFIG"
printf "\n" > "$PPX_SOURCE"
if ! error_output=$(cd ../testrepo && "$REWATCH_EXECUTABLE" clean 2>&1 && "$REWATCH_EXECUTABLE" build 2>&1); then
error "Error preparing testrepo without sury-ppx"
printf "%s\n" "$error_output" >&2
exit 1
fi
git add "$PPX_CONFIG" "$PPX_SOURCE" "$PPX_OUTPUT"
success "sury-ppx fixture disabled"
fi
# Individual test files
# Comment out any test to skip it
# Compile tests
./compile/01-basic-compile.sh &&
./compile/02-standalone-package.sh &&
./compile/03-rename-file.sh &&
./compile/04-rename-file-internal-dep.sh &&
./compile/05-rename-file-namespace.sh &&
./compile/06-rename-interface-file.sh &&
./compile/07-rename-file-with-interface.sh &&
./compile/08-remove-file.sh &&
./compile/09-dependency-cycle.sh &&
./compile/10-duplicate-module-name.sh &&
./compile/11-dev-dependency-non-dev-source.sh &&
./compile/12-compile-dev-dependencies.sh &&
./compile/13-no-infinite-loop-with-cycle.sh &&
./compile/17-prod-flag.sh &&
./compile/18-external-dep-uncurried-dot.sh &&
./compile/19-utf8-warning.sh &&
./compile/14-no-testrepo-changes.sh &&
./compile/15-no-new-files.sh &&
./compile/16-snapshots-unchanged.sh &&
# Watch tests
./watch/01-watch-recompile.sh &&
./watch/02-watch-warnings-persist.sh &&
./watch/02-watch-warnings-persist-atomic-save.sh &&
./watch/03-watch-new-file.sh &&
./watch/04-watch-config-change.sh &&
./watch/05-watch-ignores-non-source.sh &&
./watch/06-watch-missing-source-folder.sh &&
# Lock tests
./lock/01-lock-when-watching.sh &&
# Suffix tests
./suffix/01-custom-suffix.sh &&
# Format tests
./format/01-format-all-files.sh &&
./format/02-format-single-file.sh &&
./format/03-format-stdin.sh &&
./format/04-format-current-project.sh &&
# Clean tests
./clean/01-clean-single-project.sh &&
./clean/02-clean-dev-dependencies.sh &&
./clean/03-clean-node-modules.sh &&
./clean/04-clean-rebuild-no-compiler-update.sh &&
# Experimental tests
./experimental/01-experimental-features-emit.sh &&
./experimental/02-experimental-features-parse-error.sh &&
./experimental/03-watch-invalid-experimental.sh &&
# Experimental-invalid tests
./experimental-invalid/01-invalid-experimental-key.sh &&
# Features tests
./features/01-features-default-all-active.sh &&
./features/02-features-cli-restricts-to-one.sh &&
./features/03-features-transitive-expansion.sh &&
./features/04-features-toggle-cleans-artifacts.sh &&
./features/05-features-cycle-errors.sh &&
./features/06-features-empty-flag-rejected.sh &&
# Compiler-args tests
./compiler-args/01-compiler-args-cwd-invariant.sh &&
./compiler-args/02-warnings-in-parser-and-compiler.sh