From f73533aa38e5a8f3e56d1cc7d31852b0710b3e39 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Thu, 26 Mar 2020 11:37:37 +0700 Subject: [PATCH] t4124: tweak test so that non-compliant diff(1) can also be used MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The diff(1) implementation of busybox produces the unified context format even without being asked, and it cannot produce the default format, but a test in this script relies on. We could rewrite the test so that we count the lines in the postimage out of the unified context format, but the format is not supported by some implementations of diff (e.g. HP-UX). Accomodate busybox by adding a fallback code to count postimage lines in unified context output, when counting in the output in the default format finds nothing. Signed-off-by: Đoàn Trần Công Danh [jc: applied Documentation/CodingGuidelines and tweaked the log message] Signed-off-by: Junio C Hamano --- t/t4124-apply-ws-rule.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh index 971a5a7512..0ca29821ec 100755 --- a/t/t4124-apply-ws-rule.sh +++ b/t/t4124-apply-ws-rule.sh @@ -52,6 +52,13 @@ test_fix () { # find touched lines $DIFF file target | sed -n -e "s/^> //p" >fixed + # busybox's diff(1) doesn't output normal format + if ! test -s fixed + then + $DIFF -u file target | + grep -v '^+++ target' | + sed -ne "/^+/s/+//p" >fixed + fi # the changed lines are all expected to change fixed_cnt=$(wc -l