Skip to content

Commit 7ceecea

Browse files
authored
Merge pull request #3398 from vkarak/bugfix/git-clone-stagedir-marks
[bugfix] Mark the stagedir after the copy or clone of resources
2 parents 951de2b + 4e8c06c commit 7ceecea

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

ci-scripts/dockerfiles/reframe-lmod77.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ FROM ghcr.io/reframe-hpc/lmod:7.7
77

88
# Install ReFrame unit test requirements
99
RUN apt-get -y update && \
10-
apt-get -y install gcc make python3 python3-pip
10+
apt-get -y install gcc git make python3 python3-pip
1111

1212
# ReFrame user
1313
RUN useradd -ms /bin/bash rfmuser

reframe/core/pipeline.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,6 +1780,9 @@ def setup(self, partition, environ, **job_opts):
17801780
self._setup_container_platform()
17811781
self._resolve_fixtures()
17821782

1783+
def _mark_stagedir(self):
1784+
(Path(self.stagedir) / '.rfm_mark').touch()
1785+
17831786
def _requires_stagedir_contents(self):
17841787
'''Return true if the contents of the stagedir need to be generated'''
17851788

@@ -1788,12 +1791,7 @@ def _requires_stagedir_contents(self):
17881791
# `--dont-restage` is passed. In this case, we want to leave the
17891792
# existing stagedir untouched.
17901793

1791-
mark = Path(self.stagedir) / '.rfm_mark'
1792-
if mark.exists():
1793-
return False
1794-
else:
1795-
mark.touch()
1796-
return True
1794+
return not (Path(self.stagedir) / '.rfm_mark').exists()
17971795

17981796
def _copy_to_stagedir(self, path):
17991797
self.logger.debug(f'Copying {path} to stage directory')
@@ -1804,13 +1802,16 @@ def _copy_to_stagedir(self, path):
18041802
)
18051803
except (OSError, ValueError, TypeError) as e:
18061804
raise PipelineError('copying of files failed') from e
1805+
else:
1806+
self._mark_stagedir()
18071807

18081808
def _clone_to_stagedir(self, url):
18091809
self.logger.debug(f'Cloning URL {url} into stage directory')
18101810
osext.git_clone(
18111811
self.sourcesdir, self._stagedir,
18121812
timeout=rt.runtime().get_option('general/0/git_timeout')
18131813
)
1814+
self._mark_stagedir()
18141815

18151816
@final
18161817
def compile(self):

unittests/test_pipeline.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,23 @@ def validate(self):
763763
_run(MyTest(), *local_exec_ctx)
764764

765765

766+
def test_sourcesdir_git(local_exec_ctx):
767+
@test_util.custom_prefix('unittests/resources/checks')
768+
class MyTest(rfm.RunOnlyRegressionTest):
769+
sourcesdir = 'https://github.com/reframe-hpc/ci-hello-world.git'
770+
executable = 'true'
771+
valid_systems = ['*']
772+
valid_prog_environs = ['*']
773+
keep_files = ['README.md']
774+
775+
@sanity_function
776+
def validate(self):
777+
print(self.stagedir)
778+
return sn.assert_true(os.path.exists('README.md'))
779+
780+
_run(MyTest(), *local_exec_ctx)
781+
782+
766783
def test_sourcesdir_none_generated_sources(local_exec_ctx):
767784
@test_util.custom_prefix('unittests/resources/checks')
768785
class MyTest(rfm.RegressionTest):

unittests/test_utility.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,8 @@ def test_is_interactive(monkeypatch):
428428

429429

430430
def test_is_url():
431-
repo_https = 'https://github.com/reframe-hpc/reframe.git'
432-
repo_ssh = '[email protected]:reframe-hpc/reframe.git'
431+
repo_https = 'https://github.com/reframe-hpc/ci-hello-world.git'
432+
repo_ssh = '[email protected]:reframe-hpc/ci-hello-world.git'
433433
assert osext.is_url(repo_https)
434434
assert not osext.is_url(repo_ssh)
435435

0 commit comments

Comments
 (0)