Skip to content

Commit 64a84f6

Browse files
committed
Add support for running the unit tests offline
1 parent acb62bc commit 64a84f6

5 files changed

Lines changed: 19 additions & 0 deletions

File tree

test_reframe.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
parser = argparse.ArgumentParser(
2929
add_help=False,
3030
usage='%(prog)s [REFRAME_OPTIONS...] [NOSE_OPTIONS...]')
31+
parser.add_argument(
32+
'--rfm-offline', action='store_true',
33+
help='Skip unit tests that require Internet access'
34+
)
3135
parser.add_argument(
3236
'--rfm-user-config', action='store', metavar='FILE',
3337
help='Config file to use for native unit tests.'
@@ -47,6 +51,7 @@
4751

4852
test_util.USER_CONFIG_FILE = user_config
4953
test_util.USER_SYSTEM = options.rfm_user_system
54+
test_util.OFFLINE = options.rfm_offline
5055
test_util.init_runtime()
5156

5257
# If no positional argument is specified, use the `unittests` directory,

unittests/test_ci.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from reframe.core.exceptions import ReframeError
1717
from reframe.frontend.loader import RegressionCheckLoader
1818

19+
import unittests.utility as test_util
20+
1921

2022
def _generate_test_cases(checks):
2123
return dependencies.toposort(
@@ -30,6 +32,9 @@ def hello_test():
3032

3133

3234
def test_ci_gitlab_pipeline():
35+
if test_util.OFFLINE:
36+
pytest.skip('offline tests requested')
37+
3338
loader = RegressionCheckLoader([
3439
'unittests/resources/checks_unlisted/deps_complex.py'
3540
])

unittests/test_pipeline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,9 @@ def validate(self):
769769

770770

771771
def test_sourcesdir_git(local_exec_ctx):
772+
if test_util.OFFLINE:
773+
pytest.skip('offline tests requested')
774+
772775
@test_util.custom_prefix('unittests/resources/checks')
773776
class MyTest(rfm.RunOnlyRegressionTest):
774777
sourcesdir = 'https://github.com/reframe-hpc/ci-hello-world.git'

unittests/test_utility.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,9 @@ def test_git_repo_hash_no_git_repo(git_only, monkeypatch, tmp_path):
476476

477477

478478
def test_git_repo_exists(git_only):
479+
if test_util.OFFLINE:
480+
pytest.skip('offline tests requested')
481+
479482
assert osext.git_repo_exists('https://github.com/reframe-hpc/reframe.git',
480483
timeout=10)
481484
assert not osext.git_repo_exists('reframe.git', timeout=10)

unittests/utility.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
USER_CONFIG_FILE = None
3737
USER_SYSTEM = None
3838

39+
# Skip unit tests requiring Internet access
40+
OFFLINE = False
41+
3942

4043
def init_runtime():
4144
site_config = config.load_config('unittests/resources/config/settings.py')

0 commit comments

Comments
 (0)