While asserting some runfiles, I needed to do something like:
target.runfiles().contains_at_least([
<ends with "/foo">,
<ends with "/foo.exe">
])
Unfortunately, there isn't a great way to do this.
At the least, I think these convenience methods need to be added:
.paths() -> CollectionSubject[str]: returns all the runfiles paths that are represented.
.path_map() -> DictSubject[str, File|None]: returns a mapping of path to File (or None, in the case of .empty_filenames). Unfortunately, this is, potentially, a lossy operation -- a symlink could have the same path as a regular file entry. So we would want to match Bazel's behavior for how it handles such cases as best we can.
And these two lower-level accessors need to be added:
.files() -> DepsetFileSubject: returns the Runfiles.file value as a subject
.empty_filenames() -> CollectionSubject[str]: Returns Runfiles.empty_filenames as a subject
.symlinks() -> DepsetSubject[SymlinkEntry]: Returns Runfiles.symlinks as a subject
.root_symlinks() -> DepsetSubject[SymlinKEntry]: Returns Runfiles.root_symlinks as a subject
I'm not sure how to best directly expose other methods because a runfiles object is a heterogenous collection -- Files, symlink entries, and str (empty file names). I think matching on the str paths is about the best we can do -- its the common denominator. For a more specific check, the other accessors can be used (e.g. to check that something is a symlink).