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:
Dominic Hamon 2022-06-13 17:45:20 +01:00 committed by GitHub
parent 920fa14898
commit 2365c4a603
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 15 deletions

View File

@ -5,9 +5,14 @@ on:
pull_request: {}
jobs:
build-and-test:
runs-on: ubuntu-latest
job:
name: bazel.${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-2022]
steps:
- uses: actions/checkout@v1
@ -17,9 +22,9 @@ jobs:
cache-name: bazel-cache
with:
path: "~/.cache/bazel"
key: ${{ env.cache-name }}-${{ runner.os }}-${{ github.ref }}
key: ${{ env.cache-name }}-${{ matrix.os }}-${{ github.ref }}
restore-keys: |
${{ env.cache-name }}-${{ runner.os }}-main
${{ env.cache-name }}-${{ matrix.os }}-main
- name: build
run: |

View File

@ -1,3 +1,12 @@
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
platform(
name = "windows",
constraint_values = [
"@platforms//os:windows",
],
)
TEST_COPTS = [
"-pedantic",
"-pedantic-errors",
@ -11,11 +20,10 @@ TEST_COPTS = [
"-fstrict-aliasing",
]
PER_SRC_COPTS = ({
"cxx03_test.cc": ["-std=c++03"],
# Some of the issues with DoNotOptimize only occur when optimization is enabled
# Some of the issues with DoNotOptimize only occur when optimization is enabled
PER_SRC_COPTS = {
"donotoptimize_test.cc": ["-O3"],
})
}
TEST_ARGS = ["--benchmark_min_time=0.01"]
@ -26,14 +34,15 @@ PER_SRC_TEST_ARGS = ({
"spec_arg_verbosity_test.cc" : ["--v=42"],
})
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
cc_library(
name = "output_test_helper",
testonly = 1,
srcs = ["output_test_helper.cc"],
hdrs = ["output_test.h"],
copts = TEST_COPTS,
copts = select({
"//:windows": [],
"//conditions:default": TEST_COPTS,
}),
deps = [
"//:benchmark",
"//:benchmark_internal_headers",
@ -46,7 +55,10 @@ cc_library(
size = "small",
srcs = [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 = [
":output_test_helper",
"//:benchmark",
@ -62,15 +74,37 @@ cc_library(
["*test.cc"],
exclude = [
"*_assembly_test.cc",
"cxx03_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(
name = "link_main_test",
size = "small",
srcs = ["link_main_test.cc"],
copts = TEST_COPTS,
copts = select({
"//:windows": [],
"//conditions:default": TEST_COPTS,
}),
deps = ["//:benchmark_main"],
)

View File

@ -17,7 +17,7 @@ static int AddContextCases() {
AddCases(TC_ConsoleErr,
{
{"^%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},
});
AddCases(TC_JSONOut,