Skip to content

Refactor the test goldens so they have standard file name extensions #1014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 5, 2025

Conversation

devoncarew
Copy link
Collaborator

@devoncarew devoncarew commented May 28, 2025

Refactor the test goldens so they have standard file name extensions:

Done as a few separate commits for easier review.

@devoncarew devoncarew changed the title Refactor our test goldens so they have std file name extensions Refactor the test goldens so they have standard file name extensions May 29, 2025
@devoncarew devoncarew requested a review from osa1 May 30, 2025 15:56
@devoncarew
Copy link
Collaborator Author

@osa1 - do you mind reviewing this (and / or #1017)?

Copy link
Member

@osa1 osa1 left a comment

Choose a reason for hiding this comment

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

Added inline comments. We should check that goldens are formatted as we have to read them, that's the only way to make sure they're as expected. And then they protect against unintended changes to generated code. Every time there's a change, you have to read it and check whether the changes are as expected. Because we read them, they need to be formatted.

Other than that LGTM.

- group:
- format
Copy link
Member

Choose a reason for hiding this comment

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

We want golden files to be formatted because we read them and manually check that they're as expected.

So we commit a golden file that's not properly formatted it makes sense for it to cause a CI failure so that we can fix it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will be a little challenging as some of the goldens are file fragments - the formatter fails on them. I'll do some investigation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated! We now:

  • re-added the formatting verification check on the CI
  • when generating and comparing golden output, we check against the post-format output
  • adjusted one test golden (test/goldens/extension.pb.dart) to be a full dart file and not a dart fragment; the formatter wasn't able to parse the dart fragment

Copy link
Collaborator Author

@devoncarew devoncarew left a comment

Choose a reason for hiding this comment

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

updated to validate test goldens using the formatted output

- group:
- format
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will be a little challenging as some of the goldens are file fragments - the formatter fails on them. I'll do some investigation.

- group:
- format
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated! We now:

  • re-added the formatting verification check on the CI
  • when generating and comparing golden output, we check against the post-format output
  • adjusted one test golden (test/goldens/extension.pb.dart) to be a full dart file and not a dart fragment; the formatter wasn't able to parse the dart fragment

@devoncarew devoncarew merged commit 32d53da into google:master Jun 5, 2025
16 checks passed
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Jun 5, 2025
Revisions updated by `dart tools/rev_sdk_deps.dart`.

ai (https://github.com/dart-lang/ai/compare/6a71aeb..1d9d60c):
  1d9d60c  2025-06-05  Jacob MacDonald  handle relative paths under roots without trailing slashes (dart-lang/ai#152)

ecosystem (https://github.com/dart-lang/ecosystem/compare/8cebaf0..64aac3a):
  64aac3a  2025-06-03  Daco Harkes  [health] Bump dart_apitool (dart-lang/ecosystem#360)

i18n (https://github.com/dart-lang/i18n/compare/e44af54..43214dd):
  43214dde  2025-06-04  Moritz  Upgrade to new native_assets (dart-lang/i18n#964)

protobuf (https://github.com/dart-lang/protobuf/compare/c69077d..32d53da):
  32d53da  2025-06-05  Devon Carew  Refactor the test goldens so they have standard file name extensions (google/protobuf.dart#1014)

test (https://github.com/dart-lang/test/compare/e2ddae9..0793a2b):
  0793a2b3  2025-06-05  Agam Agarwal  Add isSorted and related matchers (dart-lang/test#2490)

tools (https://github.com/dart-lang/tools/compare/04c6849..e84cbd9):
  e84cbd9e  2025-06-04  Christophe Coevoet  [source_span] Add a test covering the highlighting of non-contiguous spans (dart-lang/tools#1666)
  700a3c4d  2025-06-04  Liam Appelbe  [coverage] Fix remaining ~0.1% flakiness (dart-lang/tools#2102)

webdev (https://github.com/dart-lang/webdev/compare/64492b2..55941b0):
  55941b0c  2025-06-05  Kevin Moore  [dwds] DRY up MD5/etag logic (dart-lang/webdev#2625)
  ab7c4d68  2025-06-05  dependabot[bot]  Bump the github-actions group across 1 directory with 3 updates (dart-lang/webdev#2593)
  f149e43f  2025-06-05  Nate Biggs  Update e2e_test expectation to look for more consistent message. (dart-lang/webdev#2630)
  80b1686b  2025-06-03  Nicholas Shahan  Fix e2e_test to work with current DDC output (dart-lang/webdev#2626)

Change-Id: I4802d7c4a7e39ba238f2f4ce0748dfa6dba9d8c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433240
Reviewed-by: Konstantin Shcheglov <[email protected]>
Commit-Queue: Devon Carew <[email protected]>
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.

consider having our golden testing files use correct file name extensions
2 participants