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

lint: add rule to verify use of harness files #2367

Merged
merged 3 commits into from
Sep 27, 2019

Conversation

jugglinmike
Copy link
Contributor

Verify that every test file which references a harness file using the
"includes" directive also contains at least one reference to a value
defined in the harness file.

To support this check, extend each harness file with a list of values
which it defines.

I used this check to identify the changes in gh-2366. If you folks want to
include it upstream, then that patch should be merged first.

Prior to this commit, the tests for the linter partially depended on
project files. This coupling risks churn in the tests: if the needs of
the project change (e.g. a harness file is modified), then the linter
tests would need to be updated. It also made the tests more difficult to
understand because the input was both larger and more complicated than
necessary to exercise the relevant functionality.

Execute the tests in the context of the fixture directory and introduce
minimal support files that serve the same purpose as the corresponding
project files.
The command-line interface to Python's "unittest" module allows users to
run tests by name, e.g.

    $ test.py TestLinter.test_foo

If the tests include a period, they cannot be referenced in this way.
Rename the tests to omit the filename extension so that they may be
referenced from the command-line in this way.
Verify that every test file which references a harness file using the
"includes" directive also contains at least one reference to a value
defined in the harness file.

To support this check, extend each harness file with a list of values
which it defines.
@leobalter leobalter merged commit a1acc23 into tc39:master Sep 27, 2019
@@ -0,0 +1,65 @@
import os
Copy link
Member

Choose a reason for hiding this comment

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

I really like this check. Thanks!

@jugglinmike
Copy link
Contributor Author

I really like this check. Thanks!

Sure thing! It's a little more complicated than I first expected because we currently have inter-dependencies between harness files. That's new since the last time I contributed to the project. Making each harness file truly independent could improve the contribution experience. If we ever do that, we should simplify this check.

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