Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update WRF easyblock to avoid running tests directly in installation directory #3006

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions easybuild/easyblocks/w/wrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"""
import os
import re
import tempfile

from distutils.version import LooseVersion

Expand All @@ -44,7 +45,7 @@
from easybuild.framework.easyconfig import CUSTOM, MANDATORY
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.config import build_option
from easybuild.tools.filetools import apply_regex_substitutions, change_dir
from easybuild.tools.filetools import apply_regex_substitutions, change_dir, copy_dir, mkdir
from easybuild.tools.filetools import patch_perl_script_autoflush, read_file, which
from easybuild.tools.filetools import remove_file, symlink
from easybuild.tools.modules import get_software_root
Expand Down Expand Up @@ -370,27 +371,35 @@ def run_test():
remove_file(filename)
self.log.debug("Cleaned up file %s", filename)

tests_tmpdir = os.path.join(tempfile.gettempdir(), 'wrf-tests')
mkdir(tests_tmpdir, parents=True)

# build and run each test case individually
for test in self.testcases:

self.log.debug("Building and running test %s" % test)
self.log.info("Building and running test %s", test)

# build and install
cmd = "./compile %s %s" % (self.par, test)
run_cmd(cmd, log_all=True, simple=True)

# run test
try:
prev_dir = change_dir('run')
# copy prepared 'run' directory to a (local) temporary directory (with resolved symlinks),
# to try and avoid problems with hanging tests when running directly in installation directory
tmpdir = os.path.join(tests_tmpdir, test)
copy_dir('run', tmpdir, symlinks=False)
prev_dir = change_dir(tmpdir)

if test in ["em_fire"]:
if test in ['em_fire']:

# handle tests with subtests seperately
testdir = os.path.join("..", "test", test)
testdir = os.path.join(prev_dir, 'test', test)

for subtest in [x for x in os.listdir(testdir) if os.path.isdir(x)]:

subtestdir = os.path.join(testdir, subtest)
self.log.info("Running subtest %s of %s...", subtest, test)

# link required files
for filename in os.listdir(subtestdir):
Expand Down
Loading