Skip to content

Commit c46933e

Browse files
committed
Update integration test target
1 parent b70424a commit c46933e

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

Makefile

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,27 +143,27 @@ release:
143143

144144
## Recipes:
145145
## ---------
146-
$(INTEGRATION_TESTS): RECIPE_COMMAND_LINE = $(shell head -n 1 $(INTEGRATION_TEST_DIR)/$@)
147-
$(INTEGRATION_TESTS): CMD_RECIPE_EXPECTED = tail -n +2 $(INTEGRATION_TEST_DIR)/$@
148-
$(INTEGRATION_TESTS): CMD_RESULT = $< -f $(MAKEFILE_DOC) $(AWK_FLAGS) $(RECIPE_COMMAND_LINE)
149-
# --ignore-space-at-eol is needed as empty descriptions add OFFSET
150-
$(INTEGRATION_TESTS): CMD_DIFF = git diff --ignore-space-at-eol \
151-
<($(CMD_RECIPE_EXPECTED)) \
152-
<($(CMD_RESULT) 2>&1)
153-
$(INTEGRATION_TESTS): TMP_FILE = /tmp/$@_updated
146+
147+
# Now we redirect to actual files because making sure that stderr and stdout
148+
# appear in the righ order with all AWK variants (in particular goawk) and on
149+
# CI was problematic
150+
$(INTEGRATION_TESTS): FILE_CMD = /tmp/.makefile-doc_$@_command
151+
$(INTEGRATION_TESTS): FILE_EXPECTED = /tmp/.makefile-doc_$@_expected
152+
$(INTEGRATION_TESTS): FILE_ACTUAL = /tmp/.makefile-doc_$@_actual
153+
$(INTEGRATION_TESTS): RECIPE_CMD = $(shell head -n 1 $(INTEGRATION_TEST_DIR)/$@)
154154
$(INTEGRATION_TESTS): $(AWK_BIN)/$(AWK)
155-
# The reason for using echo "$(subst $,\$,$(RECIPE_COMMAND_LINE))" is that, the value of
156-
# RECIPE_COMMAND_LINE may contain e.g., $(TARGET) and we need to make sure that the
157-
# shell doesn't try to expand it. Unfortunately, we cannot simply use echo
158-
# '$(RECIPE_COMMAND_LINE)' because the value of RECIPE_COMMAND_LINE already contains
159-
# single quotes. While it doesn't contain doble-quotes, doing echo
160-
# "$(RECIPE_COMMAND_LINE)" is not possible because the single quotes around $(TARGET)
161-
# loose their "powers" when surrounded by double-quotes. So we have to escape the $.
155+
@echo "$(subst $,\$,$(RECIPE_CMD))" > $(FILE_CMD);
156+
@tail -n +2 $(INTEGRATION_TEST_DIR)/$@ > $(FILE_EXPECTED)
157+
@$< -f $(MAKEFILE_DOC) $(AWK_FLAGS) $(RECIPE_CMD) \
158+
> $(FILE_ACTUAL).stdout 2> $(FILE_ACTUAL).stderr || exit 0
159+
@{ cat $(FILE_ACTUAL).stderr; cat $(FILE_ACTUAL).stdout; } > $(FILE_ACTUAL)
160+
# --ignore-space-at-eol is needed as empty descriptions add OFFSET
162161
@$(if $(filter 1 yes,$(UPDATE_RECIPE)),\
163-
echo "$(subst $,\$,$(RECIPE_COMMAND_LINE))" > $(TMP_FILE);\
164-
$(CMD_RESULT)\
165-
2>&1 | tee -a $(TMP_FILE) && mv $(TMP_FILE) $(INTEGRATION_TEST_DIR)/$@,\
166-
$(CMD_DIFF) || (echo "failed $@"; exit 1) && echo "[$(notdir $<)] passed $@")
162+
{ cat $(FILE_CMD); cat $(FILE_ACTUAL); } | tee -a $(FILE_ACTUAL).recipe && \
163+
mv $(FILE_ACTUAL).recipe $(INTEGRATION_TEST_DIR)/$@,\
164+
@git diff --ignore-space-at-eol $(FILE_EXPECTED) $(FILE_ACTUAL) ||\
165+
(echo "failed $@"; exit 1) && echo "[$(notdir $<)] passed $@")
166+
@rm -f $(FILE_CMD) $(FILE_EXPECTED) $(FILE_ACTUAL)*
167167

168168
# --------------------------------------------------------------------------
169169
# Targets for downloading various awk implementations

0 commit comments

Comments
 (0)