Skip to content

Commit 5d83897

Browse files
authored
test-rewatch: show actual error messages on "Error Cleaning/Building Repo" (#7609)
1 parent 15dc54d commit 5d83897

File tree

4 files changed

+37
-21
lines changed

4 files changed

+37
-21
lines changed

rewatch/tests/compile.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,23 @@ cd ../testrepo
55

66
bold "Test: It should compile"
77

8-
if rewatch clean &> /dev/null;
8+
error_output=$(rewatch clean 2>&1)
9+
if [ $? -eq 0 ];
910
then
1011
success "Repo Cleaned"
1112
else
1213
error "Error Cleaning Repo"
14+
printf "%s\n" "$error_output" >&2
1315
exit 1
1416
fi
1517

16-
if rewatch &> /dev/null;
18+
error_output=$(rewatch 2>&1)
19+
if [ $? -eq 0 ];
1720
then
1821
success "Repo Built"
1922
else
2023
error "Error Building Repo"
24+
printf "%s\n" "$error_output" >&2
2125
exit 1
2226
fi
2327

rewatch/tests/lock.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ bold "Test: It should lock - when watching"
55

66
sleep 1
77

8-
if rewatch clean &> /dev/null;
8+
error_output=$(rewatch clean 2>&1)
9+
if [ $? -eq 0 ];
910
then
1011
success "Repo Cleaned"
11-
else
12+
else
1213
error "Error Cleaning Repo"
14+
printf "%s\n" "$error_output" >&2
1315
exit 1
1416
fi
1517

16-
exit_watcher() {
18+
exit_watcher() {
1719
# kill watcher by removing lock file
1820
rm lib/rewatch.lock
1921
}
@@ -23,11 +25,11 @@ success "Watcher Started"
2325

2426
sleep 2
2527

26-
if rewatch build | grep 'Could not start Rewatch:' &> /dev/null;
28+
if rewatch build | grep 'Could not start Rewatch:' &> /dev/null;
2729
then
2830
success "Lock is correctly set"
2931
exit_watcher
30-
else
32+
else
3133
error "Not setting lock correctly"
3234
exit_watcher
3335
exit 1
@@ -41,7 +43,7 @@ success "Watcher Started"
4143

4244
sleep 2
4345

44-
if cat tmp.txt | grep 'Could not start Rewatch:' &> /dev/null;
46+
if cat tmp.txt | grep 'Could not start Rewatch:' &> /dev/null;
4547
then
4648
error "Lock not removed correctly"
4749
exit_watcher

rewatch/tests/suffix.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,26 @@ bold "Test: It should support custom suffixes"
55

66
# Clean Repo
77
sleep 1
8-
if rewatch clean &> /dev/null;
8+
error_output=$(rewatch clean 2>&1)
9+
if [ $? -eq 0 ];
910
then
1011
success "Repo Cleaned"
1112
else
1213
error "Error Cleaning Repo"
14+
printf "%s\n" "$error_output" >&2
1315
exit 1
1416
fi
1517

1618
# Replace suffix
1719
replace "s/.mjs/.res.js/g" bsconfig.json
1820

19-
if rewatch build &> /dev/null;
21+
error_output=$(rewatch build 2>&1)
22+
if [ $? -eq 0 ];
2023
then
2124
success "Repo Built"
2225
else
23-
error "Error building repo"
26+
error "Error Building Repo"
27+
printf "%s\n" "$error_output" >&2
2428
exit 1
2529
fi
2630

@@ -35,22 +39,26 @@ else
3539
exit 1
3640
fi
3741

38-
if rewatch clean &> /dev/null;
42+
error_output=$(rewatch clean 2>&1)
43+
if [ $? -eq 0 ];
3944
then
4045
success "Repo Cleaned"
4146
else
4247
error "Error Cleaning Repo"
48+
printf "%s\n" "$error_output" >&2
4349
exit 1
4450
fi
4551

4652
# Restore Suffix
4753
replace "s/.res.js/.mjs/g" bsconfig.json
4854

4955
# Restore original build
50-
if rewatch build &> /dev/null;
56+
error_output=$(rewatch build 2>&1)
57+
if [ $? -eq 0 ];
5158
then
5259
success "Repo Built"
5360
else
54-
error "Error building repo"
61+
error "Error Building Repo"
62+
printf "%s\n" "$error_output" >&2
5563
exit 1
5664
fi

rewatch/tests/watch.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ cd ../testrepo
33

44
bold "Test: It should watch"
55

6-
if rewatch clean &> /dev/null;
6+
error_output=$(rewatch clean 2>&1)
7+
if [ $? -eq 0 ];
78
then
89
success "Repo Cleaned"
9-
else
10+
else
1011
error "Error Cleaning Repo"
12+
printf "%s\n" "$error_output" >&2
1113
exit 1
1214
fi
1315

14-
exit_watcher() {
16+
exit_watcher() {
1517
# kill watcher by removing lock file
1618
rm lib/rewatch.lock
1719
}
@@ -23,10 +25,10 @@ echo 'Js.log("added-by-test")' >> ./packages/main/src/Main.res
2325

2426
sleep 2
2527

26-
if node ./packages/main/src/Main.mjs | grep 'added-by-test' &> /dev/null;
28+
if node ./packages/main/src/Main.mjs | grep 'added-by-test' &> /dev/null;
2729
then
2830
success "Output is correct"
29-
else
31+
else
3032
error "Output is incorrect"
3133
exit_watcher
3234
exit 1
@@ -38,10 +40,10 @@ replace '/Js.log("added-by-test")/d' ./packages/main/src/Main.res;
3840

3941
sleep 1
4042

41-
if git diff --exit-code ./
43+
if git diff --exit-code ./
4244
then
4345
success "Adding and removing changes nothing"
44-
else
46+
else
4547
error "Adding and removing changes left some artifacts"
4648
exit_watcher
4749
exit 1

0 commit comments

Comments
 (0)