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

[glsl-in] consolidate tests #206

Merged
merged 2 commits into from
Sep 22, 2020
Merged

Conversation

pjoe
Copy link
Collaborator

@pjoe pjoe commented Sep 18, 2020

  • remove simple lex test as was covered by others
  • combine related tests to single function
  • remove redundant prefix in test names

- remove simple lex test as was covered by others
- combine related tests to single function
- remove redundant prefix in test names
@kvark
Copy link
Member

kvark commented Sep 18, 2020

Perhaps, you could refactor this some more with the ideas from 70aa8b7 ?

@pjoe
Copy link
Collaborator Author

pjoe commented Sep 21, 2020

@kvark though that does make the test code a bit cleaner, I don't like the way failures are then reported at the line number in the sub_test function, instead of at a specific 'instance' where a comparison fails. What do you think?

@kvark
Copy link
Member

kvark commented Sep 21, 2020

Could we use rust-lang/rust#72445 ?

@pjoe
Copy link
Collaborator Author

pjoe commented Sep 21, 2020

Not really sure I understand, how this would change things?

@kvark
Copy link
Member

kvark commented Sep 21, 2020

I don't like the way failures are then reported at the line number in the sub_test function

If we put [track_caller] I was thinking that the assert will report the line number of the caller, which is the sub_test. Anyhow, this can be addressed by just returning a Result in sub_test, so we don't need the fancy stuff.

@pjoe
Copy link
Collaborator Author

pjoe commented Sep 21, 2020

Ok, so the remaining question is more about asserts in loops vs. pointing to individual line.

Keeping them individual:

  • pro: will point failures to specific instance
  • con: will require a bit more code, for each token to verify

@pjoe
Copy link
Collaborator Author

pjoe commented Sep 21, 2020

As en example here is how failure looks with individual assert:
image

@kvark
Copy link
Member

kvark commented Sep 21, 2020

Seems fine to me. Are you concerned about this look?

@pjoe
Copy link
Collaborator Author

pjoe commented Sep 21, 2020

No, this is the way it looks with individual asserts (like currently). In terms of how failures are reported, this is how I'd prefer.

I'll try adding similar screenshot tomorrow for the other solution with a helper function, looping over expected tokens, and returning a Result

@kvark
Copy link
Member

kvark commented Sep 22, 2020

Just to clarify, reducing the number of #[test] functions does not mean having less asserts.

@pjoe
Copy link
Collaborator Author

pjoe commented Sep 22, 2020

Right, as it stands the PR reduces number of lexer test functions to 4, would you prefer it all the way down to 1?

The matter of number of asserts relates to using a common helper function to check against an array of expected tokens, instead of asserting them individually.

@pjoe
Copy link
Collaborator Author

pjoe commented Sep 22, 2020

As agreed on matrix, consolidated lex tests to a single function

@kvark kvark merged commit 8c48ae5 into gfx-rs:master Sep 22, 2020
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