From 5a273ac0bd3037d664b77c2917f5647c751749e4 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Tue, 22 Jun 2021 10:16:29 +0100
Subject: [PATCH] TEST: make tests pyfeeds compatible

---
 tests/feedsRun                               |  3 +++
 {.ci => tests}/test_create_remove_wrapper.py | 24 +++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100755 tests/feedsRun
 rename {.ci => tests}/test_create_remove_wrapper.py (86%)

diff --git a/tests/feedsRun b/tests/feedsRun
new file mode 100755
index 0000000..5cf41f8
--- /dev/null
+++ b/tests/feedsRun
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+
+fslpython ./test_create_remove_wrapper.py ${FSLDIR}
\ No newline at end of file
diff --git a/.ci/test_create_remove_wrapper.py b/tests/test_create_remove_wrapper.py
similarity index 86%
rename from .ci/test_create_remove_wrapper.py
rename to tests/test_create_remove_wrapper.py
index 0bf7105..859568d 100755
--- a/.ci/test_create_remove_wrapper.py
+++ b/tests/test_create_remove_wrapper.py
@@ -1,12 +1,13 @@
 #!/usr/bin/env python
 #
 # test_create_remove_wrapper.py - Test the createFSLWrapper.sh and
-# removeFSLWrapper.sh scripts. Requires Python 3.7.
+# removeFSLWrapper.sh scripts. Requires Python>=3.7.
 #
 # Author: Paul McCarthy <pauldmccarthy@gmail.com>
 #
 
 
+import sys
 import os.path as op
 import subprocess as sp
 import textwrap as tw
@@ -18,6 +19,11 @@ import contextlib
 from unittest import mock
 
 
+# Paths to create/remove wrapper scripts, when
+# running from an in-source version. These may
+# be overwritten within the __main__ clause at
+# the bottom, where BASE_DIR may be provided
+# as a command-line argument.
 BASE_DIR       = op.abspath(op.join(op.dirname(__file__), '..'))
 CREATE_WRAPPER = op.join(BASE_DIR, 'share', 'fsl', 'sbin', 'createFSLWrapper')
 REMOVE_WRAPPER = op.join(BASE_DIR, 'share', 'fsl', 'sbin', 'removeFSLWrapper')
@@ -176,3 +182,19 @@ def test_create_remove_wrappers():
 
         assert not op.exists(op.join(wrapperdir, 'test_script1'))
         assert not op.exists(op.join(wrapperdir, 'test_script2'))
+
+
+if __name__ == '__main__':
+    # base dir can be speecified on command line
+    if len(sys.argv) > 1:
+        BASE_DIR       = sys.argv[1]
+        SBIN_DIR       = op.join(BASE_DIR, 'share', 'fsl', 'sbin')
+        CREATE_WRAPPER = op.join(SBIN_DIR, 'createFSLWrapper')
+        REMOVE_WRAPPER = op.join(SBIN_DIR, 'removeFSLWrapper')
+
+    thismod = sys.modules[__name__]
+    for test in dir(thismod):
+        if test.startswith('test_'):
+            test = getattr(thismod, test)
+            if callable(test):
+                test()
-- 
GitLab