From bbaccfdaaec6a935d4b3cf9e4752fea3561f298b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 21 Jan 2024 14:58:40 +0530 Subject: [PATCH] DRYer --- kitty/simd-string.c | 4 +++- kitty_tests/main.py | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kitty/simd-string.c b/kitty/simd-string.c index 61b391fd5..5fd1a455a 100644 --- a/kitty/simd-string.c +++ b/kitty/simd-string.c @@ -119,7 +119,8 @@ init_simd(void *x) { PyObject *module = (PyObject*)x; if (PyModule_AddFunctions(module, module_methods) != 0) return false; #define A(x, val) { Py_INCREF(Py_##val); if (0 != PyModule_AddObject(module, #x, Py_##val)) return false; } -#define do_check() has_sse4_2 = __builtin_cpu_supports("sse4.2") != 0; has_avx2 = __builtin_cpu_supports("avx2") != 0; +#define do_check() { has_sse4_2 = __builtin_cpu_supports("sse4.2") != 0; has_avx2 = __builtin_cpu_supports("avx2") != 0; } + #ifdef __APPLE__ #ifdef __arm64__ // simde takes care of NEON on Apple Silicon @@ -136,6 +137,7 @@ init_simd(void *x) { do_check(); #endif #endif + #undef do_check if (has_avx2) { A(has_avx2, True); diff --git a/kitty_tests/main.py b/kitty_tests/main.py index 3ad9319a2..a1e266ae8 100644 --- a/kitty_tests/main.py +++ b/kitty_tests/main.py @@ -28,6 +28,8 @@ Tuple, ) +from . import BaseTest + def contents(package: str) -> Iterator[str]: try: @@ -269,6 +271,7 @@ def run_tests(report_env: bool = False) -> None: else: go_proc = None with env_for_python_tests(report_env): + sys.stdout.flush() run_python_tests(args, go_proc) @@ -295,7 +298,8 @@ def env_for_python_tests(report_env: bool = False) -> Iterator[None]: launcher_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'kitty', 'launcher') path = f'{launcher_dir}{os.pathsep}{path}' python_for_type_check() - if os.environ.get('CI') == 'true' or report_env: + print('Running under CI:', BaseTest.is_ci) + if BaseTest.is_ci or report_env: print('Using PATH in test environment:', path) print('Python:', python_for_type_check()) from kitty.fast_data_types import has_avx2, has_sse4_2