~ salmonella-environment-setup (master) 0610956a0fe346a14a46e0d00084344ccf9941f2


commit 0610956a0fe346a14a46e0d00084344ccf9941f2
Author:     Mario Domenech Goulart <mario@parenteses.org>
AuthorDate: Sat Jun 17 00:06:46 2023 +0200
Commit:     Mario Domenech Goulart <mario@parenteses.org>
CommitDate: Sat Jun 17 00:12:29 2023 +0200

    run-salmonella.sh: call salmonella-run-publish with --work-dir

diff --git a/conf/common/common.scm b/conf/common/common.scm
index 70434c3..a92ca16 100644
--- a/conf/common/common.scm
+++ b/conf/common/common.scm
@@ -27,8 +27,6 @@
 (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 a7b1ace..3d68b5d 100755
--- a/run-salmonella.sh
+++ b/run-salmonella.sh
@@ -52,23 +52,6 @@ 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_WORK_DIR=salmonella-run-publish
-export RUN_SALMONELLA_LOG_FILE=run-salmonella.log
-
-# salmonella-run-publish changes to `(tmp-dir)' (mapped to
-# $RUN_SALMONELLA_WORK_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_WORK_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
     OS=$($CHICKEN_4_PREFIX/bin/csi -p '(software-version)')
@@ -116,25 +99,27 @@ run_salmonella() {
 
     mkdir -p "$WORK_DIR"
 
-    # Run salmonella from $WORK_DIR
-    cd "$WORK_DIR"
-
     local salmonella_run_publish
     salmonella_run_publish="$CHICKEN_TESTS_PREFIX/bin/salmonella-run-publish"
 
+    local conf_work_dir
     for conf in $confs; do
+        conf_work_dir=$WORK_DIR/$conf
+
+        # This must be in sync with the value of `(log-file)' in
+        # salmonella-run-publish.
+        log_file=$conf_work_dir/run-salmonella.log
 
         # Remove leftovers from previous executions.  Once
-        # `$RUN_SALMONELLA_WORK_DIR` is created it is safe to use
-        # `info'.
-        rm -rf "$RUN_SALMONELLA_WORK_DIR"
-        mkdir -p "$RUN_SALMONELLA_WORK_DIR"
+        # `$conf_work_dir` is created it is safe to use `info'.
+        rm -rf "$conf_work_dir"
+        mkdir -p "$conf_work_dir"
 
         # Load settings files
         local settings_file
         for settings_file in $SETTINGS_FILES; do
             if [ -e "$settings_file" ]; then
-                info "Loading $settings_file"
+                echo "Loading $settings_file" >> "$log_file"
                 . "$settings_file"
             fi
         done
@@ -142,14 +127,10 @@ run_salmonella() {
         # The inline egg writes some stuff to the home dir
         rm -rf ~/.chicken-inline
 
-        # Remove leftovers from previous executions
-        rm -rf "salmonella-$conf"
-        rm -f "$log_file"
-
         run_hooks
 
         local args
-        args=$SRC_CONF_DIR/${conf}.conf
+        args="--work-dir $conf_work_dir $SRC_CONF_DIR/${conf}.conf"
 
         local_conf_path=$LOCAL_CONF_DIR/${conf}.conf
         [ -e "$local_conf_path" ] && args="$args $local_conf_path"
@@ -157,11 +138,9 @@ run_salmonella() {
         [ -n "$CHICKEN_CORE_COMMIT_HASH" ] &&
             args="--commit-hash $CHICKEN_CORE_COMMIT_HASH $args"
 
-        info "Running $salmonella_run_publish $args"
+        echo "Running $salmonella_run_publish $args" >> "$log_file"
         "$salmonella_run_publish" $args >>"$log_file" 2>&1
 
-        [ -d "$RUN_SALMONELLA_WORK_DIR" ] &&
-            mv "$RUN_SALMONELLA_WORK_DIR" "salmonella-$conf"
     done
 }
 
Trap