testing: Improve replacing IP addresses in test files

There are a lot of files without patterns and running them all through
sed is quite slow.  Using grep first makes this quicker (about 0.5s per
test).  Ignoring PEM files is also helpful.
This commit is contained in:
Tobias Brunner
2024-12-03 08:43:45 +01:00
parent 1c053bc3f0
commit 3615e907f5
+2 -6
View File
@@ -194,10 +194,6 @@ function searchandreplace {
# search and replace in each found file the
# given string
#
for eachfoundfile in `find $DESTDIR -type f`
do
sed -i -e "s/$SEARCHSTRING/$REPLACESTRING/g" "$eachfoundfile"
done
grep -rlZ --exclude='*.pem' "$SEARCHSTRING" $DESTDIR | \
xargs -0 -I@ sed -i -e "s/$SEARCHSTRING/$REPLACESTRING/g" @
}