From 264a42701a9a77dba141d9b40626fceedc339270 Mon Sep 17 00:00:00 2001 From: Bastrykov Evgeniy Date: Wed, 3 Sep 2025 11:29:20 +0400 Subject: [PATCH] Add target and filter specifications for make test --- TESTING.md | 10 +++++++++- pp/Makefile | 23 ++++++++++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/TESTING.md b/TESTING.md index da7436719..600c896d2 100644 --- a/TESTING.md +++ b/TESTING.md @@ -20,7 +20,15 @@ docker run -it -v .:/src -w /src prompp-build /bin/bash All C++ code, along with tests, is located in the `pp` directory. Within this directory, there is a `Makefile` with the `test` target. This target will compile and run all unit tests for the C++ code. -TODO: Running a specific test. +To running test in only one package use command +```sh +make test target=//:bare_bones_test +``` + +It is possible also add gtest filter to run only specific tests +```sh +make test target=//:bare_bones_test filter=BareBonesVectorAllocatedMemoryFixture.ObjectWithoutAllocatedMemoryMethod +``` ### Benchmarks diff --git a/pp/Makefile b/pp/Makefile index 3eb5ac1ee..6e9a93605 100644 --- a/pp/Makefile +++ b/pp/Makefile @@ -112,16 +112,25 @@ tidy: .PHONY: test test: ## Run all cpp tests - @$(bazel_test) --test_output=errors -- $(cc_tests) +ifdef target +ifdef filter +test: test_args := --test_arg=--gtest_filter=$(filter) +endif +else +test: target := $(cc_tests) +endif +test: + @$(bazel_test) $(test_args) --test_output=errors -- $(target) + .PHONY: coverage coverage: ## Run code coverage - ifeq ($(target),) - target := //... - lcov_directory := ./bazel-testlogs/ - else - lcov_directory := ./bazel-testlogs/$(target)/_coverage/bazel-out/ - endif +ifeq ($(target),) +coverage: target := //... +coverage: lcov_directory := ./bazel-testlogs/ +else +coverage: lcov_directory := ./bazel-testlogs/$(target)/_coverage/bazel-out/ +endif coverage: @$(bazel) coverage $(bazel_flags) --cache_test_results=no --experimental_fetch_all_coverage_outputs $(target) lcov -t "pp" -o pp.info -c -f -d $(lcov_directory) -b ./ --no-external \