Hey folks, is there a recommended way to make a fi...
# plugins
c
Hey folks, is there a recommended way to make a filetree available for testing? I've currently got a scriptlet that slurps them all into a TOML file so it's just
toml.load
to get them all. Does anyone have something better? This is useful to me while comparing the output of a tool in its natural habitat and withing Pants; and for testing source file detection.
b
Are you looking just for Pants to list the names of files? Goals like
peek
and
list
are your friend, and can be filtered by tag, or by using the
filter
goal and piping+
xargs
to those other 2
c
It's more for tests. For example, if I want to run ansible-lint against files in testing, and am using the RuleRunner, I need to have all the files in memory to pass to RuleRunner.write_files . But it's more convenient to create files in a filetree, especially for adding contents to them
h
for tests, you should be able to access them like normal. Either use the resources API like
pkgutil.get_data
, or the filesystem API like
open()
But you have to declare either a `file`/`files` or `resource`/`resources` target for it, and add that as a dependency to your
python_test
/
python_tests
. No difference between those two, @bitter-ability-32190 has a proposal to simplify that
b
I think you can just copy the file tree into the sandbox that the rule runner writes the files to? (On mobile so can't verify)
c
I guess by an
os.walk
, some munging, and then
rulerunner.write_files
?