Beispiel #1
0
def checkVersions():
    """
    Method to check if versions of modules are new enough. Will call sys.exit
    if they are not in the range specified.
    @ In, None
    @ Out, None
  """
    sys.path.append(
        os.path.join(os.path.dirname(frameworkDir), "scripts", "TestHarness",
                     "testers"))
    import RavenUtils
    sys.path.pop()  #remove testers path
    missing, outOfRange, notQA = RavenUtils.checkForMissingModules(False)
    if len(missing) + len(outOfRange) > 0 and RavenUtils.checkVersions():
        print(
            "ERROR: too old, too new, or missing raven libraries, not running:"
        )
        for error in missing + outOfRange + notQA:
            print(error)
        sys.exit(-4)
    else:
        if len(missing) + len(outOfRange) > 0:
            print("WARNING: not using tested versions of the libraries:")
            for warning in notQA + missing + outOfRange:
                print(warning)
Beispiel #2
0
    def checkRunnable(self, option):
        i = 0
        if len(self.minimum_libraries) % 2:
            return (
                False,
                'skipped (libraries are not matched to versions numbers: ' +
                str(self.minimum_libraries) + ')')
        while i < len(self.minimum_libraries):
            libraryName = self.minimum_libraries[i]
            libraryVersion = self.minimum_libraries[i + 1]
            found, message, actualVersion = RavenUtils.moduleReport(
                libraryName, libraryName + '.__version__')
            if not found:
                return (False, 'skipped (Unable to import library: "' +
                        libraryName + '")')
            if distutils.version.LooseVersion(
                    actualVersion) < distutils.version.LooseVersion(
                        libraryVersion):
                return (False,
                        'skipped (Outdated library: "' + libraryName + '")')
            i += 2

        if len(self.required_executable) > 0:
            try:
                argsList = [self.required_executable]
                argsList.extend(self.required_executable_check_flags)
                retValue = subprocess.call(argsList, stdout=subprocess.PIPE)
                if retValue != 0:
                    return (False, 'skipped (Failing executable: "' +
                            self.required_executable + '")')
            except:
                return (False, 'skipped (Error when trying executable: "' +
                        self.required_executable + '")')

        if self.specs['requires_swig2'] and not RavenPython.has_swig2:
            return (False, 'skipped (No swig 2.0 found)')
        missing, too_old, notQA = RavenUtils.checkForMissingModules()
        if len(missing) > 0:
            return (False,
                    'skipped (Missing python modules: ' + " ".join(missing) +
                    " PYTHONPATH=" + os.environ.get("PYTHONPATH", "") + ')')
        if len(too_old) > 0 and RavenUtils.checkVersions():
            return (False, 'skipped (Old version python modules: ' +
                    " ".join(too_old) + " PYTHONPATH=" +
                    os.environ.get("PYTHONPATH", "") + ')')
        for lib in self.required_libraries:
            found, message, version = RavenUtils.moduleReport(lib, '')
            if not found:
                return (False,
                        'skipped (Unable to import library: "' + lib + '")')

        return (True, '')
Beispiel #3
0
 def checkRunnable(self, option):
     """This method checks if the the test is runnable within the current settings"""
     missing, too_old, notQA = RavenUtils.checkForMissingModules()
     if len(missing) > 0:
         self.setStatus(
             'skipped (Missing python modules: ' + " ".join(missing) +
             " PYTHONPATH=" + os.environ.get("PYTHONPATH", "") + ')',
             self.bucket_skip)
         return False
     if len(too_old) > 0:
         self.setStatus(
             'skipped (Old version python modules: ' + " ".join(too_old) +
             " PYTHONPATH=" + os.environ.get("PYTHONPATH", "") + ')',
             self.bucket_skip)
         return False
     for lib in self.required_libraries:
         if platform.system() == 'Windows':
             lib += '.pyd'
         else:
             lib += '.so'
         if not os.path.exists(lib):
             self.setStatus('skipped (Missing library: "' + lib + '")',
                            self.bucket_skip)
             return False
     if len(self.required_executable) > 0 and \
        not os.path.exists(self.required_executable):
         self.setStatus(
             'skipped (Missing executable: "' + self.required_executable +
             '")', self.bucket_skip)
         return False
     try:
         if len(self.required_executable) > 0 and \
            subprocess.call([self.required_executable],stdout=subprocess.PIPE) != 0:
             self.setStatus(
                 'skipped (Failing executable: "' +
                 self.required_executable + '")', self.bucket_skip)
             return False
     except:
         self.setStatus(
             'skipped (Error when trying executable: "' +
             self.required_executable + '")', self.bucket_skip)
         return False
     if len(self.specs['skip_if_env']) > 0:
         env_var = self.specs['skip_if_env']
         if env_var in os.environ:
             self.setStatus(
                 'skipped (found environmental variable "' + env_var + '")',
                 self.bucket_skip)
             return False
     return True
Beispiel #4
0
import RavenUtils
import os
import subprocess
import sys
import distutils.version

# Set this outside the class because the framework directory is constant for
#  each instance of this Tester, and in addition, there is a problem with the
#  path by the time you call it in __init__ that causes it to think its absolute
#  path is somewhere under tests/framework.
# Be aware that if this file changes its location, this variable should also be
#  changed.
myDir = os.path.dirname(os.path.realpath(__file__))
RAVEN_DIR = os.path.abspath(os.path.join(myDir, '..', '..', '..', 'framework'))

_missing_modules, _too_old_modules, _notQAModules = RavenUtils.checkForMissingModules(
)


class RavenFramework(Tester):
    @staticmethod
    def validParams():
        params = Tester.validParams()
        params.addRequiredParam('input',
                                "The input file to use for this test.")
        params.addParam('output', '',
                        "List of output files that the input should create.")
        params.addParam('csv', '', "List of csv files to check")
        params.addParam('UnorderedCsv', '',
                        "List of unordered csv files to check")
        params.addParam('xml', '', "List of xml files to check")
        params.addParam('UnorderedXml', '',