Skip to content

test-rewatch: show actual error messages on "Error Cleaning/Building Repo" #7609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
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
8 changes: 6 additions & 2 deletions rewatch/tests/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@ cd ../testrepo

bold "Test: It should compile"

if rewatch clean &> /dev/null;
error_output=$(rewatch clean 2>&1)
if [ $? -eq 0 ];
then
success "Repo Cleaned"
else
error "Error Cleaning Repo"
printf "%s\n" "$error_output" >&2
exit 1
fi

if rewatch &> /dev/null;
error_output=$(rewatch 2>&1)
if [ $? -eq 0 ];
then
success "Repo Built"
else
error "Error Building Repo"
printf "%s\n" "$error_output" >&2
exit 1
fi

Expand Down
14 changes: 8 additions & 6 deletions rewatch/tests/lock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ bold "Test: It should lock - when watching"

sleep 1

if rewatch clean &> /dev/null;
error_output=$(rewatch clean 2>&1)
if [ $? -eq 0 ];
then
success "Repo Cleaned"
else
else
error "Error Cleaning Repo"
printf "%s\n" "$error_output" >&2
exit 1
fi

exit_watcher() {
exit_watcher() {
# kill watcher by removing lock file
rm lib/rewatch.lock
}
Expand All @@ -23,11 +25,11 @@ success "Watcher Started"

sleep 2

if rewatch build | grep 'Could not start Rewatch:' &> /dev/null;
if rewatch build | grep 'Could not start Rewatch:' &> /dev/null;
then
success "Lock is correctly set"
exit_watcher
else
else
error "Not setting lock correctly"
exit_watcher
exit 1
Expand All @@ -41,7 +43,7 @@ success "Watcher Started"

sleep 2

if cat tmp.txt | grep 'Could not start Rewatch:' &> /dev/null;
if cat tmp.txt | grep 'Could not start Rewatch:' &> /dev/null;
then
error "Lock not removed correctly"
exit_watcher
Expand Down
20 changes: 14 additions & 6 deletions rewatch/tests/suffix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,26 @@ bold "Test: It should support custom suffixes"

# Clean Repo
sleep 1
if rewatch clean &> /dev/null;
error_output=$(rewatch clean 2>&1)
if [ $? -eq 0 ];
then
success "Repo Cleaned"
else
error "Error Cleaning Repo"
printf "%s\n" "$error_output" >&2
exit 1
fi

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

if rewatch build &> /dev/null;
error_output=$(rewatch build 2>&1)
if [ $? -eq 0 ];
then
success "Repo Built"
else
error "Error building repo"
error "Error Building Repo"
printf "%s\n" "$error_output" >&2
exit 1
fi

Expand All @@ -35,22 +39,26 @@ else
exit 1
fi

if rewatch clean &> /dev/null;
error_output=$(rewatch clean 2>&1)
if [ $? -eq 0 ];
then
success "Repo Cleaned"
else
error "Error Cleaning Repo"
printf "%s\n" "$error_output" >&2
exit 1
fi

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

# Restore original build
if rewatch build &> /dev/null;
error_output=$(rewatch build 2>&1)
if [ $? -eq 0 ];
then
success "Repo Built"
else
error "Error building repo"
error "Error Building Repo"
printf "%s\n" "$error_output" >&2
exit 1
fi
16 changes: 9 additions & 7 deletions rewatch/tests/watch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ cd ../testrepo

bold "Test: It should watch"

if rewatch clean &> /dev/null;
error_output=$(rewatch clean 2>&1)
if [ $? -eq 0 ];
then
success "Repo Cleaned"
else
else
error "Error Cleaning Repo"
printf "%s\n" "$error_output" >&2
exit 1
fi

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

sleep 2

if node ./packages/main/src/Main.mjs | grep 'added-by-test' &> /dev/null;
if node ./packages/main/src/Main.mjs | grep 'added-by-test' &> /dev/null;
then
success "Output is correct"
else
else
error "Output is incorrect"
exit_watcher
exit 1
Expand All @@ -38,10 +40,10 @@ replace '/Js.log("added-by-test")/d' ./packages/main/src/Main.res;

sleep 1

if git diff --exit-code ./
if git diff --exit-code ./
then
success "Adding and removing changes nothing"
else
else
error "Adding and removing changes left some artifacts"
exit_watcher
exit 1
Expand Down