Skip to content

Commit

Permalink
Add and fix Bazel tests
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 636821161
  • Loading branch information
frigus02 authored and copybara-github committed May 24, 2024
1 parent 3b2aeda commit 1d7a729
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 61 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/ubuntu-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ concurrency:
cancel-in-progress: true

jobs:
build:
cmake:
runs-on: ubuntu-22.04
name: ubuntu-build
steps:
- name: Show env
run: env
Expand Down Expand Up @@ -46,3 +45,15 @@ jobs:
shell: bash
run: |
cmake --build build -j$(nproc)
bazel:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: bazel-contrib/[email protected]
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
- run: BAZEL_CXXOPTS="-std=c++17" bazel test //...
- run: BAZEL_CXXOPTS="-std=c++20" bazel test //...
31 changes: 1 addition & 30 deletions pybind11_protobuf/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ cc_proto_library(
deps = [":we-love-dashes_proto"],
)

py_proto_library(
name = "we-love-dashes_py_pb2",
deps = [":we-love-dashes_proto"],
)

# Tests for enum_type_caster

pybind_extension(
Expand Down Expand Up @@ -371,32 +366,8 @@ pybind_extension(
py_test(
name = "we_love_dashes_cc_only_test",
srcs = ["we_love_dashes_cc_only_test.py"],
data = [":we_love_dashes_cc_only_module.so"],
deps = [
":we_love_dashes_cc_only_module",
"@com_google_absl_py//absl/testing:absltest",
"@com_google_protobuf//:protobuf_python",
requirement("absl_py"),
],
)

py_test(
name = "we_love_dashes_cc_and_py_in_deps_test",
srcs = ["we_love_dashes_cc_and_py_in_deps_test.py"],
deps = [
":we_love_dashes_cc_only_module",
":we-love-dashes_py_pb2",
"@com_google_absl_py//absl/testing:absltest",
"@com_google_protobuf//:protobuf_python",
requirement("absl_py"),
],
)

py_test(
name = "we_love_dashes_py_only_test",
srcs = ["we_love_dashes_py_only_test.py"],
deps = [
":pass_proto2_message_module",
":we-love-dashes_py_pb2",
"@com_google_absl_py//absl/testing:absltest",
"@com_google_protobuf//:protobuf_python",
requirement("absl_py"),
Expand Down
34 changes: 5 additions & 29 deletions scripts/build_and_run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,8 @@ echo "Building and testing in $PWD using 'python' (version $PYVERSION)."

bazel clean --expunge # Force a dep update

# Currently only a subset of tests build. The next one to fix is protobuf_test
BAZEL_CXXOPTS="-std=c++17" bazel test --test_output=errors \
pybind11_protobuf/tests:extension_test \
pybind11_protobuf/tests:message_test \
pybind11_protobuf/tests:pass_by_test \
pybind11_protobuf/tests:proto_enum_test \
pybind11_protobuf/tests:wrapped_proto_module_test --enable_bzlmod

BAZEL_CXXOPTS="-std=c++20" bazel test --test_output=errors \
pybind11_protobuf/tests:extension_test \
pybind11_protobuf/tests:message_test \
pybind11_protobuf/tests:pass_by_test \
pybind11_protobuf/tests:proto_enum_test \
pybind11_protobuf/tests:wrapped_proto_module_test --enable_bzlmod

# Currently only a subset of tests build. The next one to fix is protobuf_test
BAZEL_CXXOPTS="-std=c++17" bazel test --test_output=errors \
pybind11_protobuf/tests:extension_test \
pybind11_protobuf/tests:message_test \
pybind11_protobuf/tests:pass_by_test \
pybind11_protobuf/tests:proto_enum_test \
pybind11_protobuf/tests:wrapped_proto_module_test --noenable_bzlmod

BAZEL_CXXOPTS="-std=c++20" bazel test --test_output=errors \
pybind11_protobuf/tests:extension_test \
pybind11_protobuf/tests:message_test \
pybind11_protobuf/tests:pass_by_test \
pybind11_protobuf/tests:proto_enum_test \
pybind11_protobuf/tests:wrapped_proto_module_test --noenable_bzlmod
BAZEL_CXXOPTS="-std=c++17" bazel test ... --test_output=errors "$@" --enable_bzlmod
BAZEL_CXXOPTS="-std=c++20" bazel test ... --test_output=errors "$@" --enable_bzlmod

BAZEL_CXXOPTS="-std=c++17" bazel test ... --test_output=errors "$@" --noenable_bzlmod
BAZEL_CXXOPTS="-std=c++20" bazel test ... --test_output=errors "$@" --noenable_bzlmod

0 comments on commit 1d7a729

Please sign in to comment.