Skip to content

Commit

Permalink
Merge pull request #2073 from joshua-cogliati-inl/task_2071
Browse files Browse the repository at this point in the history
Moving skip_if_OS from RavenFramework to Tester
  • Loading branch information
dylanjm authored Feb 16, 2023
2 parents 365cdef + 32c6d14 commit d55043b
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 14 deletions.
13 changes: 13 additions & 0 deletions rook/Tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ def get_valid_params():
' Example 3.8 (note, format is major.minor)')
params.add_param('needed_executable', '',
'Only run test if needed executable is on path.')
params.add_param('skip_if_OS', '', 'Skip test if the operating system defined')
return params

def __init__(self, _name, params):
Expand Down Expand Up @@ -536,6 +537,18 @@ def _run_backend(self, _):
self.results.group = self.group_skip
self.results.message = self.specs['skip']
return self.results
## OS
if len(self.specs['skip_if_OS']) > 0:
skip_os = [x.strip().lower() for x in self.specs['skip_if_OS'].split(',')]
# get simple-name platform (options are Linux, Windows, Darwin, or SunOS that I've seen)
current_os = platform.system().lower()
# replace Darwin with more expected "mac"
if current_os == 'darwin':
current_os = 'mac'
if current_os in skip_os:
self.set_skip('skipped (OS is "{}")'.format(current_os))
return self.results

if self.specs['min_python_version'].strip().lower() != 'none':
major, minor = self.specs['min_python_version'].strip().split(".")
#check to see if current version of python too old.
Expand Down
5 changes: 3 additions & 2 deletions rook/doc/rook.tex
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ \subsection{Common Features}
\item[expected\_fail] if true, then the test should fails, and if it passes, it fails
\item[run\_types] The run types of this test, separated by spaces. Example: 'heavy qsub' The default is 'normal'
\item[output\_wait\_time] Number of seconds to wait for output
\item[skip\_if\_OS] Skip the test if the OS in the list Examples: 'mac,linux' or 'windows'
\end{description}

\subsection{GenericExecutable}
Expand All @@ -71,8 +72,8 @@ \subsection{Common Features}
\item[gold\_files] Gold filenames, if different from the default. These are 1 to 1 mappings with the
\texttt{output} files listed above, and use the same relative pathing. Using the example under
\textbf{output} above, including \texttt{gold\_files = 'gold/path/to/file2'} would compare the file
\texttt{path/to/file1} to the file \texttt{gold/path/to/file2}. \nb Unlike the default,
\texttt{gold} is not automatically added to the \textttt{gold\_files} path.
\texttt{path/to/file1} to the file \texttt{gold/path/to/file2}. Note: Unlike the default,
\texttt{gold} is not automatically added to the \texttt{gold\_files} path.
\end{description}

\subsection{Exists}
Expand Down
12 changes: 0 additions & 12 deletions scripts/TestHarness/testers/RavenFramework.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def get_valid_params():
'Skip test if the library listed is below the supplied'+
' version (e.g. minimum_library_versions = \"name1 version1 name2 version2\")')
params.add_param('skip_if_env', '', 'Skip test if this environmental variable is defined')
params.add_param('skip_if_OS', '', 'Skip test if the operating system defined')
params.add_param('test_interface_only', False,
'Test the interface only (without running the driven code')
params.add_param('check_absolute_value', False,
Expand Down Expand Up @@ -180,17 +179,6 @@ def check_runnable(self):
if envVar in os.environ:
self.set_skip('skipped (found environmental variable "'+envVar+'")')
return False
## OS
if len(self.specs['skip_if_OS']) > 0:
skipOs = [x.strip().lower() for x in self.specs['skip_if_OS'].split(',')]
# get simple-name platform (options are Linux, Windows, Darwin, or SunOS that I've seen)
currentOs = platform.system().lower()
# replace Darwin with more expected "mac"
if currentOs == 'darwin':
currentOs = 'mac'
if currentOs in skipOs:
self.set_skip('skipped (OS is "{}")'.format(currentOs))
return False
for lib in self.required_libraries:
found, _, _ = library_handler.checkSingleLibrary(lib)
if not found:
Expand Down
12 changes: 12 additions & 0 deletions tests/reg_self_tests/only_not_windows.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
this only runs successfully in when not in windows
"""

import platform
import sys

if platform.system().lower() == 'windows':
sys.exit(-1)

#Otherwise succeed
sys.exit(0)
12 changes: 12 additions & 0 deletions tests/reg_self_tests/only_windows.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
this only runs successfully in windows
"""

import platform
import sys

if platform.system().lower() == 'windows':
sys.exit(0)

#Otherwise fail
sys.exit(-1)
12 changes: 12 additions & 0 deletions tests/reg_self_tests/tests
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
input = 'test_ordered_csv.py'
[../]

[./check_windows]
type = 'RavenPython'
input = 'only_windows.py'
skip_if_OS = 'mac,linux'
[../]

[./check_not_windows]
type = 'RavenPython'
input = 'only_not_windows.py'
skip_if_OS = 'windows'
[../]

[./simple_exec]
type = 'GenericExecutable'
executable = 'python'
Expand Down

0 comments on commit d55043b

Please sign in to comment.