From 64a84f69baae77e295a298ba2d40730b4f0ecb6d Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Sun, 8 Feb 2026 19:48:25 +0100 Subject: [PATCH] Add support for running the unit tests offline --- test_reframe.py | 5 +++++ unittests/test_ci.py | 5 +++++ unittests/test_pipeline.py | 3 +++ unittests/test_utility.py | 3 +++ unittests/utility.py | 3 +++ 5 files changed, 19 insertions(+) diff --git a/test_reframe.py b/test_reframe.py index f03995c8fa..59d62d6d21 100755 --- a/test_reframe.py +++ b/test_reframe.py @@ -28,6 +28,10 @@ parser = argparse.ArgumentParser( add_help=False, usage='%(prog)s [REFRAME_OPTIONS...] [NOSE_OPTIONS...]') + parser.add_argument( + '--rfm-offline', action='store_true', + help='Skip unit tests that require Internet access' + ) parser.add_argument( '--rfm-user-config', action='store', metavar='FILE', help='Config file to use for native unit tests.' @@ -47,6 +51,7 @@ test_util.USER_CONFIG_FILE = user_config test_util.USER_SYSTEM = options.rfm_user_system + test_util.OFFLINE = options.rfm_offline test_util.init_runtime() # If no positional argument is specified, use the `unittests` directory, diff --git a/unittests/test_ci.py b/unittests/test_ci.py index ffed4f4096..4b02eb35ec 100644 --- a/unittests/test_ci.py +++ b/unittests/test_ci.py @@ -16,6 +16,8 @@ from reframe.core.exceptions import ReframeError from reframe.frontend.loader import RegressionCheckLoader +import unittests.utility as test_util + def _generate_test_cases(checks): return dependencies.toposort( @@ -30,6 +32,9 @@ def hello_test(): def test_ci_gitlab_pipeline(): + if test_util.OFFLINE: + pytest.skip('offline tests requested') + loader = RegressionCheckLoader([ 'unittests/resources/checks_unlisted/deps_complex.py' ]) diff --git a/unittests/test_pipeline.py b/unittests/test_pipeline.py index aba0800b4f..694771bba2 100644 --- a/unittests/test_pipeline.py +++ b/unittests/test_pipeline.py @@ -769,6 +769,9 @@ def validate(self): def test_sourcesdir_git(local_exec_ctx): + if test_util.OFFLINE: + pytest.skip('offline tests requested') + @test_util.custom_prefix('unittests/resources/checks') class MyTest(rfm.RunOnlyRegressionTest): sourcesdir = 'https://github.com/reframe-hpc/ci-hello-world.git' diff --git a/unittests/test_utility.py b/unittests/test_utility.py index fb0a204ebb..2ffc733810 100644 --- a/unittests/test_utility.py +++ b/unittests/test_utility.py @@ -476,6 +476,9 @@ def test_git_repo_hash_no_git_repo(git_only, monkeypatch, tmp_path): def test_git_repo_exists(git_only): + if test_util.OFFLINE: + pytest.skip('offline tests requested') + assert osext.git_repo_exists('https://github.com/reframe-hpc/reframe.git', timeout=10) assert not osext.git_repo_exists('reframe.git', timeout=10) diff --git a/unittests/utility.py b/unittests/utility.py index 5d6414ef10..f51a21e576 100644 --- a/unittests/utility.py +++ b/unittests/utility.py @@ -36,6 +36,9 @@ USER_CONFIG_FILE = None USER_SYSTEM = None +# Skip unit tests requiring Internet access +OFFLINE = False + def init_runtime(): site_config = config.load_config('unittests/resources/config/settings.py')