feat: allow readers to consume directories #100
Closed
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.
This is a prerequisite for #84.
Context
Currently, Allure3 readers can only consume separate files. The new XCResult reader consumes test result bundles, which are directories.
After some discussion, we've decided to allow readers to consume directories in addition to separate files.
Currently, the algorithm for processing directories is:
This PR changes it to be:
Note, that a path in step 3 now can also be a directory (which would've been skipped previously).
Interface changes
The new algorithm requires some adjustments to the reader interface. The main interface now looks like this:
The
read
function now takes a path instead of aResultFile
instance. This is because a directory can't be properly represented byResultFile
. The downside is that we can't feed an instance ofBufferedResultFile
to theread
method but we only used this in one test (which was easy to adjust). Other callers directly translate a path into aPathResultFile
instance.The PR also introduces two new helper base classes for reader implementations:
FileResultsReader
andDirectoryResultsReader
. These classes check the path before calling the underlying abstract method (readFile
andreadDirectory
respectively), which a sub-class needs to implement.All existing implementations were adjusted to be sub-classes of
FileResultsReader
. The only difference now is thatread
is now a function instead of lambda and will requirebind
if assigned to a variable (which we don't do anywhere).Dependency changes
A new dev dependency
archiver
is used to attach directories as .zip archives to Allure Report in directory reader tests. It will be useful for debugging readers likexcresult
.Other changes
fileParallelism
in the vitest config ofweb-components
; it caused flakiness due to a circular reference between TS config files viaextends
andreferences
fields. This is a workaround until we update to vitest v3 or fix the configs. More details here.