#!/home/docs/checkouts/readthedocs.org/user_builds/pyctest/conda/latest/bin/python
# MIT License
#
# Copyright (c) 2018, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory (subject to receipt of any
# required approvals from the U.S. Dept. of Energy). All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
"""
Direct interface to CTest executable
.. highlight:: bash
.. code-block:: bash
python -m pyctest.ctest [ARG [ARG]]
"""
from __future__ import absolute_import
import os, sys, imp, ctypes, platform, warnings
__author__ = "Jonathan Madsen"
__copyright__ = "Copyright 2018, The Regents of the University of California"
__credits__ = ["Jonathan Madsen"]
__license__ = "MIT"
__version__ = "0.0.12"
__maintainer__ = "Jonathan Madsen"
__email__ = "jonrobm.programming@gmail.com"
__status__ = "Development"
__all__ = ["CTest"]
#-----------------------------------------------------------------------------#
# versioning
#
sys.modules[__name__].__setattr__("version_info",
(0,
0,
12) )
sys.modules[__name__].__setattr__("version", "0.0.12" )
sys.modules[__name__].__setattr__(
"build_info",
{ "date" : "Fri Dec 28 20:09:42 2018 UTC",
"library_architecture" : "x86_64",
"system_name" : "Linux",
"system_version" : "4.4.0-96-generic",
"build_type" : "MinSizeRel",
"compiler" : "/home/conda/feedstock_root/build_artifacts/pyctest_1546027739524/_build_env/bin/x86_64-conda_cos6-linux-gnu-c++",
"compiler_id" : "GNU",
"compiler_version" : "7.3.0"
} )
version_info = sys.modules[__name__].__getattribute__("version_info")
build_info = sys.modules[__name__].__getattribute__("build_info")
version = sys.modules[__name__].__getattribute__("version")
__all__ += [ 'version_info', 'version', 'build_info' ]
#-----------------------------------------------------------------------------#
# provide a function to run CTest
#
[docs]def CTest(*args, **kwargs):
'''Function for direct access to CTest
Parameters
----------
args: list
List of CTest arguments (added to cmd-line in order after `kwargs`)
kwargs: dict
List of CTest variable definitions (added before `args`)
Example
-------
.. highlight:: python
.. code-block:: python
pyctest.ctest.CTest('-V', '-S', 'CTestScript.cmake', '-j1')
.. highlight:: python
.. code-block:: python
_kwargs['STAGES'] = 'Start;Update;Build;Test;Submit'
_args = [ '-V', '-S', 'Stages.cmake', '-j1' ]
pyctest.ctest.CTest(_args, _kwargs)
'''
import pyctest as _pyctest
import subprocess as sp
exe_args = []
# process dictionary (assumes defining for cache)
for key, val in kwargs.items():
exe_args.append("-D{}={}".format(key, val))
# process list of arguments (assumes proper ordering)
for entry in args:
exe_args.append("{}".format(entry)) # convert to string
try:
sp.check_call([_pyctest.ctest_executable] + exe_args)
except Exception as e:
print('Exception occurred: {}'.format(e))