mirror of
https://github.com/google/benchmark.git
synced 2024-11-28 05:44:40 +00:00
add multiple OSes to bazel workflow (#1412)
* add multiple OSes to bazel workflow * correct indent * only set copts when they're supported by the OS * os check should work * pull out cxx03_test for per-platform stuff * attempt to fix windows test output
This commit is contained in:
parent
920fa14898
commit
2365c4a603
15
.github/workflows/bazel.yml
vendored
15
.github/workflows/bazel.yml
vendored
|
@ -5,9 +5,14 @@ on:
|
||||||
pull_request: {}
|
pull_request: {}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test:
|
job:
|
||||||
runs-on: ubuntu-latest
|
name: bazel.${{ matrix.os }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, macos-latest, windows-2022]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
|
|
||||||
|
@ -17,9 +22,9 @@ jobs:
|
||||||
cache-name: bazel-cache
|
cache-name: bazel-cache
|
||||||
with:
|
with:
|
||||||
path: "~/.cache/bazel"
|
path: "~/.cache/bazel"
|
||||||
key: ${{ env.cache-name }}-${{ runner.os }}-${{ github.ref }}
|
key: ${{ env.cache-name }}-${{ matrix.os }}-${{ github.ref }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ env.cache-name }}-${{ runner.os }}-main
|
${{ env.cache-name }}-${{ matrix.os }}-main
|
||||||
|
|
||||||
- name: build
|
- name: build
|
||||||
run: |
|
run: |
|
||||||
|
|
52
test/BUILD
52
test/BUILD
|
@ -1,3 +1,12 @@
|
||||||
|
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
|
||||||
|
|
||||||
|
platform(
|
||||||
|
name = "windows",
|
||||||
|
constraint_values = [
|
||||||
|
"@platforms//os:windows",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
TEST_COPTS = [
|
TEST_COPTS = [
|
||||||
"-pedantic",
|
"-pedantic",
|
||||||
"-pedantic-errors",
|
"-pedantic-errors",
|
||||||
|
@ -11,11 +20,10 @@ TEST_COPTS = [
|
||||||
"-fstrict-aliasing",
|
"-fstrict-aliasing",
|
||||||
]
|
]
|
||||||
|
|
||||||
PER_SRC_COPTS = ({
|
# Some of the issues with DoNotOptimize only occur when optimization is enabled
|
||||||
"cxx03_test.cc": ["-std=c++03"],
|
PER_SRC_COPTS = {
|
||||||
# Some of the issues with DoNotOptimize only occur when optimization is enabled
|
|
||||||
"donotoptimize_test.cc": ["-O3"],
|
"donotoptimize_test.cc": ["-O3"],
|
||||||
})
|
}
|
||||||
|
|
||||||
TEST_ARGS = ["--benchmark_min_time=0.01"]
|
TEST_ARGS = ["--benchmark_min_time=0.01"]
|
||||||
|
|
||||||
|
@ -26,14 +34,15 @@ PER_SRC_TEST_ARGS = ({
|
||||||
"spec_arg_verbosity_test.cc" : ["--v=42"],
|
"spec_arg_verbosity_test.cc" : ["--v=42"],
|
||||||
})
|
})
|
||||||
|
|
||||||
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
|
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "output_test_helper",
|
name = "output_test_helper",
|
||||||
testonly = 1,
|
testonly = 1,
|
||||||
srcs = ["output_test_helper.cc"],
|
srcs = ["output_test_helper.cc"],
|
||||||
hdrs = ["output_test.h"],
|
hdrs = ["output_test.h"],
|
||||||
copts = TEST_COPTS,
|
copts = select({
|
||||||
|
"//:windows": [],
|
||||||
|
"//conditions:default": TEST_COPTS,
|
||||||
|
}),
|
||||||
deps = [
|
deps = [
|
||||||
"//:benchmark",
|
"//:benchmark",
|
||||||
"//:benchmark_internal_headers",
|
"//:benchmark_internal_headers",
|
||||||
|
@ -46,7 +55,10 @@ cc_library(
|
||||||
size = "small",
|
size = "small",
|
||||||
srcs = [test_src],
|
srcs = [test_src],
|
||||||
args = TEST_ARGS + PER_SRC_TEST_ARGS.get(test_src, []),
|
args = TEST_ARGS + PER_SRC_TEST_ARGS.get(test_src, []),
|
||||||
copts = TEST_COPTS + PER_SRC_COPTS.get(test_src, []),
|
copts = select({
|
||||||
|
"//:windows": [],
|
||||||
|
"//conditions:default": TEST_COPTS,
|
||||||
|
}) + PER_SRC_COPTS.get(test_src, []) ,
|
||||||
deps = [
|
deps = [
|
||||||
":output_test_helper",
|
":output_test_helper",
|
||||||
"//:benchmark",
|
"//:benchmark",
|
||||||
|
@ -62,15 +74,37 @@ cc_library(
|
||||||
["*test.cc"],
|
["*test.cc"],
|
||||||
exclude = [
|
exclude = [
|
||||||
"*_assembly_test.cc",
|
"*_assembly_test.cc",
|
||||||
|
"cxx03_test.cc",
|
||||||
"link_main_test.cc",
|
"link_main_test.cc",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "cxx03_test",
|
||||||
|
size = "small",
|
||||||
|
srcs = ["cxx03_test.cc"],
|
||||||
|
copts = TEST_COPTS + ["-std=c++03"],
|
||||||
|
deps = [
|
||||||
|
":output_test_helper",
|
||||||
|
"//:benchmark",
|
||||||
|
"//:benchmark_internal_headers",
|
||||||
|
"@com_google_googletest//:gtest",
|
||||||
|
"@com_google_googletest//:gtest_main",
|
||||||
|
],
|
||||||
|
target_compatible_with = select({
|
||||||
|
"//:windows": ["@platforms//:incompatible"],
|
||||||
|
"//conditions:default": [],
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
cc_test(
|
cc_test(
|
||||||
name = "link_main_test",
|
name = "link_main_test",
|
||||||
size = "small",
|
size = "small",
|
||||||
srcs = ["link_main_test.cc"],
|
srcs = ["link_main_test.cc"],
|
||||||
copts = TEST_COPTS,
|
copts = select({
|
||||||
|
"//:windows": [],
|
||||||
|
"//conditions:default": TEST_COPTS,
|
||||||
|
}),
|
||||||
deps = ["//:benchmark_main"],
|
deps = ["//:benchmark_main"],
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,7 +17,7 @@ static int AddContextCases() {
|
||||||
AddCases(TC_ConsoleErr,
|
AddCases(TC_ConsoleErr,
|
||||||
{
|
{
|
||||||
{"^%int-%int-%intT%int:%int:%int[-+]%int:%int$", MR_Default},
|
{"^%int-%int-%intT%int:%int:%int[-+]%int:%int$", MR_Default},
|
||||||
{"Running .*/reporter_output_test(\\.exe)?$", MR_Next},
|
{"Running .*(/|\\\\)reporter_output_test(\\.exe)?$", MR_Next},
|
||||||
{"Run on \\(%int X %float MHz CPU s?\\)", MR_Next},
|
{"Run on \\(%int X %float MHz CPU s?\\)", MR_Next},
|
||||||
});
|
});
|
||||||
AddCases(TC_JSONOut,
|
AddCases(TC_JSONOut,
|
||||||
|
|
Loading…
Reference in a new issue