@@ -30,6 +30,7 @@ echo_err() {
30
30
}
31
31
32
32
# ################# EXTRACT
33
+ # TODO(kwannoel): Write tests for these
33
34
34
35
# Get reason for generation crash.
35
36
get_failure_reason () {
@@ -67,7 +68,7 @@ extract_failing_query() {
67
68
grep " \[EXECUTING .*\]: " | tail -n 1 | sed -E ' s/^.*\[EXECUTING .*\]: (.*)$/\1;/' || true
68
69
}
69
70
70
- # Extract fail info from logs in log dir
71
+ # Extract fail info from [`generate-*.log`] in log dir
71
72
extract_fail_info_from_logs () {
72
73
for LOGFILENAME in $( ls " $LOGDIR " | grep " generate" )
73
74
do
@@ -86,14 +87,17 @@ extract_fail_info_from_logs() {
86
87
FAIL_DIR=" $OUTDIR /failed/$SEED "
87
88
mkdir -p " $FAIL_DIR "
88
89
echo -e " $DDL " " \n$GLOBAL_SESSION " " \n$DML " " \n$TEST_SESSION " " \n$QUERY " > " $FAIL_DIR /queries.sql"
89
- echo_err " [INFO] WROTE FAIL QUERY to $FAIL_DIR /queries.log "
90
+ echo_err " [INFO] WROTE FAIL QUERY to $FAIL_DIR /queries.sql "
90
91
echo -e " $REASON " > " $FAIL_DIR /fail.log"
91
92
echo_err " [INFO] WROTE FAIL REASON to $FAIL_DIR /fail.log"
93
+
92
94
cp " $LOGFILE " " $FAIL_DIR /$LOGFILENAME "
93
95
fi
94
96
done
95
97
}
96
98
99
+ # ################ Generate
100
+
97
101
# Prefer to use [`generate_deterministic`], it is faster since
98
102
# runs with all-in-one binary.
99
103
generate_deterministic () {
@@ -123,6 +127,8 @@ generate_sqlsmith() {
123
127
--generate " $OUTDIR /$1 "
124
128
}
125
129
130
+ # ############################ Checks
131
+
126
132
# Check that queries are different
127
133
check_different_queries () {
128
134
if [[ -z $( diff " $OUTDIR /1/queries.sql" " $OUTDIR /2/queries.sql" ) ]]; then
@@ -142,34 +148,6 @@ check_failed_to_generate_queries() {
142
148
fi
143
149
}
144
150
145
- # sync step
146
- # Some queries maybe be added
147
- sync_queries () {
148
- set +x
149
- pushd $OUTDIR
150
- git checkout main
151
- git pull
152
- set +e
153
- git branch -D stage
154
- set -e
155
- git checkout -b stage
156
- popd
157
- set -x
158
- }
159
-
160
- # Upload step
161
- upload_queries () {
162
- set +x
163
- pushd " $OUTDIR "
164
- git add .
165
- git commit -m ' update queries'
166
- git push -f origin stage
167
- git checkout -
168
- git branch -D stage
169
- popd
170
- set -x
171
- }
172
-
173
151
# Run it to make sure it should have no errors
174
152
run_queries () {
175
153
echo " " > $LOGDIR /run_deterministic.stdout.log
@@ -180,6 +158,7 @@ run_queries() {
180
158
&& rm $LOGDIR /fuzzing-{}.log"
181
159
}
182
160
161
+ # Generated query sets should not fail.
183
162
check_failed_to_run_queries () {
184
163
FAILED_LOGS=$( ls " $LOGDIR " | grep fuzzing || true)
185
164
if [[ -n " $FAILED_LOGS " ]]; then
@@ -223,11 +202,39 @@ validate() {
223
202
echo_err " [INFO] Passed checks"
224
203
}
225
204
205
+ # sync step
206
+ # Some queries maybe be added
207
+ sync_queries () {
208
+ set +x
209
+ pushd $OUTDIR
210
+ git checkout main
211
+ git pull
212
+ set +e
213
+ git branch -D stage
214
+ set -e
215
+ git checkout -b stage
216
+ popd
217
+ set -x
218
+ }
219
+
226
220
sync () {
227
221
sync_queries
228
222
echo_err " [INFO] Synced"
229
223
}
230
224
225
+ # Upload step
226
+ upload_queries () {
227
+ set +x
228
+ pushd " $OUTDIR "
229
+ git add .
230
+ git commit -m ' update queries'
231
+ git push -f origin stage
232
+ git checkout -
233
+ git branch -D stage
234
+ popd
235
+ set -x
236
+ }
237
+
231
238
upload () {
232
239
upload_queries
233
240
echo_err " [INFO] Uploaded"
@@ -238,6 +245,8 @@ cleanup() {
238
245
echo_err " [INFO] Success!"
239
246
}
240
247
248
+ # ################## MAIN
249
+
241
250
main () {
242
251
setup
243
252
@@ -250,4 +259,4 @@ main() {
250
259
cleanup
251
260
}
252
261
253
- main
262
+ main
0 commit comments