Skip to content

Commit

Permalink
t/Makefile: make "check-meson" work with Dash
Browse files Browse the repository at this point in the history
The "check-meson" target uses process substitution to check whether
extracted contents from "meson.build" match expected contents. Process
substitution is unportable though and thus the target will fail when
using for example Dash.

Fix this by writing data into a temporary directory.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
pks-t authored and gitster committed Dec 27, 2024
1 parent 7a3136e commit d8af27d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions t/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/test-results
/.prove
/chainlinttmp
/mesontmp
/out/
12 changes: 7 additions & 5 deletions t/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ clean-except-prove-cache: clean-chainlint

clean: clean-except-prove-cache
$(RM) -r '$(TEST_RESULTS_DIRECTORY_SQ)'
$(RM) -r mesontmp
$(RM) .prove

clean-chainlint:
Expand All @@ -116,16 +117,17 @@ check-chainlint:

check-meson:
@# awk acts up when trying to match single quotes, so we use \047 instead.
@printf "%s\n" \
@mkdir -p mesontmp && \
printf "%s\n" \
"integration_tests t[0-9][0-9][0-9][0-9]-*.sh" \
"unit_test_programs unit-tests/t-*.c" \
"clar_test_suites unit-tests/u-*.c" | \
while read -r variable pattern; do \
meson_tests=$$(awk "/^$$variable = \[\$$/ {flag=1 ; next } /^]$$/ { flag=0 } flag { gsub(/^ \047/, \"\"); gsub(/\047,\$$/, \"\"); print }" meson.build) && \
actual_tests=$$(ls $$pattern) && \
if test "$$meson_tests" != "$$actual_tests"; then \
awk "/^$$variable = \[\$$/ {flag=1 ; next } /^]$$/ { flag=0 } flag { gsub(/^ \047/, \"\"); gsub(/\047,\$$/, \"\"); print }" meson.build >mesontmp/meson.txt && \
ls $$pattern >mesontmp/actual.txt && \
if ! cmp mesontmp/meson.txt mesontmp/actual.txt; then \
echo "Meson tests differ from actual tests:"; \
diff -u <(echo "$$meson_tests") <(echo "$$actual_tests"); \
diff -u mesontmp/meson.txt mesontmp/actual.txt; \
exit 1; \
fi; \
done
Expand Down

0 comments on commit d8af27d

Please sign in to comment.