Skip to content

Revise use of sed in-place option in tox.ini to support testing on MacOS#2047

Merged
Ruwann merged 1 commit intospec-first:mainfrom
chrisinmtown:fix-tox-sed-macos
May 28, 2025
Merged

Revise use of sed in-place option in tox.ini to support testing on MacOS#2047
Ruwann merged 1 commit intospec-first:mainfrom
chrisinmtown:fix-tox-sed-macos

Conversation

@chrisinmtown
Copy link
Contributor

@chrisinmtown chrisinmtown commented Apr 26, 2025

sed on Linux accepts an optional value with the -i flag, a file extension to use
sed on MacOS requires a value with the -i flag, a file extension to use
credit to https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux

This change fixes the following error seen when running tox on macOS:

sed: 1: "s/"(\^|~|>=)([ 0-9])/"= ...": \2 not defined in the RE

@chrisinmtown
Copy link
Contributor Author

I didn't open an issue. I would be glad to create one if you prefer. Please comment.

@chrisinmtown chrisinmtown force-pushed the fix-tox-sed-macos branch 2 times, most recently from 0b093f3 to a6f0dfa Compare May 5, 2025 01:31
@chrisinmtown chrisinmtown changed the title Add empty argument to sed -i option in tox.ini for use on MacOS Revise use of sed in-place option in tox.ini to support testing on MacOS May 5, 2025
@chrisinmtown
Copy link
Contributor Author

chrisinmtown commented May 5, 2025

This solution gains test portability across Linux and MacOS. Please consider.

@coveralls
Copy link

coveralls commented May 5, 2025

Coverage Status

coverage: 94.354%. remained the same
when pulling aa0abe4 on chrisinmtown:fix-tox-sed-macos
into af3de6b on spec-first:main.

@chrisinmtown chrisinmtown force-pushed the fix-tox-sed-macos branch 4 times, most recently from d60f580 to 5ed35dc Compare May 10, 2025 10:04
sed on Linux accepts an optional value with the `-i` flag, a file extension to use
sed on MacOS requires a value with the `-i` flag, a file extension to use
credit to https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux
@Ruwann Ruwann force-pushed the fix-tox-sed-macos branch from 5ed35dc to aa0abe4 Compare May 28, 2025 18:07
Copy link
Member

@Ruwann Ruwann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, pipeline is green and also works on my WSL setup

min: cp pyproject.toml .pyproject.toml
min: sed -i -E 's/"(\^|~|>=)([ 0-9])/"==\2/' pyproject.toml
# sed in-place flag works on Linux and Mac, writes a .bak file
min: sed -i.bak -E 's/"(\^|~|>=)([ 0-9])/"==\2/' pyproject.toml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL about -i[SUFFIX]

@Ruwann Ruwann merged commit dd79c11 into spec-first:main May 28, 2025
9 checks passed
@chrisinmtown
Copy link
Contributor Author

Thanks @Ruwann

@chrisinmtown chrisinmtown deleted the fix-tox-sed-macos branch July 17, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants