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

lints: better test utils, avoid accessing lint.Lints directly #364

Merged
merged 6 commits into from
Jan 17, 2020

Conversation

cpu
Copy link
Member

@cpu cpu commented Jan 17, 2020

This is a follow up from #337 addressing the use of lint.Lints throughout the unit tests. This in turn will unblock switching lint.Lints to be unexported which will give the project more freedom to restructure for #344.

At a high level:

  • I removed the testlint/testDef directory. I'm not sure what it was used for historically but it appears unused today.
  • I flattened the testlint/testCerts directory into just testdata/ at the root of the project. All of the test files are certs and I think this is a little bit cleaner.
  • I moved the existing test helpers from util/testTools.go to a dedicated test package. That makes it clearer that only unit tests should be consuming things from that package vs util which is used by lint logic.
  • I reworked the test helpers, adding a new test.TestLint function that is used by the vast majority of the unit tests to load a cert from the test dir and execute a lint with a given name. Presently this function uses the lint.Lints map directly but now we have 1 place to update when that field is no longer exported instead of 200+.

This is a big diff, but it should be a functional no-op (only unit tests and test data are changed).

@cpu cpu requested a review from zakird January 17, 2020 22:14
@cpu cpu self-assigned this Jan 17, 2020
@cpu cpu changed the title lints: better test utils, avoid accessing lint.Lints in unit tests. lints: better test utils, avoid accessing lint.Lints directly Jan 17, 2020
@cpu
Copy link
Member Author

cpu commented Jan 17, 2020

Files changed 844

😭 Sorry @zakird!

@zakird zakird merged commit 2cce203 into zmap:master Jan 17, 2020
@cpu cpu deleted the cpu-lint-test-utils branch January 18, 2020 17:32
cpu pushed a commit to cpu/zlint that referenced this pull request Jan 19, 2020
I had left this commit with some additional comments out of zmap#364 by
mistake.
cpu pushed a commit to cpu/zlint that referenced this pull request Jan 19, 2020
I had left this commit with some additional comments out of zmap#364 by
mistake.
zakird pushed a commit that referenced this pull request Jan 19, 2020
I had left this commit with some additional comments out of #364 by
mistake.
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