Beispiel #1
0
  def check_runnable(self):
    """
      Checks if this test can be run.
      @ In, None
      @ Out, check_runnable, boolean, If True can run this test.
    """
    i = 0
    if len(self.minimum_libraries) % 2:
      self.set_skip('skipped (libraries are not matched to versions numbers: '
                    +str(self.minimum_libraries)+')')
      return False
    while i < len(self.minimum_libraries):
      library_name = self.minimum_libraries[i]
      library_version = self.minimum_libraries[i+1]
      found, _, actual_version = RavenUtils.module_report(library_name, library_name+'.__version__')
      if not found:
        self.set_skip('skipped (Unable to import library: "'+library_name+'")')
        return False
      if distutils.version.LooseVersion(actual_version) < \
         distutils.version.LooseVersion(library_version):
        self.set_skip('skipped (Outdated library: "'+library_name+'")')
        return False
      i += 2

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

    if self.specs['requires_swig2'] and not RavenPython.has_swig2:
      self.set_skip('skipped (No swig 2.0 found)')
      return False
    missing, too_old, _ = RavenUtils.check_for_missing_modules()
    if len(missing) > 0:
      self.set_skip('skipped (Missing python modules: '+" ".join(missing)+
                    " PYTHONPATH="+os.environ.get("PYTHONPATH", "")+')')
      return False
    if len(too_old) > 0 and RavenUtils.check_versions():
      self.set_skip('skipped (Old version python modules: '+" ".join(too_old)+
                    " PYTHONPATH="+os.environ.get("PYTHONPATH", "")+')')
      return False
    for lib in self.required_libraries:
      found, _, _ = RavenUtils.module_report(lib, '')
      if not found:
        self.set_skip('skipped (Unable to import library: "'+lib+'")')
        return False
    if self.specs['python3_only'] and not RavenUtils.in_python_3():
      self.set_skip('Python 3 only')
      return False

    return True
Beispiel #2
0
 def check_runnable(self):
     """
   This method checks if the the test is runnable within the current settings
   @ In, None
   @ Out, check_runnable, boolean, If True this test can run.
 """
     missing, too_old, _ = RavenUtils.check_for_missing_modules()
     if len(missing) > 0:
         self.set_skip('skipped (Missing python modules: ' +
                       " ".join(missing) + " PYTHONPATH=" +
                       os.environ.get("PYTHONPATH", "") + ')')
         return False
     if len(too_old) > 0:
         self.set_skip('skipped (Old version python modules: ' +
                       " ".join(too_old) + " PYTHONPATH=" +
                       os.environ.get("PYTHONPATH", "") + ')')
         return False
     for lib in self.required_libraries:
         if platform.system() == 'Windows':
             lib += '.pyd'
         else:
             lib += '.so'
         if not os.path.exists(lib):
             self.set_skip('skipped (Missing library: "' + lib + '")')
             return False
     if self.specs['python3_only'] and not RavenUtils.in_python_3():
         self.set_skip('Python 3 only')
         return False
     if len(self.required_executable) > 0 and \
        not os.path.exists(self.required_executable):
         self.set_skip('skipped (Missing executable: "' +
                       self.required_executable + '")')
         return False
     try:
         if len(self.required_executable) > 0 and \
            subprocess.call([self.required_executable], stdout=subprocess.PIPE) != 0:
             self.set_skip('skipped (Failing executable: "' +
                           self.required_executable + '")')
             return False
     except Exception:
         self.set_skip('skipped (Error when trying executable: "' +
                       self.required_executable + '")')
         return False
     if len(self.specs['skip_if_env']) > 0:
         env_var = self.specs['skip_if_env']
         if env_var in os.environ:
             self.set_skip('skipped (found environmental variable "' +
                           env_var + '")')
             return False
     return True
Beispiel #3
0
  def check_runnable(self):
    """
      Checks if this test can run.
      @ In, None
      @ Out, check_runnable, boolean, if True can run this test.
    """
    missing = _missing_modules
    too_old = _too_old_modules
    # remove tests based on skipping criteria
    ## required module is missing
    if len(missing) > 0:
      self.set_fail('skipped (Missing python modules: '+" ".join(missing)+
                    " PYTHONPATH="+os.environ.get("PYTHONPATH", "")+')')
      return False
    ## required module is present, but too old
    if len(too_old) > 0  and RavenUtils.check_versions():
      self.set_fail('skipped (Old version python modules: '+" ".join(too_old)+
                    " PYTHONPATH="+os.environ.get("PYTHONPATH", "")+')')
      return False
    ## an environment varible value causes a skip
    if len(self.specs['skip_if_env']) > 0:
      env_var = self.specs['skip_if_env']
      if env_var in os.environ:
        self.set_skip('skipped (found environmental variable "'+env_var+'")')
        return False
    ## 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 False
    for lib in self.required_libraries:
      found, _, _ = RavenUtils.module_report(lib, '')
      if not found:
        self.set_skip('skipped (Unable to import library: "'+lib+'")')
        return False
    if self.specs['python3_only'] and not RavenUtils.in_python_3():
      self.set_skip('Python 3 only')
      return False

    i = 0
    if len(self.minimum_libraries) % 2:
      self.set_skip('skipped (libraries are not matched to versions numbers: '
                    +str(self.minimum_libraries)+')')
      return False
    while i < len(self.minimum_libraries):
      library_name = self.minimum_libraries[i]
      library_version = self.minimum_libraries[i+1]
      found, _, actual_version = RavenUtils.module_report(library_name, library_name+'.__version__')
      if not found:
        self.set_skip('skipped (Unable to import library: "'+library_name+'")')
        return False
      if distutils.version.LooseVersion(actual_version) < \
         distutils.version.LooseVersion(library_version):
        self.set_skip('skipped (Outdated library: "'+library_name+'")')
        return False
      i += 2

    if len(self.required_executable) > 0 and \
       not os.path.exists(self.required_executable):
      self.set_skip('skipped (Missing executable: "'+self.required_executable+'")')
      return False
    try:
      if len(self.required_executable) > 0 and \
         subprocess.call([self.required_executable], stdout=subprocess.PIPE) != 0:
        self.set_skip('skipped (Failing executable: "'+self.required_executable+'")')
        return False
    except Exception as exp:
      self.set_skip('skipped (Error when trying executable: "'
                    +self.required_executable+'")'+str(exp))
      return False
    filename_set = set()
    duplicate_files = []
    for filename in self.__get_created_files():
      if filename not in filename_set:
        filename_set.add(filename)
      else:
        duplicate_files.append(filename)
    if len(duplicate_files) > 0:
      self.set_skip('[incorrect test] duplicated files specified: '+
                    " ".join(duplicate_files))
      return False
    return True