Add path constants to `test` module and use them in different test suites instead of own dups of the same code: - TOP_SRC_DIR : ScyllaDB's source code root directory - TEST_DIR : the directory with test.py tests and libs - BUILD_DIR : directory with ScyllaDB's build artefacts Add TestSuite.log_dir attribute as a ScyllaDB's build mode subdir of a path provided using `--tmpdir` CLI argument. Don't use `tmpdir` name because it mixed up with pytest's built-in fixture and `--tmpdir` option itself. Change default value for `--tmdir` from `./testlog` to `TOP_SRC_DIR/testlog` Refactor `ResourceGather*` classes to use path from a `test` object instead of providing it separately. Move modes constants to `test` module and remove duplications. Move `prepare_dirs()` and `start_3rd_party_services()` from `pylib.util` to `pylib.suite.base` to avoid circular imports (with little refactoring to use `pathlib.Path` instead of `str` as paths.) Also, in some places refactor to use f-strings for formatting.
36 lines
981 B
Python
36 lines
981 B
Python
#
|
|
# Copyright (C) 2025-present ScyllaDB
|
|
#
|
|
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
|
#
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
__all__ = ["ALL_MODES", "BUILD_DIR", "DEBUG_MODES", "TEST_DIR", "TEST_RUNNER", "TOP_SRC_DIR", "path_to"]
|
|
|
|
|
|
TEST_RUNNER = os.environ.get("SCYLLA_TEST_RUNNER", "pytest")
|
|
|
|
TOP_SRC_DIR = Path(__file__).parent.parent # ScyllaDB's source code root directory
|
|
TEST_DIR = TOP_SRC_DIR / "test"
|
|
BUILD_DIR = TOP_SRC_DIR / "build"
|
|
|
|
ALL_MODES = {
|
|
"debug": "Debug",
|
|
'release': "RelWithDebInfo",
|
|
"dev": "Dev",
|
|
"sanitize": "Sanitize",
|
|
"coverage": "Coverage",
|
|
}
|
|
DEBUG_MODES = {"debug", "sanitize"}
|
|
|
|
|
|
def path_to(mode: str, *components: str) -> str:
|
|
"""Resolve path to built executable."""
|
|
|
|
if BUILD_DIR.joinpath("build.ninja").exists():
|
|
*dir_components, basename = components
|
|
return str(BUILD_DIR.joinpath(*dir_components, ALL_MODES[mode], basename))
|
|
return str(BUILD_DIR.joinpath(mode, *components))
|