From 8b2c515ea6e404aa6e812cd1718229e66773ee15 Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Tue, 30 Jun 2015 20:14:34 -0600 Subject: [PATCH] Specify executable in Executor and TestHarness for PR #402 --- CMakeLists.txt | 5 +++-- openmc/executor.py | 11 +++++++---- tests/test_source_file/test_source_file.py | 3 ++- .../test_statepoint_restart.py | 3 ++- tests/testing_harness.py | 8 ++++++-- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 725171510c..e5c5e62b67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -253,14 +253,15 @@ foreach(test ${TESTS}) # Preform a parallel test add_test(NAME ${TEST_NAME} WORKING_DIRECTORY ${TEST_PATH} - COMMAND ${PYTHON_EXECUTABLE} ${TEST_NAME} --mpi_exec) + COMMAND ${PYTHON_EXECUTABLE} ${TEST_NAME} --exe $ + --mpi_exec) else(${MPI_ENABLED}) # Perform a serial test add_test(NAME ${TEST_NAME} WORKING_DIRECTORY ${TEST_PATH} - COMMAND ${PYTHON_EXECUTABLE} ${TEST_NAME}) + COMMAND ${PYTHON_EXECUTABLE} ${TEST_NAME} --exe $) endif(${MPI_ENABLED}) diff --git a/openmc/executor.py b/openmc/executor.py index f662384e27..76c3737079 100644 --- a/openmc/executor.py +++ b/openmc/executor.py @@ -56,14 +56,15 @@ class Executor(object): self._working_directory = working_directory - def plot_geometry(self, output=True): + def plot_geometry(self, output=True, openmc_exec='openmc'): """Run OpenMC in plotting mode""" - return self._run_openmc('openmc -p', output) + return self._run_openmc(openmc_exec + ' -p', output) def run_simulation(self, particles=None, threads=None, geometry_debug=False, restart_file=None, - tracks=False, mpi_procs=1, output=True): + tracks=False, mpi_procs=1, output=True, + openmc_exec='openmc'): """Run an OpenMC simulation. Parameters @@ -82,6 +83,8 @@ class Executor(object): Number of MPI processes output : bool Capture OpenMC output from standard out + openmc_exec : str + Path to OpenMC executable """ @@ -106,6 +109,6 @@ class Executor(object): if isinstance(mpi_procs, Integral) and mpi_procs > 1: pre_args += 'mpirun -n {0} '.format(mpi_procs) - command = pre_args + 'openmc ' + post_args + command = pre_args + openmc_exec + ' ' + post_args return self._run_openmc(command, output) diff --git a/tests/test_source_file/test_source_file.py b/tests/test_source_file/test_source_file.py index 1750d60805..3e64d2d1a0 100644 --- a/tests/test_source_file/test_source_file.py +++ b/tests/test_source_file/test_source_file.py @@ -92,7 +92,8 @@ class SourceFileTestHarness(TestHarness): # Run OpenMC. executor = Executor() - returncode = executor.run_simulation(mpi_procs=mpi_procs) + returncode = executor.run_simulation(mpi_procs=mpi_procs, + openmc_exec=self._opts.exe) assert returncode == 0, 'OpenMC did not exit successfully.' def _cleanup(self): diff --git a/tests/test_statepoint_restart/test_statepoint_restart.py b/tests/test_statepoint_restart/test_statepoint_restart.py index 739ce84a9f..ad88d6b914 100644 --- a/tests/test_statepoint_restart/test_statepoint_restart.py +++ b/tests/test_statepoint_restart/test_statepoint_restart.py @@ -47,7 +47,8 @@ class StatepointRestartTestHarness(TestHarness): # Run OpenMC executor = Executor() returncode = executor.run_simulation(mpi_procs=mpi_procs, - restart_file=statepoint) + restart_file=statepoint, + openmc_exec = self._opts.exe) assert returncode == 0, 'OpenMC did not exit successfully.' diff --git a/tests/testing_harness.py b/tests/testing_harness.py index ced1a653f7..54096d6726 100644 --- a/tests/testing_harness.py +++ b/tests/testing_harness.py @@ -57,6 +57,7 @@ class TestHarness(object): def _parse_args(self): parser = OptionParser() + parser.add_option('--exe', dest='exe', default='openmc') parser.add_option('--mpi_exec', dest='mpi_exec', action='store_true', default=False) parser.add_option('--mpi_np', dest='mpi_np', type=int, default=3) @@ -65,13 +66,16 @@ class TestHarness(object): (self._opts, self._args) = parser.parse_args() def _run_openmc(self): + print('******') + print(self._opts.exe) if self._opts.mpi_exec: mpi_procs = self._opts.mpi_np else: mpi_procs = 1 executor = Executor() - returncode = executor.run_simulation(mpi_procs=mpi_procs) + returncode = executor.run_simulation(mpi_procs=mpi_procs, + openmc_exec=self._opts.exe) assert returncode == 0, 'OpenMC did not exit successfully.' def _test_output_created(self): @@ -160,7 +164,7 @@ class PlotTestHarness(TestHarness): def _run_openmc(self): executor = Executor() - returncode = executor.plot_geometry() + returncode = executor.plot_geometry(openmc_exec=self._opts.exe) assert returncode == 0, 'OpenMC did not exit successfully.' def _test_output_created(self):