I have this weird situation where I have a script
spec, which does this:
#!/bin/bash set -o pipefail && swift test "$@" 2>&1 | xcpretty -s && swiftlint --quiet
I usually use this to run tests because the output is nicer. However, sometimes there are issues where
xcpretty hides too many details, so I have to run
swift test to get all the output (e.g. log statements).
However, I observe the following behaviour:
- When I run
./specseveral times without changing the code, it only needs to compile the code the first time
- The same thing happens when I run
swift testseveral times
- However, if I run
swift test, or the other way around, it somehow needs to recompile everything (even all the dependencies). This happens every time I switch between the two commands: apparently Swift doesn't keep a separate cache for
swift test, but it just destroys the cache for one command every time I run the other command.
What could be the reason for this behaviour, and is there any way to avoid this? My project takes a long time to compile from scratch, so it would be really nice if this didn't happen.