[v3,5/8] test-lib: set $TRASH_DIRECTORY earlier
diff mbox series

Message ID 20181230191629.3232-6-szeder.dev@gmail.com
State New
Headers show
Series
  • test-lib: add the '--stress' option to help reproduce occasional failures in flaky tests
Related show

Commit Message

SZEDER Gábor Dec. 30, 2018, 7:16 p.m. UTC
A later patch in this series will need to know the path to the trash
directory early in 'test-lib.sh', but $TRASH_DIRECTORY is set much
later.  Furthermore, the path to the trash directory depends on the
'--root=<path>' option, which, too, is parsed too late.

Move parsing '--root=...' to the early option parsing loop, and set
$TRASH_DIRECTORY where the other test-specific path variables are set.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 t/test-lib.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

SZEDER Gábor Dec. 30, 2018, 10:44 p.m. UTC | #1
On Sun, Dec 30, 2018 at 08:16:26PM +0100, SZEDER Gábor wrote:
> A later patch in this series will need to know the path to the trash
> directory early in 'test-lib.sh', but $TRASH_DIRECTORY is set much
> later.  Furthermore, the path to the trash directory depends on the
> '--root=<path>' option, which, too, is parsed too late.
> 
> Move parsing '--root=...' to the early option parsing loop, and set
> $TRASH_DIRECTORY where the other test-specific path variables are set.

Sigh.
After moving the whole option parsing loop, I should have updated this
commit message as well.

Hang on for a sec...


> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---
>  t/test-lib.sh | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 41457d1dcf..2b88ba2de1 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -186,6 +186,12 @@ fi
>  TEST_NAME="$(basename "$0" .sh)"
>  TEST_RESULTS_DIR="$TEST_OUTPUT_DIRECTORY/test-results"
>  TEST_RESULTS_BASE="$TEST_RESULTS_DIR/$TEST_NAME"
> +TRASH_DIRECTORY="trash directory.$TEST_NAME"
> +test -n "$root" && TRASH_DIRECTORY="$root/$TRASH_DIRECTORY"
> +case "$TRASH_DIRECTORY" in
> +/*) ;; # absolute path is good
> + *) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$TRASH_DIRECTORY" ;;
> +esac
>  
>  # if --tee was passed, write the output not only to the terminal, but
>  # additionally to the file test-results/$BASENAME.out, too.
> @@ -1046,12 +1052,6 @@ then
>  fi
>  
>  # Test repository
> -TRASH_DIRECTORY="trash directory.$TEST_NAME"
> -test -n "$root" && TRASH_DIRECTORY="$root/$TRASH_DIRECTORY"
> -case "$TRASH_DIRECTORY" in
> -/*) ;; # absolute path is good
> - *) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$TRASH_DIRECTORY" ;;
> -esac
>  rm -fr "$TRASH_DIRECTORY" || {
>  	GIT_EXIT_OK=t
>  	echo >&5 "FATAL: Cannot prepare test area"
> -- 
> 2.20.1.151.gec613c4b75
>

Patch
diff mbox series

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 41457d1dcf..2b88ba2de1 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -186,6 +186,12 @@  fi
 TEST_NAME="$(basename "$0" .sh)"
 TEST_RESULTS_DIR="$TEST_OUTPUT_DIRECTORY/test-results"
 TEST_RESULTS_BASE="$TEST_RESULTS_DIR/$TEST_NAME"
+TRASH_DIRECTORY="trash directory.$TEST_NAME"
+test -n "$root" && TRASH_DIRECTORY="$root/$TRASH_DIRECTORY"
+case "$TRASH_DIRECTORY" in
+/*) ;; # absolute path is good
+ *) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$TRASH_DIRECTORY" ;;
+esac
 
 # if --tee was passed, write the output not only to the terminal, but
 # additionally to the file test-results/$BASENAME.out, too.
@@ -1046,12 +1052,6 @@  then
 fi
 
 # Test repository
-TRASH_DIRECTORY="trash directory.$TEST_NAME"
-test -n "$root" && TRASH_DIRECTORY="$root/$TRASH_DIRECTORY"
-case "$TRASH_DIRECTORY" in
-/*) ;; # absolute path is good
- *) TRASH_DIRECTORY="$TEST_OUTPUT_DIRECTORY/$TRASH_DIRECTORY" ;;
-esac
 rm -fr "$TRASH_DIRECTORY" || {
 	GIT_EXIT_OK=t
 	echo >&5 "FATAL: Cannot prepare test area"