Skip to content

Commit

Permalink
chore: add test_suite for unit tests and fix minor build issues (goog…
Browse files Browse the repository at this point in the history
  • Loading branch information
chanseokoh authored Feb 8, 2022
1 parent 36f519b commit 0b7ec5b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fi
if [ $NUM_JAVA_FILES_CHANGED -gt 0 ] || [ $NUM_UNIT_GOLDEN_FILES_CHANGED -gt 0 ]
then
echo_status "Checking unit tests..."
bazel --batch test $(bazel query //... | grep ^//:unit_) --disk_cache="$BAZEL_CACHE_DIR"
bazel --batch test //:units --disk_cache="$BAZEL_CACHE_DIR"
TEST_STATUS=$?
if [ $TEST_STATUS != 0 ]
then
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
echo "The old one will disappear after 7 days."
- name: Unit Tests
run: bazel --batch test $(bazel query //... | grep ^//:unit_) --noshow_progress --test_output=errors
run: bazel --batch test //:units --noshow_progress --test_output=errors

- name: Integration Tests
run: bazel --batch test //test/integration/...
Expand Down Expand Up @@ -87,7 +87,7 @@ jobs:

- name: Generate Code Coverage Report
# Run only test targets, and not golden_update targets.
run: bazel coverage $(bazel query //... | grep ^//:unit_) --combined_report=lcov
run: bazel coverage //:units --combined_report=lcov

- name: Upload Code Coverage Report
uses: codecov/codecov-action@v2
Expand Down
7 changes: 5 additions & 2 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ java_binary(
java_binary(
name = "protoc-gen-code_generator_request_dumper",
main_class = "com.google.api.generator.debug.CodeGeneratorRequestDumper",
runtime_deps = MAIN_DEPS_DEBUG_RUNTIME_ONLY,
runtime_deps = [":protoc-gen-java_gapic"] + MAIN_DEPS_DEBUG_RUNTIME_ONLY,
)

# A binary similar to protoc-gen-java_gapic but reads the CodeGeneratorRequest
Expand All @@ -125,7 +125,7 @@ java_binary(
java_binary(
name = "code_generator_request_file_to_gapic_main",
main_class = "com.google.api.generator.debug.CodeGeneratorRequestFileToGapicMain",
runtime_deps = MAIN_DEPS_DEBUG_RUNTIME_ONLY,
runtime_deps = [":protoc-gen-java_gapic"] + MAIN_DEPS_DEBUG_RUNTIME_ONLY,
)

# another test resource
Expand All @@ -150,8 +150,11 @@ genrule(
"src/test/java/**/*.golden",
"src/test/resources/**",
]),
tags = ["small"],
) for file in glob(["src/test/java/**/*Test.java"])]

test_suite(name = "units", tags = ["small"])

# Tests that generate and save unit golden (.golden) files.
GOLDEN_UPDATING_UNIT_TESTS = [
"com.google.api.generator.engine.JavaCodeGeneratorTest",
Expand Down
4 changes: 2 additions & 2 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# that includes "java_gapic".
java_gapic_library(
name = "showcase_java_gapic",
srcs = ["//:showcase_proto_with_info"],
srcs = [":showcase_proto_with_info"],
grpc_service_config = "showcase_grpc_service_config.json",
test_deps = [
":showcase_java_grpc",
Expand Down Expand Up @@ -110,7 +110,7 @@
- Run all unit tests.

```sh
bazel test $(bazel query //... | grep ^//:unit_)
bazel test //:units
```

- Run a single unit test like `JavaCodeGeneratorTest.java`
Expand Down

0 comments on commit 0b7ec5b

Please sign in to comment.