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

update linker tests to have descriptive names #27

Merged
merged 3 commits into from
Sep 15, 2022

Conversation

pkwarren
Copy link
Member

Update linker table driven tests to have descriptive names and run with t.Run (for easier targeting/debugging of a single test). Enable the 'paralleltest' linter which will ensure that all tests can run in parallel and we properly reassign variables inside a loop so they run properly in parallel.

Update linker table driven tests to have descriptive names and run with
t.Run (for easier targeting/debugging of a single test). Enable the
'paralleltest' linter which will ensure that all tests can run in
parallel and we properly reassign variables inside a loop so they run
properly in parallel.
@pkwarren pkwarren requested a review from jhump September 14, 2022 22:51
@@ -58,7 +58,6 @@ linters:
- nilerr
- nilnil
- nonamedreturns
- paralleltest
Copy link
Member Author

Choose a reason for hiding this comment

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

Enabled every test to run in parallel.

compiler_test.go Show resolved Hide resolved
},
{
map[string]string{
Copy link
Member Author

Choose a reason for hiding this comment

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

This test was duplicated (same input) as another one above so removed it.

if tc.errMsg == "" {
if err != nil {
t.Errorf("case %d: expecting no error; instead got error %q", i, err)
assert.Truef(t, strings.HasPrefix(name, expectedPrefix), "expected test name %q to have %q prefix", name, expectedPrefix)
Copy link
Member Author

Choose a reason for hiding this comment

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

This felt nice to enforce some consistency in naming.

type msg struct {
pos ast.SourcePos
text string
}
var msgs []msg
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved this into the tests - otherwise it led to a race condition.

Copy link
Member

@jhump jhump left a comment

Choose a reason for hiding this comment

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

This looks great!

compiler_test.go Show resolved Hide resolved
compiler_test.go Outdated Show resolved Hide resolved
linker/descriptors_test.go Outdated Show resolved Hide resolved
options/options_test.go Outdated Show resolved Hide resolved
linker/linker_test.go Outdated Show resolved Hide resolved
pkwarren and others added 2 commits September 15, 2022 09:23
Co-authored-by: Joshua Humphries <jhumphries@buf.build>
@pkwarren pkwarren merged commit aae326a into main Sep 15, 2022
@pkwarren pkwarren deleted the pkw/TCN-389-linker-test-names branch September 15, 2022 14:30
@bufbuild bufbuild deleted a comment from linear bot Sep 16, 2022
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