Use python imports to identify fixtures (part 3/6)#5703
Merged
cognifloyd merged 5 commits intomasterfrom Aug 17, 2022
Merged
Conversation
23ac68d to
e3ca0a5
Compare
3b03303 to
9a1eeec
Compare
30c2b0e to
a13542a
Compare
It only worked for st2tests.fixtures.packs, but we need to use it for other packs dirs as well.
a13542a to
216129e
Compare
cognifloyd
commented
Aug 17, 2022
Comment on lines
-336
to
-341
| FIXTURES_PACK = "generic" | ||
| TEST_FIXTURES = { | ||
| "runners": ["testrunner1.yaml"], | ||
| "actions": ["action1.yaml", "local.yaml"], | ||
| } | ||
|
|
Member
Author
There was a problem hiding this comment.
These vars are unused. So I removed them.
cognifloyd
commented
Aug 17, 2022
Comment on lines
172
to
+175
| def get_fixture_name_and_path(fixture_file): | ||
| pack_name = os.path.basename(os.path.dirname(fixture_file)) | ||
| pack_path = os.path.join(get_fixtures_packs_base_path(), pack_name) | ||
| return pack_name, pack_path | ||
| fixture_path = os.path.dirname(fixture_file) | ||
| fixture_name = os.path.basename(fixture_path) | ||
| return fixture_name, fixture_path |
Member
Author
There was a problem hiding this comment.
I adjusted this method to make it more generic, so we can use it for pack fixtures that are not in st2tests/st2tests/fixtures/packs.
I also renamed the vars to highlight that this is not specific to packs.
nzlosh
approved these changes
Aug 17, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
I'm working towards introducing
pants. Eventually I would like to use pants to run tests to take advantage of the fine-grained per-file caching of results that accounts for dependencies by python files (pants infers the deps by reading the python files).In order to use the fine-grained caching, Pants needs to know which tests rely on which fixtures. We could add extra metadata to tie the tests to the fixtures, but that would be an additional maintenance burden that will become out-of-date. We can also include all fixtures for all tests, but then we don't benefit from the fine-grained per-file caching. However, pants can already infer dependencies based on python imports, so that is what this PR (and several follow-up PRs) takes advantage of.
Overview
This PR does the following:
st2tests/st2tests/fixturesloader.pyso that we can use those utilities to identify pack fixtures in directories outside ofst2tests/st2tests/fixtures/packs.__init__.py.fixture.pyfile in each fixture that uses the fixturesloader utils (where helpful) to identify itself withPATHandNAMEvars.PATHand/orNAMEvars from that fixture.This PR focuses on only fixture packs that are in:
st2tests/st2tests/fixtures/packs_1/,st2tests/st2tests/fixtures/packs_invalid/andst2tests/st2tests/fixtures/.Follow-up PRs will address other fixture packs and other sets of fixtures. I will submit those PRs after this one is merged.
Statistics
Changes Summary:
st2tests/st2tests/fixturesloader.pyfixture.py(16 lines, 13 of which are copyright/license header):16*11=+176 lines-103 +93lines changed in test files to use the new fixture vars.-6 lines: remove unused vars in one test file