Skip to content
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

feat: introduce generated_file_test #1941

Merged
merged 2 commits into from
Jun 8, 2020

Conversation

alexeagle
Copy link
Collaborator

This is a new public API for checking in golden or snapshot files.
If you used the private golden_file_test previously, you need to rename actual to generated, golden to src, and golden_debug to src_dbg

Fixes #1893

This is a new public API for checking in golden or snapshot files.
If you used the private golden_file_test previously, you need to rename actual to generated, golden to src, and golden_debug to src_dbg

Fixes bazel-contrib#1893
return 0;
}
if (mode === '--verify') {
const unidiff = require('unidiff');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nothing needs to be done to ensure unidiff is available?

I know the @bazel/* npm packages use peerDependencies, but how does it work for rules built directly into rules_nodejs?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see @npm//unidiff is passed into the nodejs_test|binary(data), but is that the consumers @npm// and we assume the package exists?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Immediate answer is this needs some e2e test to show how it's used outside our workspace.
Yes I think that will show it's broken like you say. This rule has to be in an npm package or else unidiff has to be vendored.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That could always be a followup, wouldn't change what you've done.

Copy link
Collaborator

@gregmagolan gregmagolan left a comment

Choose a reason for hiding this comment

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

🌮
I like the naming you settled on

Add an example test for generated_file_test
@alexeagle
Copy link
Collaborator Author

@jbedard I added a second commit where I run rollup on the bin.js so unidiff gets inlined into the code. Added a test by simplifying the parcel example with a golden file rather than a spec, to prove that it works.

@alexeagle alexeagle merged commit 7b2b4cf into bazel-contrib:master Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add golden_file_test to public API
4 participants