Configurable SnapshotDirectory to support Xcode cloud workflow #716
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.
Following the thread in #553 it seems there are two steps to using snapshots on Xcode cloud:
ci_scripts
directory, which is the only set of files available during a test run. This can be done via symlink.assertSnapshot
must be called with asnapshotDirectory
argument pointing to the location of the file's snapshots within theci_scripts
directory.The project I'm working with has many swift packages, many of which use snapshots. I wanted a way to run the snapshot tests on Xcode cloud without changing the local workflow.
This change allows configuration of the snapshot directory via ENV var, with an option specifically for this workflow.
1. Symlink snapshots
This script finds all
__Snapshot__
directories and symlinks them intoci_scripts/snapshots
. Run it from your project root.2. Configure the snapshots location for CI
Set an ENV var to change where the library finds snapshots:
The result is that snapshots from all packages are flattened and symlinked into the
ci_scripts
dir, thenSnapshotTesting
constructs a matching path for assertion when run via CI.