From fa76b6e215c2b846ca0fe1c75dcb40d22dda3158 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 2 Sep 2025 11:16:31 -0400 Subject: [PATCH] nix store benchmarks: Only get unit test dir from env var --- src/libstore-tests/derivation-parser-bench.cc | 16 ++++------------ src/libstore-tests/meson.build | 11 +++++++---- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/libstore-tests/derivation-parser-bench.cc b/src/libstore-tests/derivation-parser-bench.cc index 61c9807a6..1709eed1c 100644 --- a/src/libstore-tests/derivation-parser-bench.cc +++ b/src/libstore-tests/derivation-parser-bench.cc @@ -51,18 +51,10 @@ static void BM_UnparseRealDerivationFile(benchmark::State & state, const std::st // Register benchmarks for actual test derivation files if they exist BENCHMARK_CAPTURE( - BM_ParseRealDerivationFile, - hello, - getEnvNonEmpty("_NIX_TEST_UNIT_DATA").value_or(NIX_UNIT_TEST_DATA) + "/derivation/hello.drv"); + BM_ParseRealDerivationFile, hello, getEnvNonEmpty("_NIX_TEST_UNIT_DATA").value() + "/derivation/hello.drv"); BENCHMARK_CAPTURE( - BM_ParseRealDerivationFile, - firefox, - getEnvNonEmpty("_NIX_TEST_UNIT_DATA").value_or(NIX_UNIT_TEST_DATA) + "/derivation/firefox.drv"); + BM_ParseRealDerivationFile, firefox, getEnvNonEmpty("_NIX_TEST_UNIT_DATA").value() + "/derivation/firefox.drv"); BENCHMARK_CAPTURE( - BM_UnparseRealDerivationFile, - hello, - getEnvNonEmpty("_NIX_TEST_UNIT_DATA").value_or(NIX_UNIT_TEST_DATA) + "/derivation/hello.drv"); + BM_UnparseRealDerivationFile, hello, getEnvNonEmpty("_NIX_TEST_UNIT_DATA").value() + "/derivation/hello.drv"); BENCHMARK_CAPTURE( - BM_UnparseRealDerivationFile, - firefox, - getEnvNonEmpty("_NIX_TEST_UNIT_DATA").value_or(NIX_UNIT_TEST_DATA) + "/derivation/firefox.drv"); + BM_UnparseRealDerivationFile, firefox, getEnvNonEmpty("_NIX_TEST_UNIT_DATA").value() + "/derivation/firefox.drv"); diff --git a/src/libstore-tests/meson.build b/src/libstore-tests/meson.build index fced20269..4c2840ab7 100644 --- a/src/libstore-tests/meson.build +++ b/src/libstore-tests/meson.build @@ -130,10 +130,13 @@ if get_option('benchmarks') link_args : linker_export_flags, install : true, cpp_pch : do_pch ? [ 'pch/precompiled-headers.hh' ] : [], - cpp_args : [ - '-DNIX_UNIT_TEST_DATA="' + meson.current_source_dir() + '/data"', - ], ) - benchmark('nix-store-benchmarks', benchmark_exe) + benchmark( + 'nix-store-benchmarks', + benchmark_exe, + env : { + '_NIX_TEST_UNIT_DATA' : meson.current_source_dir() / 'data', + }, + ) endif