From 9694f705bd8f78841571ab23400b40d3dc9e4951 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Tue, 4 Jan 2022 10:47:02 +0000
Subject: [PATCH] TEST: Test creating multiple wrappers for one command

---
 tests/test_create_remove_wrapper.py | 40 +++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/tests/test_create_remove_wrapper.py b/tests/test_create_remove_wrapper.py
index 624fd5e..8318650 100755
--- a/tests/test_create_remove_wrapper.py
+++ b/tests/test_create_remove_wrapper.py
@@ -345,6 +345,46 @@ def test_create_wrappers_rename():
                 assert not op.exists(wrapper)
 
 
+def test_create_wrappers_multiple_same():
+    """Tests creating multiple wrapper scripts which call the same
+    target command.
+    """
+
+    # Keys are passed to createFSLWrapper, values
+    # are wrappers that should be created
+    scripts = {
+        'scripta'         : 'scripta',
+        'scripta=script1' : 'script1',
+        'scripta=script2' : 'script2',
+        'scriptb'         : 'scriptb',
+        'scriptc=script3' : 'script3',
+        'scriptc=script4' : 'script4',
+    }
+
+    with temp_fsldir() as (fsldir, wrapperdir):
+        for script in scripts.keys():
+            target = script.split('=')[0]
+            with open(target, 'wt') as f:
+                touch(op.join(fsldir, 'bin', target))
+
+        for wrappers in it.permutations(scripts.keys()):
+            args  = ' '.join(wrappers)
+            run(f'{CREATE_WRAPPER} {args}')
+
+            for arg in wrappers:
+                target  = arg.split('=')[0]
+                wrapper = op.join(wrapperdir, scripts[arg])
+
+                assert op.exists(wrapper)
+                assert get_called_command(wrapper) == target
+
+            run(f'{REMOVE_WRAPPER} {args}')
+            for arg in wrappers:
+                target  = scripts[arg]
+                wrapper = op.join(wrapperdir, target)
+                assert not op.exists(wrapper)
+
+
 if __name__ == '__main__':
     # base dir can be speecified on command line
     if len(sys.argv) > 1:
-- 
GitLab