test.py: Move get configured modes to common lib
This will allow using this method inside the test module for pytest launching the boost and unit tests
This commit is contained in:
17
test.py
17
test.py
@@ -42,7 +42,7 @@ from test.pylib.pool import Pool
|
||||
from test.pylib.s3_proxy import S3ProxyServer
|
||||
from test.pylib.s3_server_mock import MockS3Server
|
||||
from test.pylib.resource_gather import setup_cgroup, run_resource_watcher, get_resource_gather
|
||||
from test.pylib.util import LogPrefixAdapter
|
||||
from test.pylib.util import LogPrefixAdapter, get_configured_modes, ninja
|
||||
from test.pylib.scylla_cluster import ScyllaServer, ScyllaCluster, get_cluster_manager, merge_cmdline_options
|
||||
from test.pylib.minio_server import MinioServer
|
||||
from typing import Dict, List, Callable, Any, Iterable, Optional, Awaitable, Union
|
||||
@@ -167,15 +167,6 @@ def path_to(mode, *components):
|
||||
return os.path.join(build_dir, mode, *components)
|
||||
|
||||
|
||||
def ninja(target):
|
||||
"""Build specified target using ninja"""
|
||||
build_dir = 'build'
|
||||
args = ['ninja', target]
|
||||
if os.path.exists(os.path.join(build_dir, 'build.ninja')):
|
||||
args = ['ninja', '-C', build_dir, target]
|
||||
return subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0].decode()
|
||||
|
||||
|
||||
class TestSuite(ABC):
|
||||
"""A test suite is a folder with tests of the same type.
|
||||
E.g. it can be unit tests, boost tests, or CQL tests."""
|
||||
@@ -1786,11 +1777,7 @@ def parse_cmd_line() -> argparse.Namespace:
|
||||
|
||||
if not args.modes:
|
||||
try:
|
||||
out = ninja('mode_list')
|
||||
# [1/1] List configured modes
|
||||
# debug release dev
|
||||
args.modes = re.sub(r'.* List configured modes\n(.*)\n', r'\1',
|
||||
out, count=1, flags=re.DOTALL).split("\n")[-1].split(' ')
|
||||
args.modes = get_configured_modes()
|
||||
except Exception:
|
||||
print(palette.fail("Failed to read output of `ninja mode_list`: please run ./configure.py first"))
|
||||
raise
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#
|
||||
# SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
|
||||
#
|
||||
import re
|
||||
import subprocess
|
||||
from collections.abc import Coroutine
|
||||
import threading
|
||||
import time
|
||||
@@ -10,7 +12,8 @@ import asyncio
|
||||
import logging
|
||||
import pathlib
|
||||
import os
|
||||
import pytest
|
||||
from functools import cache
|
||||
|
||||
import random
|
||||
import string
|
||||
|
||||
@@ -255,3 +258,21 @@ async def wait_for_first_completed(coros: list[Coroutine]):
|
||||
t.cancel()
|
||||
for t in done:
|
||||
await t
|
||||
|
||||
|
||||
def ninja(target):
|
||||
"""Build specified target using ninja"""
|
||||
build_dir = 'build'
|
||||
args = ['ninja', target]
|
||||
if os.path.exists(os.path.join(build_dir, 'build.ninja')):
|
||||
args = ['ninja', '-C', build_dir, target]
|
||||
return subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0].decode()
|
||||
|
||||
|
||||
@cache
|
||||
def get_configured_modes():
|
||||
out = ninja('mode_list')
|
||||
# [1/1] List configured modes
|
||||
# debug release dev
|
||||
return re.sub(r'.* List configured modes\n(.*)\n', r'\1',
|
||||
out, count=1, flags=re.DOTALL).split('\n')[-1].split(' ')
|
||||
|
||||
Reference in New Issue
Block a user