Skip to contentSkip to conversation

cleanup shell test only if TST_NO_CLEANUP is not defined

PATCH New Alexey Kodanev 2 participants 2 messages Dec 19, 2016 – Jan 23, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cleanup shell test only if TST_NO_CLEANUP is not defined

Could be useful to debug a single test so it leaves the setup on the machine intact.

---
 testcases/lib/test.sh     |    2 +-
 testcases/lib/tst_test.sh |    3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
testcases/lib/test.sh +1 -1
index 76b7062..0876df3 100644
@@ -96,7 +96,7 @@ tst_require_root()
 
 tst_exit()
 {
-	if [ -n "$TST_CLEANUP" ]; then
+	if [ -n "$TST_CLEANUP" -a -z "$TST_NO_CLEANUP" ]; then
 		$TST_CLEANUP
 	fi
 
testcases/lib/tst_test.sh +2 -1
index b54bbbf..c6a85f3 100644
@@ -33,7 +33,8 @@ tst_do_exit()
 {
 	local ret=0
 
-	if [ -n "$TST_SETUP_STARTED" -a -n "$TST_CLEANUP" ]; then
+	if [ -n "$TST_SETUP_STARTED" -a -n "$TST_CLEANUP" -a \
+	     -z "$TST_NO_CLEANUP" ]; then
 		$TST_CLEANUP
 	fi
 
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 cleanup shell test only if TST_NO_CLEANUP is not defined

Hi!

Quoted 2 lines

Could be useful to debug a single test so it leaves the setup on the machine intact.

I do not think that this is useful enough to be included in the shell library, but on the other hand it's just oneliner. Feel free to push it if you find it useful.

Signature · 2 lines
Cyril Hrubis
[email protected]