forked from pulp-platform/Deeploy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaths.py
More file actions
48 lines (37 loc) · 1.54 KB
/
paths.py
File metadata and controls
48 lines (37 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# SPDX-FileCopyrightText: 2025 ETH Zurich and University of Bologna
#
# SPDX-License-Identifier: Apache-2.0
from pathlib import Path
from typing import Optional, Tuple
from Deeploy.Logging import DEFAULT_LOGGER as log
def get_test_paths(test_dir: str, platform: str, base_dir: Optional[str] = None) -> Tuple[str, str, str]:
"""
Resolve test paths for generation and build directories.
Args:
test_dir: Path to test directory (e.g., "Tests/Adder" or absolute path)
platform: Platform name (e.g., "Generic")
base_dir: Base directory for tests (defaults to DeeployTest/)
Returns:
Tuple of (gen_dir, test_dir_abs, test_name)
"""
if base_dir is None:
# Get the absolute path of this script's parent directory (core -> testUtils -> DeeployTest)
script_path = Path(__file__).resolve()
base_dir = script_path.parent.parent.parent
else:
base_dir = Path(base_dir)
test_path = Path(test_dir)
if not test_path.is_absolute():
test_path = base_dir / test_dir
test_path = test_path.resolve()
test_name = test_path.name
gen_dir_name = f"TEST_{platform.upper()}"
# Check if path is inside base_dir
try:
rel_path = test_path.relative_to(base_dir)
gen_dir = base_dir / gen_dir_name / rel_path
except ValueError:
# Path is outside base_dir
gen_dir = base_dir / gen_dir_name / test_name
log.warning(f"Test path {test_path} is outside base directory. Using {gen_dir}")
return str(gen_dir), str(test_path), test_name