Skip to content

Commit

Permalink
RavenFramework tests using pip package or pre-built executable
Browse files Browse the repository at this point in the history
  • Loading branch information
j-bryan committed Feb 16, 2024
1 parent 7e74598 commit ef51b9d
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
18 changes: 18 additions & 0 deletions rook/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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, _):
"""
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion run_tests
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]];
Expand Down
53 changes: 53 additions & 0 deletions scripts/TestHarness/testers/RavenFramework.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit ef51b9d

Please sign in to comment.