Skip to content

Commit

Permalink
Add a way to only run a test if a needed executable is on the path. (#…
Browse files Browse the repository at this point in the history
…2004)

* Add a way to only run a test if a needed executable is on the path.

* Adding a test for needed_executable.
  • Loading branch information
joshua-cogliati-inl authored Nov 15, 2022
1 parent 959b9c1 commit c8d7598
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rook/Tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import subprocess
import sys
import os
import shutil
import time
import threading
import platform
Expand Down Expand Up @@ -388,6 +389,8 @@ def get_valid_params():
params.add_param('min_python_version', 'none',
'The Minimum python version required for this test.'+
' Example 3.8 (note, format is major.minor)')
params.add_param('needed_executable', '',
'Only run test if needed executable is on path.')
return params

def __init__(self, _name, params):
Expand All @@ -400,6 +403,7 @@ def __init__(self, _name, params):
valid_params = self.get_valid_params()
self.specs = valid_params.get_filled_dict(params)
self.results = TestResult()
self._needed_executable = self.specs['needed_executable']
self.__command_prefix = ""
self.__python_command = sys.executable
if os.name == "nt":
Expand Down Expand Up @@ -547,6 +551,10 @@ def _run_backend(self, _):
self.results.message = "SKIPPED ("+str(self.__test_run_type)+\
" is not a subset of "+str(self.__base_current_run_type)+")"
return self.results
if len(self._needed_executable) > 0 and \
shutil.which(self._needed_executable) is None:
self.set_skip('skipped (Missing executable: "'+self._needed_executable+'")')
return self.results
if not self.check_runnable():
return self.results

Expand Down
6 changes: 6 additions & 0 deletions tests/reg_self_tests/tests
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,10 @@
alt_root = './matching'
[../]
[../]
[./check_needed_executable]
#Checks that this is skipped
type = 'GenericExecutable'
executable = 'no_such_executable'
needed_executable = 'no_such_executable'
[../]
[]

0 comments on commit c8d7598

Please sign in to comment.