Files
scylladb/test/__init__.py
Andrei Chekun 13770ab394 test.py: delete dead code in test.py
With the latest changes, there are a lot of code that is redundant in
the test.py. This PR just cleans this code.
Changes in other files are related to cleaning code from the test.py,
especially with redundant parameter --test-py-init and moving
prepare_environment to pytest itself.
2026-04-16 22:08:31 +02:00

49 lines
1.5 KiB
Python

#
# Copyright (C) 2025-present ScyllaDB
#
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.1
#
import hashlib
import socket
import time
import os
from pathlib import Path
__all__ = ["ALL_MODES", "BUILD_DIR", "DEBUG_MODES", "HOST_ID", "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"}
MODES_TIMEOUT_FACTOR = {"release": 1, "sanitize": 3, "debug": 3, "dev": 2, "coverage": 1}
HOST_ID = os.environ.get("SCYLLA_TEST_HOST_ID")
if HOST_ID is None:
HOST_ID = hashlib.sha3_224((socket.gethostname() + str(time.time())).encode("utf-8")).hexdigest()[:5]
os.environ["SCYLLA_TEST_HOST_ID"] = HOST_ID
def path_to(mode: str, *components: str) -> str:
"""Resolve path to built executable."""
# cmake places build.ninja in build/, traditional is in ./.
# We choose to test for traditional, not cmake, because IDEs may
# invoke cmake to learn the configuration and generate false positives
if not TOP_SRC_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))