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

improve testdata files folder content #48

Open
ccoVeille opened this issue Feb 9, 2025 · 3 comments
Open

improve testdata files folder content #48

ccoVeille opened this issue Feb 9, 2025 · 3 comments

Comments

@ccoVeille
Copy link
Contributor

ccoVeille commented Feb 9, 2025

Here is the current testdata folder structure

testdata/src
├── bool-format
│   ├── p.go
│   └── p.go.golden
├── default
│   ├── p.go
│   └── p.go.golden
├── err-error
│   ├── p.go
│   └── p.go.golden
├── errorf
│   ├── p.go
│   └── p.go.golden
├── error-format
│   ├── p.go
│   └── p.go.golden
(...)

Each p.go file contains a version of testdata/src/default/p.go that is slightly altered.

It's a burden to maintain the content of these files, I experienced it by working on

I think code should be split into multiple file, for example one per type

integer.go
integer.go.golden
hex.go
hex.go.golden
bool.go
bool.go.golden
...
negative.go.golden
negative.go.golden
malformed.go.golden
malformed.go.golden
  • integer.go would be about the code that is likely to be affected by integer-format in p.go
  • hex.go would be about the code that is likely to be affected by hex-format in p.go
  • ...
  • negative.go would be about the code currently in func negative() in p.go
  • malformed.go would be about the code currently in func malformed() in p.go

We could also consider using a different naming for file when they are altered

so testdata/src/default would contain

integer.go
integer.go.golden
hex.go
hex.go.golden
bool.go
bool.go.golden
...
negative.go.golden
negative.go.golden
malformed.go.golden
malformed.go.golden

While testdata/src/hex-format would contain

integer.go
integer.go.golden
hex_deactivated.go
hex_deactivated.go.golden
bool.go
bool.go.golden
...
negative.go.golden
negative.go.golden
malformed.go.golden
malformed.go.golden

This could prepare the work of generating the testdata and golden files, but it's not the purpose of this issue

Note

Note: This change is not directly linked to #47, but they will have to be done one after the other to avoid conflicts.

@catenacyber
Copy link
Owner

I think the best would be to have a unique p.go file and have the right tooling to update all the golden test files for all options

@ccoVeille
Copy link
Contributor Author

I preferred my approach of having two files per checker:

  • one with option activated
  • one with checker deactivated

The invariant files that are should catch nothing. Then a way to copy the right file at the right place.

But why not. My problem is that generating test and golden files is never fun.

It's better to do not reinvent the wheel. Let's reuse something that exists

Any idea how to that @alexandear @mmorel-35 ?

@alexandear
Copy link
Contributor

Any idea how to that

Thanks for improving testdata folder. I haven't contributed much to this repo, so I'm not in a position to make decisions about the preferred approach.

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

No branches or pull requests

3 participants