From 1ae9a15f6ef1d14c0a126347612e5ab6e6cbcbb4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= <tseeker@legacyworlds.com>
Date: Thu, 16 Feb 2012 18:32:44 +0100
Subject: [PATCH] Improvements to developer SQL tests runner

* The script will no longer fail when there are no tests matching the
requested name in either admin/ or user/

* The script will ignore non-SQL files when running with --run-name
---
 legacyworlds/dev-tools/run-database-tests.sh | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/legacyworlds/dev-tools/run-database-tests.sh b/legacyworlds/dev-tools/run-database-tests.sh
index cfaf812..b1956f8 100755
--- a/legacyworlds/dev-tools/run-database-tests.sh
+++ b/legacyworlds/dev-tools/run-database-tests.sh
@@ -50,10 +50,14 @@ EOF
 	if [ "x$run_name" = "x" ]; then
 		run_name='*.sql'
 	else
-		run_name='*'"$run_name"'*'
+		run_name='*'"$run_name"'*.sql'
+	fi
+	if ! [ -z "`find admin/ -type f -name "$run_name"`" ]; then
+		pg_prove -d $test_db `find admin/ -type f -name "$run_name" | sort` || exit 1
+	fi
+	if ! [ -z "`find user/ -type f -name "$run_name"`" ]; then
+		pg_prove -U $test_user -d $test_db `find user/ -type f -name "$run_name" | sort` || exit 1
 	fi
-	pg_prove -d $test_db `find admin/ -type f -name "$run_name" | sort` || exit 1
-	pg_prove -U $test_user -d $test_db `find user/ -type f -name "$run_name" | sort` || exit 1
 )
 result=$?