I'm working on migrating some python tests from ru...
# general
p
I'm working on migrating some python tests from running via Makefile+nosetest to pants+pytest. I just came across a very odd dependency that I'm trying to figure out how to represent in BUILD metadata. Any solution has to continue working under nosetest until all tests can run under pants+pytest so that I can show that the transition has not broken any functionality. A test depends on a set of directories. The code under test is ultimately calling
os.path.isdir()
on each of the directory paths. In the git repo, each leaf of this directory tree has a
.gitignore
file with:
Copy code
*
!.gitignore
Essentially, that preserves the directory structure in git. But how do I get pants to include those directories in the pytest sandbox? Add a BUILD file with a
file()
target for each of the
.gitignore
files? Add some other file and have the
file()
target use that in sources? Or perhaps add a BUILD file with an empty
target()
in each of the leaf directories? Then the test could have an explicit dependency on some target that references the directory structure targets? Any ideas for how to deal with this somewhat cleanly?
1
b
I suspect a BUILD file with an empty
target
won't work (since it won't be connected to any files, there's nothing to prompt being materialized into the sandbox)... but I could be wrong!
file
targets for the existing git ignore files seems plausible, in that it's encoding the existing git convention. Another option would be a
files()
target with a glob like
files(sources=["**/.gitignore"])
or similar.
p
Thanks! I ended up using
resources(sources=["**/.gitignore"])
. That seems to be working well enough. 😅
👍 1