$OpenBSD: patch-tests_regression-test_py,v 1.2 2018/10/28 14:49:25 landry Exp $
Index: tests/regression-test.py
--- tests/regression-test.py.orig
+++ tests/regression-test.py
@@ -494,7 +494,7 @@ def findContribSql(filename):
 
     # Try to get base dir for postgres contrib
     try:
-        postgis_base_dir = os.popen('pg_config | grep -m 1 "^INCLUDEDIR ="').read().strip().split(' ')[2].split('/include')[0]
+        postgis_base_dir = os.popen('pg_config | grep "^INCLUDEDIR =" |head -n1').read().strip().split(' ')[2].split('/include')[0]
     except:
         postgis_base_dir = '/usr'
 
@@ -554,6 +554,9 @@ def setupDB():
             global created_tablespace
             created_tablespace = 0
 
+            subprocess.call(["/bin/rm", "-rf", "/tmp/psql-tablespace"])
+            os.makedirs("/tmp/psql-tablespace")
+            test_cur.execute("""CREATE TABLESPACE tablespacetest LOCATION '/tmp/psql-tablespace'""")
             test_cur.execute("""SELECT spcname FROM pg_tablespace WHERE spcname = 'tablespacetest'""")
             if test_cur.fetchone():
                 print "We already have a tablespace, can use that"
@@ -613,7 +616,7 @@ def tearDownDB():
     gen_cur.close()
     gen_conn.close()
     if (created_tablespace == 1):
-        returncode = subprocess.call(["/usr/bin/sudo", "/bin/rmdir", "/tmp/psql-tablespace"])
+        returncode = subprocess.call(["/bin/rm", "-rf", "/tmp/psql-tablespace"])
 
 
 if __name__ == "__main__":
