From fa1548b0cfd41822a7c4387fa5f34c614e4b5b7a Mon Sep 17 00:00:00 2001
From: Ignacio Pisso <Ignacio.Pisso@nilu.no>
Date: Fri, 18 Mar 2016 11:01:05 +0100
Subject: [PATCH] test whether directories already exist from previous test
 runs and print those to stdout

---
 tests/create_test  | 33 ++++++++++++++++++++++++++++-----
 tests/create_tests |  2 +-
 2 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/tests/create_test b/tests/create_test
index 30ebfdae..ca558211 100755
--- a/tests/create_test
+++ b/tests/create_test
@@ -14,22 +14,45 @@ options_default=../options
 test_tmp=${base_dir}${test_dir}
 #_${suffix}
 
-current_dir=$(pwd)
-echo test_tmp=$test_tmp
-mkdir $test_tmp
+#current_dir=$(pwd)
+if [[ -d "$test_tmp" ]] ; then
+  echo  $test_tmp already exists
+else 
+  echo create test in $test_tmp
+  mkdir $test_tmp
+fi
 
 #copy default optios
+echo copy default options from  $options_default
 cp -r $options_default $test_tmp/options
+
 #override default options
-if [ -d "$test_dir"  &&  "$(ls -A ${test_dir}/options)" ]; then
+if [[ -d "$test_dir/options" ]] && [[  "$(ls -A ${test_dir}/options)" ]]; then
   cp -r ${test_dir}/options/* $test_tmp/options/
+  echo copy specific options for this test from ${test_dir}/options
 fi
+
 # copy paths form repo source exec tmp dir 
+echo copy ${test_dir}/pathnames
 cp ${test_dir}/pathnames $test_tmp
+
 # make output dir locally
-mkdir ${test_tmp}/output
+if [[ -d "$test_tmp/output" ]]; then
+  echo  $test_tmp/output already exists
+else
+  mkdir ${test_tmp}/output
+  echo create ${test_tmp}/output
+fi
+
+if [[ -L "${test_tmp}/flexpartnoresm" ]]; then
+  rm ${test_tmp}/flexpartnoresm
+  echo remove existing link ${test_tmp}/flexpartnoresm  
+fi
 ln -s $FP_exec ${test_tmp}/flexpartnoresm
+echo link  $FP_exec to ${test_tmp}/flexpartnoresm
 
+echo $test_dir is ready to run
+echo
 #cd $test_tmp
 #echo $(pwd)
 #echo $FP_exec
diff --git a/tests/create_tests b/tests/create_tests
index 0df8159f..c01f2fa0 100755
--- a/tests/create_tests
+++ b/tests/create_tests
@@ -13,7 +13,7 @@ if [ ! -d "$tmp_dir" ]; then
   echo create $tmp_dir
 fi
 
-echo $tmp_dir
+echo create tests in $tmp_dir
 #exit
 ./create_test test_0 $tmp_dir ../../src/flexpartnoresm
 ./create_test test_1 $tmp_dir ../../src/flexpartnoresm
-- 
GitLab