diff --git a/rook/main.py b/rook/main.py index 9261b2bc69..2e0b531bc6 100644 --- a/rook/main.py +++ b/rook/main.py @@ -101,6 +101,12 @@ class NoColors: parser.add_argument('--python-command', dest='python_command', help='command to run python') +alt_framework_args = parser.add_mutually_exclusive_group(required=False) +alt_framework_args.add_argument('--use-pip', dest='use_pip', action='store_true', + help='use the pip-installed version of ravenframework') +alt_framework_args.add_argument('--use-binary', nargs=1, dest='use_binary', + help='use a specified binary version of ravenframework') + parser.add_argument('--config-file', dest='config_file', help='Configuration file location') @@ -316,6 +322,10 @@ def process_result(index, _input_data, output_data): test=process_test_name)) if __name__ == "__main__": + if args.use_binary and not os.path.exists(args.use_binary[0]): + print("The specified binary does not exist:", args.use_binary[0]) + sys.exit(-1) + if args.unkillable: def term_handler(signum, _): """ @@ -397,6 +407,14 @@ def term_handler(signum, _): print(differ.get_valid_params()) print() + if args.use_pip: + testers['RavenFramework'] = testers['RavenFrameworkPip'] + if args.use_binary: + # Specify an absolute path so we don't have to worry about where we are now vs where when + # we try to run the binary. + testers['RavenFrameworkBinary'].binary_location = os.path.abspath(args.use_binary[0]) + testers['RavenFramework'] = testers['RavenFrameworkBinary'] + tester_params = {} for tester_key, tester_value in testers.items(): #Note as a side effect, testers can add run types to diff --git a/run_tests b/run_tests index aca180dfe7..8c847528f3 100755 --- a/run_tests +++ b/run_tests @@ -44,7 +44,12 @@ for A in "$@"; do esac done echo 'Loading libraries ...' -if [[ "$INSTALLATION_MANAGER" == "CONDA" ]]; +if [[ " ${ARGS[@]} " =~ " --use-pip " ]]; +then + echo "Using the current python environment" + PYTHON_COMMAND="$CONDA_PREFIX/bin/python" + echo "Python command: $PYTHON_COMMAND" +elif [[ "$INSTALLATION_MANAGER" == "CONDA" ]]; then source $SCRIPT_DIR/scripts/establish_conda_env.sh --load elif [[ "$INSTALLATION_MANAGER" == "PIP" ]]; diff --git a/scripts/TestHarness/testers/RavenFramework.py b/scripts/TestHarness/testers/RavenFramework.py index 22c27bb9f5..3a5c8fd588 100644 --- a/scripts/TestHarness/testers/RavenFramework.py +++ b/scripts/TestHarness/testers/RavenFramework.py @@ -261,3 +261,56 @@ def process_results(self, _): @ Out, None """ self.set_success() + + +class RavenFrameworkBinary(RavenFramework): + """ + RavenFrameworkBinary is the class to use for testing standard raven inputs using a binary of RAVEN. + The main difference between this class and RavenFramework is that the command to run raven_framework + points to a binary of RAVEN instead of the local (devel) version of RAVEN. + """ + binary_location = None + + def get_command(self): + """ + Gets the raven command to run this test. + @ In, None + @ Out, get_command, string, command to run. + """ + if self.binary_location is None: + raise ValueError('Binary location not set!') + + ravenflag = '' + if self.specs['test_interface_only']: + ravenflag += ' interfaceCheck ' + + if self.specs['interactive']: + ravenflag += ' interactiveCheck ' + + # Use raven_framework script in the bin directory of the current python environment. This should be in the + # PATH, so we can just call it directly. + return self.binary_location + " " + ravenflag + self.specs["input"] + + +class RavenFrameworkPip(RavenFramework): + """ + RavenFrameworkPip is the class to use for testing standard raven inputs using a pip installation of RAVEN. + The main difference between this class and RavenFramework is that the command to run raven_framework + points to a pip installation of RAVEN instead of the local (devel) version of RAVEN. + """ + def get_command(self): + """ + Gets the raven command to run this test. + @ In, None + @ Out, get_command, string, command to run. + """ + ravenflag = '' + if self.specs['test_interface_only']: + ravenflag += ' interfaceCheck ' + + if self.specs['interactive']: + ravenflag += ' interactiveCheck ' + + # Use raven_framework script in the bin directory of the current python environment. This should be in the + # PATH, so we can just call it directly. + return "raven_framework " + ravenflag + self.specs["input"]