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

Reduce the noise in our golden tests #2150

Open
theunrepentantgeek opened this issue Mar 10, 2022 · 5 comments
Open

Reduce the noise in our golden tests #2150

theunrepentantgeek opened this issue Mar 10, 2022 · 5 comments
Labels
low-priority Low priority item. We'll get to it eventually. technical-debt 📈

Comments

@theunrepentantgeek
Copy link
Member

Describe the current behavior

Many of our golden tests (the ones driven by test data under v2\tools\generator\internal\codegen\testdata) are checking for the structure of the final data types, but also contain a lot of other generated code that's simply noise.

Describe the improvement

Reduce the amount of generated code so that the data structures become the focus.

Additional context

We can't just filter out all functions - tried that, it suppressed too much.

We also can't just pull out some of the pipeline stages. For one, they're often prerequisites of other stages that we do want to test. For another, a lot of our stages are ONLY tested by these golden tests (they don't have isolated unit tests of their own). The more our test pipeline resembles the actual one we use for code generation the better, because we rule out unexpected interactions between the stages.

@theunrepentantgeek
Copy link
Member Author

theunrepentantgeek commented Mar 14, 2022

Our test package already includes a fluent style API for doing assertions:

test.AssertPackagesGenerateExpectedCode(
	t, 
	finalState.definitions, 
	test.DiffWithTypes(initialState.Definitions()))

We might add more options to allow removing specific functions and/or interface implementations before generating the golden files:

test.AssertPackagesGenerateExpectedCode(
	t, 
	finalState.definitions,
	test.RemoveAll(&PropertyAssignmentFunction{}),
	test.RemoveAll(&PivotConversionFunction{}),
	test.RemoveAll(&OriginalGVKFunction{}))

These would work by pruning any functions (or interface implementations) that match the specified types.

@matthchr
Copy link
Member

This is something we're still interested in doing, but its not a high priority right now.

@matthchr
Copy link
Member

matthchr commented Jan 9, 2023

Still interested in this, but it's not a high priority currently

@matthchr matthchr added the low-priority Low priority item. We'll get to it eventually. label Jan 9, 2023
@theunrepentantgeek theunrepentantgeek modified the milestones: v2.5.0, v2.4.0 Sep 7, 2023
@matthchr matthchr modified the milestones: v2.4.0, v2.5.0 Oct 23, 2023
@theunrepentantgeek theunrepentantgeek modified the milestones: v2.6.0, v2.7.0 Dec 11, 2023
@matthchr matthchr removed this from the v2.7.0 milestone Feb 22, 2024
@matthchr
Copy link
Member

matthchr commented Apr 8, 2024

This is still something we're interested in, and related to getting rid of gojsonschema too (#1592)

@theunrepentantgeek
Copy link
Member Author

I'm still interested in doing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low-priority Low priority item. We'll get to it eventually. technical-debt 📈
Projects
Development

No branches or pull requests

2 participants