36
36
37
37
38
38
@pytest .mark .skipif (onWindows (),
39
- reason = "On Windows this would invoke a default docker container" )
39
+ reason = "On Windows this would invoke a default docker container, some of the test workflows need unix commands " )
40
40
class TestProvenance (unittest .TestCase ):
41
41
folder = None
42
42
43
+
44
+ def cwltool (self , * args ):
45
+ new_args = ['--no-container' ,
46
+ '--provenance' ,
47
+ self .folder ]
48
+ new_args .extend (args )
49
+ # Run within a temporary directory to not pollute git checkout
50
+ test_dir = os .path .abspath (os .curdir )
51
+ tmp_dir = tempfile .mkdtemp ("cwltool-run" )
52
+ os .chdir (tmp_dir )
53
+ try :
54
+ status = main (new_args )
55
+ self .assertEquals (status , 0 , "Failed: cwltool.main(%r)" % (args ,))
56
+ finally :
57
+ # Change back
58
+ os .chdir (test_dir )
59
+
43
60
def setUp (self ):
44
61
self .folder = tempfile .mkdtemp ("ro" )
45
62
if os .environ .get ("DEBUG" ):
@@ -50,22 +67,22 @@ def tearDown(self):
50
67
shutil .rmtree (self .folder )
51
68
52
69
def test_hello_workflow (self ):
53
- self .assertEquals ( main ([ '--provenance' , self . folder , get_data ('tests/wf/hello-workflow.cwl' ),
54
- "--usermessage" , "Hello workflow" ]), 0 )
70
+ self .cwltool ( get_data ('tests/wf/hello-workflow.cwl' ),
71
+ "--usermessage" , "Hello workflow" )
55
72
self .check_provenance ()
56
73
57
74
def test_hello_single_tool (self ):
58
- self .assertEquals ( main ([ '--provenance' , self . folder , get_data ('tests/wf/hello_single_tool.cwl' ),
59
- "--message" , "Hello tool" ]), 0 )
75
+ self .cwltool ( get_data ('tests/wf/hello_single_tool.cwl' ),
76
+ "--message" , "Hello tool" )
60
77
self .check_provenance (single_tool = True )
61
78
62
79
def test_revsort_workflow (self ):
63
- self .assertEquals ( main ([ '--no-container' , '--provenance' , self . folder , get_data ('tests/wf/revsort.cwl' ),
64
- get_data ('tests/wf/revsort-job.json' )]), 0 )
80
+ self .cwltool ( get_data ('tests/wf/revsort.cwl' ),
81
+ get_data ('tests/wf/revsort-job.json' ))
65
82
self .check_provenance ()
66
83
67
84
def test_nested_workflow (self ):
68
- self .assertEquals ( main ([ '--no-container' , '--provenance' , self . folder , get_data ('tests/wf/nested.cwl' )]), 0 )
85
+ self .cwltool ( get_data ('tests/wf/nested.cwl' ))
69
86
self .check_provenance (nested = True )
70
87
71
88
def test_directory_workflow (self ):
@@ -83,8 +100,8 @@ def test_directory_workflow(self):
83
100
with open (os .path .join (dir2 , x ), "w" , encoding = "ascii" ) as f :
84
101
f .write (x )
85
102
86
- self .assertEquals ( main ([ '--provenance' , self . folder , get_data ('tests/wf/directory.cwl' ),
87
- "--dir" , dir2 ]), 0 )
103
+ self .cwltool ( get_data ('tests/wf/directory.cwl' ),
104
+ "--dir" , dir2 )
88
105
self .check_provenance (directory = True )
89
106
90
107
# Output should include ls stdout of filenames a b c on each line
0 commit comments