Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions cvs/cli_plugins/copy_config_plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .base import SubcommandPlugin
from cvs.extension import ExtensionConfig
from cvs.lib.utils_lib import cvs_package_root
import os
import shutil

Expand Down Expand Up @@ -49,8 +50,7 @@ def _find_config_root(self):
1. Core cvs package (cvs/input/config_file, cvs/input/cluster_file, cvs/input/env_file)
2. Extension packages configured via extension.ini (e.g., cvs_extension/input)
"""
plugin_dir = os.path.dirname(__file__)
cvs_dir = os.path.dirname(plugin_dir) # cvs/
cvs_dir = cvs_package_root()
config_root = os.path.join(cvs_dir, "input", "config_file")
cluster_root = os.path.join(cvs_dir, "input", "cluster_file")
env_root = os.path.join(cvs_dir, "input", "env_file")
Expand Down
5 changes: 2 additions & 3 deletions cvs/lib/run_config_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ def resolve_runner_results_base(run_config: dict) -> str:


def _cvs_baseline_data_dir() -> str:
import cvs
from cvs.lib.utils_lib import cvs_package_root

root = os.path.dirname(os.path.abspath(cvs.__file__))
return os.path.normpath(os.path.join(root, "baseline_data"))
return os.path.normpath(os.path.join(cvs_package_root(), "baseline_data"))


def resolve_baseline_csv_folder(run_config: dict) -> Optional[str]:
Expand Down
9 changes: 9 additions & 0 deletions cvs/lib/unittests/test_utils_lib.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# cvs/lib/unittests/test_utils_lib.py
import os
import unittest
from unittest.mock import patch

import cvs
import cvs.lib.utils_lib as utils_lib
from cvs.parsers.schemas import AortaBenchmarkConfigFile

Expand All @@ -19,6 +21,13 @@ def test_scan_test_results_no_failure(self, mock_fail_test):
utils_lib.scan_test_results(out_dict)
mock_fail_test.assert_not_called()

def test_cvs_package_root_matches_cvs_module_directory(self):
expected = os.path.dirname(os.path.abspath(cvs.__file__))
self.assertEqual(utils_lib.cvs_package_root(), expected)

def test_cvs_package_root_contains_input_dir(self):
self.assertTrue(os.path.isdir(os.path.join(utils_lib.cvs_package_root(), 'input')))


class TestResolveTestConfigPlaceholdersAorta(unittest.TestCase):
"""Aorta benchmark YAML uses the same resolver as other CVS test suites (see tests/benchmark/test_aorta.py)."""
Expand Down
12 changes: 12 additions & 0 deletions cvs/lib/utils_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
log = globals.log


def cvs_package_root():
"""Absolute path to the installed/editable cvs package directory.

This is the root cvs/input/, cvs/tests/, cvs/baseline_data/, etc. hang off
of -- not the repo root and not the process cwd -- so it resolves the same
way whether cvs was pip-installed or run from an editable checkout.
"""
import cvs

return os.path.dirname(os.path.abspath(cvs.__file__))


def fail_test(msg):
"""
Record and report a test failure without immediately raising an exception.
Expand Down