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
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.check_for_missing_modules(False) if len(missing) + len(outOfRange) > 0 and RavenUtils.check_versions(): 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)
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
# 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')) #Need to add the directory for AMSC for doing module checks. os.environ["PYTHONPATH"] = os.path.join(RAVEN_DIR, 'contrib') +\ os.pathsep + os.environ.get("PYTHONPATH", "") _missing_modules, _too_old_modules, _notQAModules = RavenUtils.check_for_missing_modules() class RavenFramework(Tester): """ RavenFramework is the class to use for testing standard raven inputs. """ @staticmethod def get_valid_params(): """ Returns the parameters that can be used for this class. @ In, None @ Out, params, _ValidParameters, return the parameters. """ params = Tester.get_valid_params() params.add_required_param('input', "The input file to use for this test.")