Skip to content

Conversation

@chanseokoh
Copy link
Contributor

Now we can completely remove the rules_bazel folder.

To generate a golden file, all we have to do is to run a unit test, because those unit tests are written to generate and save a golden. For example,

  @Test
  public void generateGrpcServiceStubClass_createBatchingCallable() {
    ...
    // Generate a golden while running this test.
    Utils.saveCodegenToFile(this.getClass(), "GrpcLoggingStub.golden", visitor.write());
    ...
    Assert.assertCodeEquals(goldenFilePath, visitor.write());
  }

I think this is better than my previous attempt: #911

@chanseokoh chanseokoh requested a review from a team January 26, 2022 23:33
@chanseokoh chanseokoh requested a review from a team as a code owner January 26, 2022 23:33
@codecov
Copy link

codecov bot commented Jan 26, 2022

Codecov Report

Merging #912 (81f1bbe) into main (d210aa1) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #912   +/-   ##
=======================================
  Coverage   87.84%   87.84%           
=======================================
  Files         153      153           
  Lines       16046    16046           
  Branches     1166     1166           
=======================================
  Hits        14095    14095           
  Misses       1607     1607           
  Partials      344      344           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d210aa1...81f1bbe. Read the comment docs.

# Generate the goldens from tests.
generate_goldens_script = """
mkdir local_tmp
TEST_OUTPUT_HOME="$(pwd)/local_tmp" {test_runner_path} $@
Copy link
Contributor Author

@chanseokoh chanseokoh Jan 27, 2022

Choose a reason for hiding this comment

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

FTR: this is the line running SingleJUnitTestRunner.

{test_runner_path} $@ is roughly

java -cp ... com.google.api.generator.test.framework.SingleJUnitTestRunner <SomeUnitTestClass>

as shown here. All it does is to run unit tests (i.e., @Test methods) in <SomeUnitTestClass>. (Unit tests in the class should be designed to save a golden file.)

@chanseokoh chanseokoh merged commit 8ae5f31 into main Jan 27, 2022
@chanseokoh chanseokoh deleted the direct-golden-update branch January 27, 2022 16:31
suztomo pushed a commit that referenced this pull request Dec 16, 2022
* chore: re-work generating unit goldens
* chore: clean up code
suztomo pushed a commit that referenced this pull request Mar 21, 2023
suztomo pushed a commit that referenced this pull request Mar 21, 2023
🤖 I have created a release *beep* *boop*
---


## [2.8.11](googleapis/java-core@v2.8.10...v2.8.11) (2022-09-08)


### Dependencies

* Update dependency com.google.auth:google-auth-library-bom to v1.11.0 ([#911](googleapis/java-core#911)) ([e7d4513](googleapis/java-core@e7d4513))

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants