1111from pathlib import Path
1212import unittest
1313from unittest import mock
14+ from tempfile import TemporaryFile
1415from tests .common import with_tempdir
1516from vunit .hashing import hash_string
1617from vunit .test .runner import TestRunner
@@ -23,10 +24,13 @@ class TestTestRunner(unittest.TestCase):
2324 Test the test runner
2425 """
2526
27+ def setUp (self ):
28+ self ._run_script = TemporaryFile ()
29+
2630 @with_tempdir
2731 def test_runs_testcases_in_order (self , tempdir ):
2832 report = TestReport ()
29- runner = TestRunner (report , tempdir )
33+ runner = TestRunner (report , tempdir , self . _run_script )
3034
3135 order = []
3236 test_case1 = self .create_test ("test1" , True , order = order )
@@ -48,7 +52,7 @@ def test_runs_testcases_in_order(self, tempdir):
4852 @with_tempdir
4953 def test_fail_fast (self , tempdir ):
5054 report = TestReport ()
51- runner = TestRunner (report , tempdir , fail_fast = True )
55+ runner = TestRunner (report , tempdir , self . _run_script , fail_fast = True )
5256
5357 order = []
5458 test_case1 = self .create_test ("test1" , True , order = order )
@@ -72,7 +76,7 @@ def test_fail_fast(self, tempdir):
7276 @with_tempdir
7377 def test_handles_python_exeception (self , tempdir ):
7478 report = TestReport ()
75- runner = TestRunner (report , tempdir )
79+ runner = TestRunner (report , tempdir , self . _run_script )
7680
7781 test_case = self .create_test ("test" , True )
7882 test_list = TestList ()
@@ -88,7 +92,7 @@ def side_effect(*args, **kwargs): # pylint: disable=unused-argument
8892 @with_tempdir
8993 def test_collects_output (self , tempdir ):
9094 report = TestReport ()
91- runner = TestRunner (report , tempdir )
95+ runner = TestRunner (report , tempdir , self . _run_script )
9296
9397 test_case = self .create_test ("test" , True )
9498 test_list = TestList ()
@@ -111,7 +115,7 @@ def side_effect(*args, **kwargs): # pylint: disable=unused-argument
111115 @with_tempdir
112116 def test_can_read_output (self , tempdir ):
113117 report = TestReport ()
114- runner = TestRunner (report , tempdir )
118+ runner = TestRunner (report , tempdir , self . _run_script )
115119
116120 test_case = self .create_test ("test" , True )
117121 test_list = TestList ()
@@ -138,7 +142,7 @@ def side_effect(read_output, **kwargs): # pylint: disable=unused-argument
138142 def test_get_output_path_on_linux (self ):
139143 output_path = "output_path"
140144 report = TestReport ()
141- runner = TestRunner (report , output_path )
145+ runner = TestRunner (report , output_path , self . _run_script )
142146
143147 with mock .patch ("sys.platform" , new = "linux" ):
144148 with mock .patch ("os.environ" , new = {}):
@@ -169,7 +173,7 @@ def test_get_output_path_on_linux(self):
169173 def test_get_output_path_on_windows (self ):
170174 output_path = "output_path"
171175 report = TestReport ()
172- runner = TestRunner (report , output_path )
176+ runner = TestRunner (report , output_path , self . _run_script )
173177
174178 with mock .patch ("sys.platform" , new = "win32" ):
175179 with mock .patch ("os.environ" , new = {}):
@@ -213,6 +217,9 @@ def run_side_effect(*args, **kwargs): # pylint: disable=unused-argument
213217 test_case = TestCaseMock (name = name , run_side_effect = run_side_effect )
214218 return test_case
215219
220+ def tearDown (self ):
221+ self ._run_script .close ()
222+
216223
217224class TestCaseMock (object ):
218225 """
@@ -226,7 +233,7 @@ def __init__(self, name, run_side_effect):
226233 self .called = False
227234 self .run_side_effect = run_side_effect
228235
229- def run (self , output_path , read_output ):
236+ def run (self , output_path , read_output , run_script_path ):
230237 """
231238 Mock run method that just records the arguments
232239 """
0 commit comments