~ salmonella-environment-setup (master) 335aa23ba6e9d6e55f8e1780659947235864041a


commit 335aa23ba6e9d6e55f8e1780659947235864041a
Author:     Mario Domenech Goulart <mario@parenteses.org>
AuthorDate: Fri Apr 16 19:56:37 2021 +0200
Commit:     Mario Domenech Goulart <mario@parenteses.org>
CommitDate: Fri Apr 16 19:56:55 2021 +0200

    run-salmonella.sh: manage run-salmonella.log
    
    This change makes run-salmonella.sh manage salmonella-run-publish's
    log file.  The log file is passed via the `RUN_SALMONELLA_LOG_FILE'
    environment in `conf/common/common.scm'.

diff --git a/conf/common/common.scm b/conf/common/common.scm
index 6985438..4b018c3 100644
--- a/conf/common/common.scm
+++ b/conf/common/common.scm
@@ -23,6 +23,8 @@
 (compress-report? #f)
 (create-report-tarball 'gzip)
 
+(log-file (ensure-environment-variable "RUN_SALMONELLA_LOG_FILE"))
+
 (web-dir (ensure-environment-variable "SALMONELLA_REPORTS_DIR"))
 
 (feeds-server
diff --git a/run-salmonella.sh b/run-salmonella.sh
index cac9927..8a7aaeb 100755
--- a/run-salmonella.sh
+++ b/run-salmonella.sh
@@ -33,6 +33,22 @@ export CHICKEN_5_PREFIX=$HOME/local/chicken-5
 export CHICKEN_5_EGGS_DIR=$HOME/src/chicken-5-eggs
 export SALMONELLA_REPORTS_DIR=$HOME/salmonella/reports
 
+# This must be in sync with the value of `(tmp-dir)' in
+# salmonella-run-publish-params.
+RUN_SALMONELLA_TMP_DIR=salmonella-run-publish
+export RUN_SALMONELLA_LOG_FILE=run-salmonella.log
+
+# salmonella-run-publish changes to `(tmp-dir)' (mapped to
+# $RUN_SALMONELLA_TMP_DIR in this script) in runtime and by default
+# assumes the log file is there.  When logging from this script,
+# though, the log file is relative to $WORK_DIR (we change to
+# $WORK_DIR in `main').
+log_file=$RUN_SALMONELLA_TMP_DIR/$RUN_SALMONELLA_LOG_FILE
+
+# `info' is supposed to be used after changing to $WORK_DIR.
+info() {
+    echo "$*" >> "$log_file"
+}
 
 if [ "$CHICKEN_TESTS_MAJOR_VERSION" = 4 ]; then
     CHICKEN_TESTS_PREFIX=$CHICKEN_4_PREFIX
@@ -44,20 +60,13 @@ else
     ARCH=$($CHICKEN_5_PREFIX/bin/csi -p '(begin (import (chicken platform)) (machine-type))')
 fi
 
-settings_files="\
+SETTINGS_FILES="\
     $SRC_CONF_DIR/shell-settings/${OS}/settings.sh
     $SRC_CONF_DIR/shell-settings/${OS}-${ARCH}/settings.sh
     $LOCAL_CONF_DIR/shell-settings/${OS}/settings.sh
     $LOCAL_CONF_DIR/shell-settings/${OS}-${ARCH}/settings.sh
 "
 
-for settings_file in $settings_files; do
-    if [ -e "$settings_file" ]; then
-        echo "Loading $settings_file"
-        . "$settings_file"
-    fi
-done
-
 
 run_hooks() {
     # Call hooks scripts, passing $OS, $ARCH, CHICKEN_4_PREFIX and
@@ -113,6 +122,18 @@ main() {
     # Remove leftovers from previous executions
     rm -rf salmonella-run-publish
 
+    # Create the directory for the log file
+    mkdir -p "$RUN_SALMONELLA_TMP_DIR"
+
+    # Load settings files
+    local settings_file
+    for settings_file in $SETTINGS_FILES; do
+        if [ -e "$settings_file" ]; then
+            info "Loading $settings_file"
+            . "$settings_file"
+        fi
+    done
+
     local salmonella_run_publish
     salmonella_run_publish="$CHICKEN_TESTS_PREFIX/bin/salmonella-run-publish"
 
@@ -121,19 +142,20 @@ main() {
         rm -rf ~/.chicken-inline
 
         # Remove leftovers from previous executions
-        rm -rf salmonella-$conf
+        rm -rf "salmonella-$conf"
+        rm -f "$log_file"
 
         run_hooks
 
         conf_path=$SRC_CONF_DIR/${conf}.conf
         local_conf_path=$LOCAL_CONF_DIR/${conf}.conf
         if [ -e "$local_conf_path" ]; then
-            echo "Loading $conf_path"
-            echo "Loading $local_conf_path"
-            "$salmonella_run_publish" "$conf_path" "$local_conf_path"
+            info "Loading $conf_path"
+            info "Loading $local_conf_path"
+            "$salmonella_run_publish" "$conf_path" "$local_conf_path" >>"$log_file" 2>&1
         else
-            echo "Loading $conf_path"
-            "$salmonella_run_publish" "$conf_path"
+            info "Loading $conf_path"
+            "$salmonella_run_publish" "$conf_path" >>"$log_file" 2>&1
         fi
         [ -d salmonella-run-publish ] && mv salmonella-run-publish "salmonella-$conf"
     done
Trap