Add test tolerance variant to nalu-wind pkg (#18455)

* Add test tolerance variant to nalu-wind pkg

* flake8 fixes
This commit is contained in:
psakievich 2020-09-02 19:31:58 -06:00 committed by GitHub
parent ced0a8f068
commit 7c0b356e79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,8 @@ class NaluWind(CMakePackage):
description='Build dependencies as shared libraries')
variant('pic', default=True,
description='Position independent code')
variant('test_tol', default='default',
description='Tolerance for regression tests')
# Third party libraries
variant('openfast', default=False,
description='Compile with OpenFAST support')
@ -122,6 +124,17 @@ def cmake_args(self):
else:
options.append('-DENABLE_TESTS:BOOL=OFF')
if self.spec.variants['test_tol'].value != 'default':
try:
test_tol = float(self.spec.variants['test_tol'].value)
if test_tol <= 0.0:
raise ValueError
options.append('-DTEST_TOLERACE:STRING={tol}'.format(
tol=test_tol))
except ValueError:
print("Specified test_tol must be a positive float. "
"Using the default.")
return options
@run_before('cmake')