I have some tests that use globs to access other d...
# general
p
I have some tests that use globs to access other directories of files, so I’m adding a dependency from the tests to a new
target()
with dependencies on the subdirs. That should ensure the glob is satisfied for the tests. Here is the directory and the
target()
I’m adding for it: https://github.com/StackStorm/st2/tree/master/st2tests/st2tests/fixtures/packs https://github.com/StackStorm/st2/pull/5874/files#diff-0a765a0e1409bcce280bee085bd5903e219b4c63a442696f8d23216a525d882a But, I am afraid (and I’ve got feedback from others who are afraid) of not keeping the
target()
dependencies up-to-date as people add new directories. Can I use globs in
dependencies
to avoid that? And if yes, can I use
!
to ignore a couple of directories so they are not direct dependencies (but transitive is fine)?
1
e
Can you not use a naming convention and a high (in the filesystem) target to ensure stability?
p
I’m not sure I understand. How would a naming convention help here?
e
Dependency globs have not been permitted historically because it is
import *
👍 1
If all dirs containing files are named
packs
use *`**/packs/**` from a BUILD in repo root*
p
Hmm. In each of these subdirectories, I added an
__init__.py
and a
fixture.py
with a constant. That python target then depends on the resources targets that are contained in the fixture. This way dependency inference brings in all the fixtures required for a test because the test imports the constant from that fixture. But, the last few tests use a glob to include a lot of the fixtures. So, I need a target that includes all of them even though it is reminiscent of
import *
. Using a higher level target that includes globs in sources would cause problems because then multiple targets would own the files, and for most tests, they only need a couple of them, so I don't want to include all of them.
I'm wondering if I'm going to have to invent a
subdir_glob()
target in a plugin to do what I want. 🤔
So, I created a new glob target to handle this.
packs_glob()
dep inference is implemented here: https://github.com/StackStorm/st2/pull/5874/files#diff-85923e3f477f36c3b348f492d5f0dc3daea954a2d35001c8c7b38485789d8aafR43-R76