diff options
author | Mathew Robinson <mathew.robinson@mongodb.com> | 2020-01-06 19:53:40 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2020-01-06 19:53:40 +0000 |
commit | 77fd09b418ce6f782eb6cf30568270aa76485d38 (patch) | |
tree | 5f38855ae25567d818377c360558b8af5ff94887 /site_scons/site_tools/mongo_benchmark.py | |
parent | d0671dc95e8144d5828343f7431715537945425b (diff) | |
download | mongo-77fd09b418ce6f782eb6cf30568270aa76485d38.tar.gz |
Revert "SERVER-44947 Allow test execution selection by test source file name"
Diffstat (limited to 'site_scons/site_tools/mongo_benchmark.py')
-rw-r--r-- | site_scons/site_tools/mongo_benchmark.py | 87 |
1 files changed, 51 insertions, 36 deletions
diff --git a/site_scons/site_tools/mongo_benchmark.py b/site_scons/site_tools/mongo_benchmark.py index 400512e738a..c765adba744 100644 --- a/site_scons/site_tools/mongo_benchmark.py +++ b/site_scons/site_tools/mongo_benchmark.py @@ -1,60 +1,75 @@ -# Copyright 2019 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" -Pseudo-builders for building and registering benchmarks. +"""Pseudo-builders for building and registering benchmarks. """ +import os from SCons.Script import Action - def exists(env): return True +_benchmarks = [] +def register_benchmark(env, test): + _benchmarks.append(test.path) + env.Alias('$BENCHMARK_ALIAS', test) + +def benchmark_list_builder_action(env, target, source): + ofile = open(str(target[0]), 'w') + try: + for s in _benchmarks: + print('\t' + str(s)) + ofile.write('%s\n' % s) + finally: + ofile.close() def build_benchmark(env, target, source, **kwargs): bmEnv = env.Clone() - bmEnv.InjectThirdParty(libraries=["benchmark"]) + bmEnv.InjectThirdParty(libraries=['benchmark']) - if bmEnv.TargetOSIs("windows"): + if bmEnv.TargetOSIs('windows'): bmEnv.Append(LIBS=["ShLwApi.lib"]) - libdeps = kwargs.get("LIBDEPS", []) - libdeps.append("$BUILD_DIR/mongo/unittest/benchmark_main") + libdeps = kwargs.get('LIBDEPS', []) + libdeps.append('$BUILD_DIR/mongo/unittest/benchmark_main') - kwargs["LIBDEPS"] = libdeps - kwargs["INSTALL_ALIAS"] = ["benchmarks"] + kwargs['LIBDEPS'] = libdeps + kwargs['INSTALL_ALIAS'] = ['benchmarks'] - benchmark_test_components = {"tests", "benchmarks"} - if "AIB_COMPONENT" in kwargs and not kwargs["AIB_COMPONENT"].endswith("-benchmark"): - kwargs["AIB_COMPONENT"] += "-benchmark" + benchmark_test_components = {'tests', 'benchmarks'} + if ( + 'AIB_COMPONENT' in kwargs + and not kwargs['AIB_COMPONENT'].endswith('-benchmark') + ): + kwargs['AIB_COMPONENT'] += '-benchmark' - if "AIB_COMPONENTS_EXTRA" in kwargs: - benchmark_test_components = set(kwargs["AIB_COMPONENTS_EXTRA"]).union( - benchmark_test_components - ) + if 'AIB_COMPONENTS_EXTRA' in kwargs: + benchmark_test_components = set(kwargs['AIB_COMPONENTS_EXTRA']).union(benchmark_test_components) - kwargs["AIB_COMPONENTS_EXTRA"] = benchmark_test_components + kwargs['AIB_COMPONENTS_EXTRA'] = benchmark_test_components result = bmEnv.Program(target, source, **kwargs) - bmEnv.RegisterTest("$BENCHMARK_LIST", result[0]) - bmEnv.Alias("$BENCHMARK_ALIAS", result) + bmEnv.RegisterBenchmark(result[0]) + hygienic = bmEnv.GetOption('install-mode') == 'hygienic' + if not hygienic: + installed_test = bmEnv.Install("#/build/benchmark/", result[0]) + env.Command( + target="#@{}".format(os.path.basename(installed_test[0].path)), + source=installed_test, + action="${SOURCES[0]}" + ) + else: + test_bin_name = os.path.basename(result[0].path) + env.Command( + target="#@{}".format(test_bin_name), + source=["$PREFIX_BINDIR/{}".format(test_bin_name)], + action="${SOURCES[0]}" + ) return result def generate(env): - env.TestList("$BENCHMARK_LIST", source=[]) - env.AddMethod(build_benchmark, "Benchmark") - env.Alias("$BENCHMARK_ALIAS", "$BENCHMARK_LIST") + env.Command('$BENCHMARK_LIST', env.Value(_benchmarks), + Action(benchmark_list_builder_action, "Generating $TARGET")) + env.AddMethod(register_benchmark, 'RegisterBenchmark') + env.AddMethod(build_benchmark, 'Benchmark') + env.Alias('$BENCHMARK_ALIAS', '$BENCHMARK_LIST') |