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

Replace config.IsTestEnvironment with a configuration #10

Merged
merged 1 commit into from
Aug 4, 2023

Conversation

yuxincs
Copy link
Contributor

@yuxincs yuxincs commented Jul 26, 2023

This PR replaces the global variable config.IsTestEnvironment with a user-configuration option pretty-print (default true). Then in our TestMain setup function we set this flag to be false for testing purposes.

Depends on #9

@yuxincs yuxincs self-assigned this Jul 26, 2023
@yuxincs yuxincs force-pushed the yuxincs/add-config-analyzer branch from f065d95 to ca3a1bb Compare July 28, 2023 14:59
@yuxincs yuxincs force-pushed the yuxincs/replace-is-test-environment branch from 1bb9133 to 717021a Compare July 28, 2023 14:59
@yuxincs yuxincs force-pushed the yuxincs/add-config-analyzer branch from ca3a1bb to cb84038 Compare July 29, 2023 03:03
@yuxincs yuxincs force-pushed the yuxincs/replace-is-test-environment branch from 717021a to 64b66ac Compare July 29, 2023 03:03
@yuxincs yuxincs force-pushed the yuxincs/add-config-analyzer branch from cb84038 to cb1c20d Compare July 31, 2023 17:20
@yuxincs yuxincs force-pushed the yuxincs/replace-is-test-environment branch 4 times, most recently from 7456a3b to e92f4de Compare July 31, 2023 19:51
Base automatically changed from yuxincs/add-config-analyzer to main July 31, 2023 20:41
@yuxincs yuxincs force-pushed the yuxincs/replace-is-test-environment branch from e92f4de to 6990af9 Compare July 31, 2023 20:41
Copy link
Collaborator

@lazaroclapp lazaroclapp left a comment

Choose a reason for hiding this comment

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

Overall looks good, but do we want a test specifically to test that setting this flag has some effect, even if we disable it for the majority of the test suite?

@yuxincs yuxincs force-pushed the yuxincs/replace-is-test-environment branch 2 times, most recently from d6e0736 to fe2b512 Compare August 4, 2023 02:53
@yuxincs yuxincs force-pushed the yuxincs/replace-is-test-environment branch from fe2b512 to 4db2508 Compare August 4, 2023 03:00
@yuxincs
Copy link
Contributor Author

yuxincs commented Aug 4, 2023

Overall looks good, but do we want a test specifically to test that setting this flag has some effect, even if we disable it for the majority of the test suite?

Right, it's probably better to test it. I have added a non-parallel test to the test suite to test this functionality (since it needs to change the global config.Analyzer, and then revert it for the other tests).

Copy link
Collaborator

@lazaroclapp lazaroclapp left a comment

Choose a reason for hiding this comment

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

LGTM!

@yuxincs yuxincs merged commit 2677b5b into main Aug 4, 2023
3 checks passed
@yuxincs yuxincs deleted the yuxincs/replace-is-test-environment branch August 4, 2023 18:13
yuxincs added a commit that referenced this pull request Aug 4, 2023
This PR removes the hardcoded `nolint:nilaway` docstring check for both
files and function declarations since it is no longer necessary:

* files: we have implemented configuration analyzer in #9 which is able
to take a list of strings to ignore the analysis of a file.

* function declaration: it is mainly designed for two reasons:
* performance: we were able to use it to manually skip the analysis of a
particular function for performance reasons. However, we now have a
timeout for analysis of any particular function, hence this is no longer
required.
* error suppression: most linter drivers, especially nogo, are now
respecting `nolint`, so there is really no need to support it within the
linter itself.

Depends on #10
Comment on lines +221 to +223
// We specifically do not set this test to be parallel such that this test is run separately
// from the parallel tests. This makes it possible to set the pretty-print flag to true for
// testing and false for the other tests.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is also documented here: https://pkg.go.dev/testing#T.Parallel

sonalmahajan15 pushed a commit that referenced this pull request Aug 5, 2023
This PR replaces the global variable `config.IsTestEnvironment` with a
user-configuration option `pretty-print` (default `true`). Then in our
`TestMain` setup function we set this flag to be false for testing
purposes.

Depends on #9
sonalmahajan15 pushed a commit that referenced this pull request Aug 5, 2023
This PR removes the hardcoded `nolint:nilaway` docstring check for both
files and function declarations since it is no longer necessary:

* files: we have implemented configuration analyzer in #9 which is able
to take a list of strings to ignore the analysis of a file.

* function declaration: it is mainly designed for two reasons:
* performance: we were able to use it to manually skip the analysis of a
particular function for performance reasons. However, we now have a
timeout for analysis of any particular function, hence this is no longer
required.
* error suppression: most linter drivers, especially nogo, are now
respecting `nolint`, so there is really no need to support it within the
linter itself.

Depends on #10
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