Skip to content

Commit a8104fd

Browse files
committed
feat: improve snapshot::match_with_placeholder
1 parent d46213d commit a8104fd

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,4 @@ jobs:
131131
- name: Run Tests
132132
run: |
133133
docker run --rm -v "$(pwd)":/project -w /project nixos/nix:latest \
134-
nix-shell -p bash gnumake git --run "./bashunit --simple tests/"
134+
nix-shell -p bash --run "./bashunit --simple tests/"

src/assert_snapshot.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ function snapshot::match_with_placeholder() {
2020
return
2121
fi
2222

23+
if grep -P '' </dev/null >/dev/null 2>&1; then
24+
printf '%s\0' "$actual" | grep -Pzo "$regex" >/dev/null
25+
return
26+
fi
27+
2328
# fallback: only supports single-line ignores
2429
local pattern="${snapshot//$placeholder/.+}"
2530
pattern=$(printf '%s' "$pattern" | sed -e 's/[][\.^$*+?{}|()]/\\&/g')

0 commit comments

Comments
 (0)