From 6f8f9dd46ebf8a7ff662ad65a6a1867e020682da Mon Sep 17 00:00:00 2001 From: Christoph Knittel Date: Mon, 7 Jul 2025 10:52:40 +0200 Subject: [PATCH] test-rewatch: show actual error messages on "Error Cleaning/Building Repo" --- rewatch/tests/compile.sh | 8 ++++++-- rewatch/tests/lock.sh | 14 ++++++++------ rewatch/tests/suffix.sh | 20 ++++++++++++++------ rewatch/tests/watch.sh | 16 +++++++++------- 4 files changed, 37 insertions(+), 21 deletions(-) diff --git a/rewatch/tests/compile.sh b/rewatch/tests/compile.sh index a465933c9e..334993cfc5 100755 --- a/rewatch/tests/compile.sh +++ b/rewatch/tests/compile.sh @@ -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 diff --git a/rewatch/tests/lock.sh b/rewatch/tests/lock.sh index f96d68db3e..edfa3f01b0 100755 --- a/rewatch/tests/lock.sh +++ b/rewatch/tests/lock.sh @@ -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 } @@ -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 @@ -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 diff --git a/rewatch/tests/suffix.sh b/rewatch/tests/suffix.sh index d644a34e99..499738ab9d 100755 --- a/rewatch/tests/suffix.sh +++ b/rewatch/tests/suffix.sh @@ -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 @@ -35,11 +39,13 @@ 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 @@ -47,10 +53,12 @@ fi 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 diff --git a/rewatch/tests/watch.sh b/rewatch/tests/watch.sh index 83cee30f1b..7f89837bfc 100755 --- a/rewatch/tests/watch.sh +++ b/rewatch/tests/watch.sh @@ -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 } @@ -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 @@ -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