Fix scripted
tests on Mac: use portable sed -i
syntax
#181
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.
On Mac OS (which is BSD-based), the following sbt
scripted
tests would fail:...with an error message like this:
The failing test line would be like this:
Unfortunately there's variation between the ways the 'optional' backup-file-extension argument for
sed
's change-in-place flag (-i
) is handled on Linux (GNU) vs Mac (BSD). GNUsed
allows you to completely omit the backup-file-extension argument, as in thesed
line above - so GitHub CI, running with Linux, passes fine!However, with BSD
sed
, you have to provide some argument to the-i
flag, even if it's just''
to indicate you want no backup at all. Consequently, on Mac the above line was interpreted as specifying a backup-file-extension ofs/versionPolicyIntention .../
(obviously very wrong), and the parser then treatedbuild.sbt
as the transformation program forsed
- starting withb
, which issed
's 'branching' command, and thenuild.sbt
as the label to branch to, thus giving theundefined label
error - it's a mess.Fix
The simplest way to get a portable
sed
command that works on both Mac OS and Linux is to just supply a backup-file-extension argument (eg.bak
), and then gitignore the resultingbuild.sbt.bak
files.https://www.thegeekstuff.com/2009/12/unix-sed-tutorial-6-examples-for-sed-branching-operation/ https://unix.stackexchange.com/a/92907/46453
https://stackoverflow.com/a/22084103/438886
With this change, the
sbt scripted
suite passes on Mac OS.