Skip to content

Commit 5013d60

Browse files
committed
Add fix-test and test/tmp/* targets for updating screen
Update screen files wrt .test-result using make targets: 1. fix-test target to apply patches ``` make fix-test ``` 2. test/tmp/* target to apply patch for specific test ``` make test/tmp/diff/diff-stat-test ```
1 parent e8e6756 commit 5013d60

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

Makefile

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,16 @@ test-address-sanitizer: export TIG_ADDRESS_SANITIZER_ENABLED=yes
261261

262262
TESTS = $(sort $(shell find test -type f -name '*-test'))
263263
TESTS_TODO = $(sort $(shell find test -type f -name '*-test' -exec grep -l '\(test_todo\|-todo=\)' {} \+))
264+
TESTS_TMP = $(patsubst test/%,test/tmp/%,$(TESTS))
264265

265266
clean-test:
266267
$(Q)$(RM) -r test/tmp
267268

268269
test: clean-test $(TESTS)
269270
$(QUIET_SUMMARY)test/tools/show-results.sh
270271

272+
fix-test: $(TESTS_TMP)
273+
271274
ifneq (,$(strip $(V:@=)))
272275
export MAKE_TEST_OPTS = no-indent
273276
else
@@ -278,6 +281,29 @@ $(TESTS): PATH := $(CURDIR)/test/tools:$(CURDIR)/src:$(PATH)
278281
$(TESTS): $(EXE) test/tools/test-graph
279282
$(QUIET_TEST)$(TEST_SHELL) $@
280283

284+
$(TESTS_TMP):
285+
@ test -z "$$DEBUG" || set -x ; \
286+
if egrep -q '^ *\[FAIL\]+' $@/.test-result 2>/dev/null; then \
287+
name=$(patsubst test/tmp/%,test/%,$@); \
288+
! test -f $$name.expected || name=$$name.expected; \
289+
if git diff --quiet $$name; then \
290+
perm=$$(stat -c %a $$name); \
291+
cat $@/.test-result | { \
292+
sed -r -e 's/\x1b\[.{0,5}m//g' \
293+
-e '/^ *\[(OK|FAIL)\]+ .*/d' \
294+
-e 's/^ $$/ /' \
295+
-e "s# a/expected/\S+# a/$$name#" \
296+
-e "s# b/\S+# b/$$name#" \
297+
-e "s#^(index .*? 100)...#\1$$perm#" | { \
298+
test -n "$$DEBUG" && cat || { \
299+
git apply --verbose --ignore-whitespace --unidiff-zero && \
300+
echo "Updated for $@!" || true; \
301+
}; \
302+
}; \
303+
}; \
304+
fi; \
305+
fi
306+
281307
test-todo: MAKE_TEST_OPTS += todo
282308
test-todo: $(TESTS_TODO)
283309

@@ -295,7 +321,7 @@ site:
295321
doc-man doc-html dist distclean install install-doc \
296322
install-doc-man install-doc-html install-release-doc-html \
297323
install-release-doc-man rpm spell-check strip test \
298-
test-coverage update-docs update-headers veryclean $(TESTS)
324+
test-coverage update-docs update-headers veryclean $(TESTS) $(TESTS_TMP)
299325

300326
ifdef NO_MKSTEMPS
301327
COMPAT_CPPFLAGS += -DNO_MKSTEMPS

0 commit comments

Comments
 (0)