Skip to content

Commit 77a832d

Browse files
jclarkeSTFCjhaigh0
andcommitted
The .exe file is no longer produced in a dev build
Since we switched to pip install --editable instead of calling setup.py directly, we no longer get an executable file in the build output, so this test needed adjusting. It was also attempting to do a for loop and returning at the first entry so we fixed that. Co-authored-by: Jonathan Haigh <jonathan.haigh@stfc.ac.uk>
1 parent dbe9e38 commit 77a832d

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

Testing/SystemTests/tests/qt/WorkbenchStartupTest.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
from tempfile import NamedTemporaryFile
1515

1616
TEST_MESSAGE = "Hello Mantid!"
17-
EXECUTABLE_SWITCHER = {"linux": ["launch_mantidworkbench.sh", "mantidworkbench"], "darwin": ["workbench"], "win32": ["workbench.exe"]}
17+
EXECUTABLE_SWITCHER = {
18+
"linux": ["launch_mantidworkbench.sh", "mantidworkbench", "workbench"],
19+
"darwin": ["workbench"],
20+
"win32": ["workbench"],
21+
}
1822
SUBPROCESS_TIMEOUT_SECS = 300
1923

2024

@@ -25,15 +29,6 @@ def get_mantid_executables_for_platform(platform):
2529
return workbench_executables
2630

2731

28-
def get_mantid_executable_path(platform):
29-
directory = ConfigService.getPropertiesDir().replace("\\", "/")
30-
for executable in get_mantid_executables_for_platform(platform):
31-
workbench_exe = os.path.join(directory, executable)
32-
if os.path.exists(workbench_exe):
33-
return workbench_exe
34-
raise RuntimeError(f"Could not find path to {workbench_exe}. Tried {get_mantid_executables_for_platform(platform)}")
35-
36-
3732
def start_and_wait_for_completion(args_list):
3833
pids_before_open = set(psutil.pids())
3934
process = subprocess.Popen(args_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -78,18 +73,21 @@ def __init__(self):
7873

7974
self._test_file = NamedTemporaryFile(suffix=".txt", delete=False).name.replace("\\", "/")
8075
self._test_script = NamedTemporaryFile(suffix=".py", delete=False).name.replace("\\", "/")
81-
self._executable = get_mantid_executable_path(sys.platform)
76+
self._executables = get_mantid_executables_for_platform(sys.platform)
8277
write_test_script(self._test_script, self._test_file)
8378

8479
def runTest(self):
85-
exitcode = start_and_wait_for_completion([self._executable, "--execute", self._test_script, "--quit"])
86-
87-
# Was the process successful
88-
self.assertEqual(0, exitcode)
89-
# Assert that the test script runs successfully by writing to a .txt file
90-
with open(self._test_file, "r") as file:
91-
self.assertEqual(TEST_MESSAGE, file.readline())
80+
directory = ConfigService.getPropertiesDir().replace("\\", "/")
81+
for executable in self._executables:
82+
file_path = os.path.join(directory, executable)
83+
executable = file_path if os.path.exists(file_path) else executable
84+
exitcode = start_and_wait_for_completion([executable, "--execute", self._test_script, "--quit"])
85+
# Was the process successful
86+
self.assertEqual(0, exitcode)
87+
# Assert that the test script runs successfully by writing to a .txt file
88+
with open(self._test_file, "r") as file:
89+
self.assertEqual(TEST_MESSAGE, file.readline())
90+
remove_file(self._test_file)
9291

9392
def cleanup(self):
9493
remove_file(self._test_script)
95-
remove_file(self._test_file)

0 commit comments

Comments
 (0)