Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions Testing/SystemTests/tests/qt/WorkbenchStartupTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
from tempfile import NamedTemporaryFile

TEST_MESSAGE = "Hello Mantid!"
EXECUTABLE_SWITCHER = {"linux": ["launch_mantidworkbench.sh", "mantidworkbench"], "darwin": ["workbench"], "win32": ["workbench.exe"]}
EXECUTABLE_SWITCHER = {
"linux": ["launch_mantidworkbench.sh", "workbench"],
"darwin": ["workbench"],
"win32": ["workbench"],
}
SUBPROCESS_TIMEOUT_SECS = 300


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


def get_mantid_executable_path(platform):
directory = ConfigService.getPropertiesDir().replace("\\", "/")
for executable in get_mantid_executables_for_platform(platform):
workbench_exe = os.path.join(directory, executable)
if os.path.exists(workbench_exe):
return workbench_exe
raise RuntimeError(f"Could not find path to {workbench_exe}. Tried {get_mantid_executables_for_platform(platform)}")


def start_and_wait_for_completion(args_list):
pids_before_open = set(psutil.pids())
process = subprocess.Popen(args_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Expand Down Expand Up @@ -78,18 +73,21 @@ def __init__(self):

self._test_file = NamedTemporaryFile(suffix=".txt", delete=False).name.replace("\\", "/")
self._test_script = NamedTemporaryFile(suffix=".py", delete=False).name.replace("\\", "/")
self._executable = get_mantid_executable_path(sys.platform)
self._executables = get_mantid_executables_for_platform(sys.platform)
write_test_script(self._test_script, self._test_file)

def runTest(self):
exitcode = start_and_wait_for_completion([self._executable, "--execute", self._test_script, "--quit"])

# Was the process successful
self.assertEqual(0, exitcode)
# Assert that the test script runs successfully by writing to a .txt file
with open(self._test_file, "r") as file:
self.assertEqual(TEST_MESSAGE, file.readline())
directory = ConfigService.getPropertiesDir().replace("\\", "/")
for executable in self._executables:
file_path = os.path.join(directory, executable)
executable = file_path if os.path.exists(file_path) else executable
exitcode = start_and_wait_for_completion([executable, "--execute", self._test_script, "--quit"])
# Was the process successful
self.assertEqual(0, exitcode)
# Assert that the test script runs successfully by writing to a .txt file
with open(self._test_file, "r") as file:
self.assertEqual(TEST_MESSAGE, file.readline())
remove_file(self._test_file)

def cleanup(self):
remove_file(self._test_script)
remove_file(self._test_file)
2 changes: 1 addition & 1 deletion qt/applications/workbench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if(APPLE OR WIN32)
endif()
add_python_package(workbench EXECUTABLE EGGLINKNAME MantidWorkbench EXCLUDE_FROM_INSTALL ${_exclude_on_install})
# Allow VS to start workbench for debugging
set(_vs_debugger_args "${MSVC_BIN_DIR}/workbench-script.pyw --single-process")
set(_vs_debugger_args "-m workbench --single-process")
# cmake-format: off
set_target_properties(
workbench
Expand Down
Loading