test-lib: retire $remove_trash variable
commit06478dab4c9fb57dc6b7299eafd18df1bea9ca22
authorJunio C Hamano <gitster@pobox.com>
Mon, 24 Apr 2017 00:15:09 +0000 (23 17:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 25 Apr 2017 06:45:51 +0000 (24 23:45 -0700)
tree8cda819742ddae03b720f43f217c220ff255440f
parent4d0912a206a32e9763424363617e8425f049f344
test-lib: retire $remove_trash variable

The convention "$remove_trash is set to the trash directory that is
used during the test, so that it will be removed at the end, but
under --debug option we set the varilable to empty string to
preserve the directory" made sense back when it was introduced, as
there was no $TRASH_DIRECTORY variable.  These days, since no tests
looks at the variable, it is obscure and even risks that by mistake
the variable gets used for something else (e.g. remove_trash=yes)
and cause us misbehave.  Worse yet, remove_trash was not initialized
to an empty string at the beginning, so a stray environment variable
the user has could have affected the logic when "--debug" is in use.

Rewrite the clean-up sequence in test_done helper to explicitly
check the $debug condition and remove the trash directory using
the $TRASH_DIRECTORY variable.

Note that "go to the directory one level above the trash and then
remove it" is kept and this is deliverate; test_at_end_hook_ will
keep running from the expected location, and also some platforms may
not like a directory that is serving as the $cwd of a still-active
process removed.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib.sh