GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [ggj][infra][3/5] feat: implement update golden bazel rules for dummy test by xiaozhenliu-gg5 · Pull Request #314 · googleapis/sdk-platform-java

This repository was archived by the owner on Oct 29, 2026. It is now read-only.

Conversation

@xiaozhenliu-gg5

@xiaozhenliu-gg5 xiaozhenliu-gg5 commented Sep 18, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Find more details in design doc: go/java-micro-file-diff-infra

  1. Added rules_bazel/java_diff_test.bzl where update_golden bazel rule is defined, including two parts: running JUnit test and overwritting goldens.
  2. Added SingleJUnitTestRunner which helps us to manually trigger the JUnit test, it takes test_class_name as arg and emits test result if any failure is detected.
  3. Added Utils.java in test/framework which helps to save the generated code from JUnit test to tmp file in folder $TEST_OUTPUT_HOME. System environment is set to interact with update golden bazel rules, the folder will get deleted once the bazel rules finish.
  4. update_golden rule is called from BUILD.bazel in dummy test, and junit_runner_binary is defined for running the JUnit test when updating goldens.

How we use it (check out this branch and modify the dummy/goldens/*.golden)

> bazel test //...
Tests have failures: [classWithHeader(com.google.api.generator.gapic.dummy.FileDiffInfraDummyTest): Differences found: 
--- golden
+++ codegen
@@ -17,3 +17,3 @@
 package com.google.showcase.v1beta1.stub;
 
-public class  {}
+public class EchoStubSettings {}]
//src/test/java/com/google/api/generator/gapic/dummy:FileDiffInfraDummyTest FAILED in 5.6s
  /private/var/tmp/_bazel_xiaozhenliu/27d546162d4fdfcb8b9c40b4c5bf4971/execroot/com_google_api_codegen/bazel-out/darwin-fastbuild/testlogs/src/test/java/com/google/api/generator/gapic/dummy/FileDiffInfraDummyTest/test.log


> bazel run //src/test/java/com/google/api/generator/gapic/dummy:FileDiffInfraDummyTest_update
> bazel test //...
.....
Executed 53 out of 66 tests: 66 tests pass.

Next step would be:

  1. Move the existing expected class string to file-diff infra, including
    (a)gapic/composer/*Test.
    (b)engine/astIntegrationTest
  2. Update developer doc to include this instruction for updating goldens.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
xiaozhenliu-gg5 added 30 commits September 8, 2020 17:56
@xiaozhenliu-gg5
add fileDiffUtils
42db152
@xiaozhenliu-gg5
add new dummy unit test
7c4b6a7
@xiaozhenliu-gg5
format
f42d269
@xiaozhenliu-gg5
add assertUtils
7224b5a
@xiaozhenliu-gg5
format
62ddbe6
@xiaozhenliu-gg5
move dummy test to separate folder
d9fbb0a
@xiaozhenliu-gg5
add compare strings method in diffUtils
0e63a94
@xiaozhenliu-gg5
format
076ef47
@xiaozhenliu-gg5
Merge branch 'dummy_test' of github.com:googleapis/gapic-generator-ja…
760b0a9
…va into java_diff_util
@xiaozhenliu-gg5
dummy test pass
25ce9ec
@xiaozhenliu-gg5
reformat
6f54239
@xiaozhenliu-gg5
merge
cf90743
@xiaozhenliu-gg5
add simple strings comparison
e3563b9
@xiaozhenliu-gg5
add java_diff_test bzl
2ff169e
@xiaozhenliu-gg5
group test framework helpers together
7cc8219
@xiaozhenliu-gg5
Merge branch 'java_diff_util' of github.com:googleapis/gapic-generato…
ec51871
…r-java into update_golden
@xiaozhenliu-gg5
run testRunner
2fce32e
@xiaozhenliu-gg5
format
306eb83
@xiaozhenliu-gg5
run single JUnit test and save output
53da6c4
@xiaozhenliu-gg5
add copy of golden
509746b
@xiaozhenliu-gg5
format
20b3b1f
@xiaozhenliu-gg5
working pipeline
3af8ba7
@xiaozhenliu-gg5
format
9e438ad
@xiaozhenliu-gg5
clean up
4c542c7
@xiaozhenliu-gg5
get codegen in local_tmp
6e08814
@xiaozhenliu-gg5
format
f6de85e
@xiaozhenliu-gg5
add golden path to bazel rules
b04ea6b
@xiaozhenliu-gg5
working pipeline
15e26e3
@xiaozhenliu-gg5
format
eb2f931
@xiaozhenliu-gg5
work!
278ade1
xiaozhenliu-gg5 added 3 commits September 19, 2020 14:57
@xiaozhenliu-gg5
feedback
f5f9ba9
@xiaozhenliu-gg5
clean
19d791c
@xiaozhenliu-gg5
comment
5ccd3ea
@xiaozhenliu-gg5
xiaozhenliu-gg5 requested a review from miraleung September 19, 2020 22:21
vam-google
vam-google reviewed Sep 22, 2020
View reviewed changes

@vam-google vam-google left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good. I left quite a few comments, but most of them are minor and/or optional.

My only real concern is the general structure of the BUILD.bazel files (if we don't be careful here, we may end up in a very verbose layout, with many BUILD files everywhere and many targets being redeclared in each BUILD file, which will be very difficult to maintain).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

xiaozhenliu-gg5 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread dependencies.properties Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread rules_bazel/java/java_diff_test.bzl Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread rules_bazel/java/java_diff_test.bzl Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/test/java/com/google/api/generator/gapic/dummy/BUILD.bazel Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/test/java/com/google/api/generator/gapic/dummy/BUILD.bazel Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/test/java/com/google/api/generator/test/framework/SingleJUnitTestRunner.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/test/java/com/google/api/generator/test/framework/Utils.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/test/java/com/google/api/generator/test/framework/Utils.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/test/java/com/google/api/generator/test/framework/Utils.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/test/java/com/google/api/generator/test/framework/Utils.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

xiaozhenliu-gg5 added 3 commits September 22, 2020 11:26
@xiaozhenliu-gg5
bazel rules feedbacj
a51f0ce
@xiaozhenliu-gg5
java code feedback
f230b09
@xiaozhenliu-gg5
move dependency
b51775d
miraleung
miraleung reviewed Sep 22, 2020
View reviewed changes

@miraleung miraleung left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good. I left quite a few comments, but most of them are minor and/or optional.

My only real concern is the general structure of the BUILD.bazel files (if we don't be careful here, we may end up in a very verbose layout, with many BUILD files everywhere and many targets being redeclared in each BUILD file, which will be very difficult to maintain).

The motivation for the BUILD file structure in this repo is to keep individual repos self-contained (following google3 style), so the proliferation of files is fine.

Otherwise +1 to Vadym's comments below.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread rules_bazel/java/java_diff_test.bzl Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread rules_bazel/java/java_diff_test.bzl Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread rules_bazel/java/java_diff_test.bzl Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/test/java/com/google/api/generator/test/framework/Utils.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

xiaozhenliu-gg5 added 3 commits September 22, 2020 22:10
@xiaozhenliu-gg5
clean up
6f8d04b
@xiaozhenliu-gg5
merge master
f18c8cc
@xiaozhenliu-gg5
comment
d364be4
@xiaozhenliu-gg5
xiaozhenliu-gg5 requested review from miraleung and vam-google September 22, 2020 22:22
xiaozhenliu-gg5 added 3 commits September 23, 2020 17:52
@xiaozhenliu-gg5
move hamcrest dep back
c681dc1
@xiaozhenliu-gg5
Merge branch 'master' of github.com:googleapis/gapic-generator-java i…
1dc6ff3
…nto update_golden_bazel
@xiaozhenliu-gg5
add helpers in Utils
f91ee2c
@xiaozhenliu-gg5 xiaozhenliu-gg5 mentioned this pull request Sep 23, 2020
[ggj][infra][4/5]feat: move the expected string in unit test to golden files #279
Merged
miraleung
miraleung approved these changes Sep 24, 2020
View reviewed changes
Comment thread rules_bazel/java/java_diff_test.bzl Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread rules_bazel/java/java_diff_test.bzl Resolved

Uh oh!

There was an error while loading. Please reload this page.

@xiaozhenliu-gg5
xiaozhenliu-gg5 merged commit 26611d7 into master Sep 24, 2020
@xiaozhenliu-gg5
xiaozhenliu-gg5 deleted the update_golden_bazel branch September 24, 2020 17:40
@miraleung

miraleung commented Oct 2, 2020

Copy link
Copy Markdown
Contributor

From a clean client, I tried running this update command, and got the error below, plus lots of warnings. Seems that this isn't working and requires each incremental target to be built first, whereas it should all just work with bazel run. I'll fix these issues too.

bazel run //src/test/java/com/google/api/generator/gapic/dummy:FileDiffInfraDummyTest_update

Target //src/test/java/com/google/api/generator/gapic/dummy:FileDiffInfraDummyTest_update up-to-date:
  bazel-bin/src/test/java/com/google/api/generator/gapic/dummy/FileDiffInfraDummyTest_update.sh
INFO: Elapsed time: 8.211s, Critical Path: 0.06s
INFO: 0 processes.
INFO: Build completed successfully, 4 total actions
INFO: Build completed successfully, 4 total actions
unzip:  cannot find or open bazel-out/k8-fastbuild/bin/src/test/java/com/google/api/generator/gapic/dummy/FileDiffInfraDummyTest_update_output.zip, bazel-out/k8-fastbuild/bin/src/test/java/com/google/api/generator/gapic/dummy/FileDiffInfraDummyTest_update_output.zip.zip or bazel-out/k8-fastbuild/bin/src/test/java/com/google/api/generator/gapic/dummy/FileDiffInfraDummyTest_update_output.zip.ZIP.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miraleung

miraleung commented Oct 3, 2020

Copy link
Copy Markdown
Contributor

Another one I found: In a clean client, I get this error, even though it updates fine:

Error occurs when reading golden file
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miraleung

miraleung commented Oct 3, 2020

Copy link
Copy Markdown
Contributor

Fixed all of these in #363.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@xiaozhenliu-gg5

xiaozhenliu-gg5 commented Oct 3, 2020

Copy link
Copy Markdown
Contributor Author

This implementation was based on the prerequisites of users running bazel test or bazel build first before updating any goldens files. The usage was described in the description, but it does not support directly bazel run testTarget_update for updating goldens before any test run.
Error occurs when reading golden file only happens when not finding/reading the goldens files, I did not have chance to repro that error, but thanks for the refactor to allow the direct usage of update_goldens.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

suztomo pushed a commit that referenced this pull request Dec 16, 2022
@gcf-owl-bot
chore: enable auto release in java (#1349) (#314)
791d77c
* chore: fix auto-release

* chore: remove codecov.yml

* chore: update license headers for yaml files
Source-Link: googleapis/synthtool@5b77727
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:ebc2104854c5b81c6fd72ca79400a2e20e0d510c5e0654fd1a19e5c9be160ca6
suztomo pushed a commit that referenced this pull request Dec 16, 2022
@release-please
chore(main): release 1.2.11 (#314)
620d0d9
🤖 I have created a release *beep* *boop*
---


### [1.2.11](googleapis/java-iam@v1.2.10...v1.2.11) (2022-03-25)


### Dependencies

* update dependency com.google.api:api-common to v2.1.5 ([#313](googleapis/java-iam#313)) ([08a700e](googleapis/java-iam@08a700e))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
suztomo pushed a commit that referenced this pull request Mar 21, 2023
@yoshi-automation
chore: remove staging bucket v2 (#314)
547ae6e
not needed since we removed v2 solution - googleapis/synthtool#964

Source-Author: Emily Ball <[email protected]>
Source-Date: Mon Mar 29 14:47:37 2021 -0700
Source-Repo: googleapis/synthtool
Source-Sha: 572ef8f70edd9041f5bcfa71511aed6aecfc2098
Source-Link: googleapis/synthtool@572ef8f
suztomo pushed a commit that referenced this pull request Mar 21, 2023
@renovate-bot
deps: update dependency org.threeten:threetenbp to v1.5.0 (#314)
35bcf4d
suztomo pushed a commit that referenced this pull request Mar 21, 2023
@release-please
chore: release 1.93.10 (#301)
6eecfdb
🤖 I have created a release \*beep\* \*boop\* 
---
### [1.93.10](https://www.github.com/googleapis/java-core/compare/v1.93.9...v1.93.10) (2020-10-30)


### Dependencies

* update core dependencies ([#294](https://www.github.com/googleapis/java-core/issues/294)) ([5f6b784](https://www.github.com/googleapis/java-core/commit/5f6b784ad94b71553d339e3450b17f70dd307e6d))
* update core transport dependencies ([#295](https://www.github.com/googleapis/java-core/issues/295)) ([39fdd06](https://www.github.com/googleapis/java-core/commit/39fdd06a84a92c2d314c9de8b1baba0cd5b6589d))
* update dependency com.google.api:api-common to v1.10.1 ([#302](https://www.github.com/googleapis/java-core/issues/302)) ([6ebd6b1](https://www.github.com/googleapis/java-core/commit/6ebd6b186dc99bc0a306e2b28150d84c6e6d8125))
* update dependency com.google.api.grpc:proto-google-iam-v1 to v1.0.2 ([#312](https://www.github.com/googleapis/java-core/issues/312)) ([e416c1c](https://www.github.com/googleapis/java-core/commit/e416c1cafdafac7165f986194a028096ff936993))
* update dependency com.google.guava:guava-bom to v30 ([#310](https://www.github.com/googleapis/java-core/issues/310)) ([1026809](https://www.github.com/googleapis/java-core/commit/1026809177b3460a7170e13cb205b8505bde1ddb))
* update dependency io.grpc:grpc-bom to v1.33.0 ([#309](https://www.github.com/googleapis/java-core/issues/309)) ([e021cb0](https://www.github.com/googleapis/java-core/commit/e021cb0943b7b538df79941f98c46cbc53633959))
* update dependency org.threeten:threetenbp to v1.4.5 ([#297](https://www.github.com/googleapis/java-core/issues/297)) ([9286f76](https://www.github.com/googleapis/java-core/commit/9286f761449ae51bd7ae4fe84494f9b987a45623))
* update dependency org.threeten:threetenbp to v1.5.0 ([#314](https://www.github.com/googleapis/java-core/issues/314)) ([35bcf4d](https://www.github.com/googleapis/java-core/commit/35bcf4d3ff1f47295a466ff37685b7b526af2b1a))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@summer-ji-eng summer-ji-eng Awaiting requested review from summer-ji-eng
@vam-google vam-google Awaiting requested review from vam-google
1 more reviewer
@miraleung miraleung miraleung approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@xiaozhenliu-gg5 @miraleung @vam-google
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.