git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 6/6] t4124: fix test for non-compliance diff

From
Đoàn Trần Công Danh <congdanhqx@gmail.com>
Date
Mar 22, 2020, 00:55 UTC
Message-ID
<cd86febed9b2791436d5e61da58cd318dcf4a7f9.1584838133.git.congdanhqx@gmail.com>
In-Reply-To
<cover.1584838133.git.congdanhqx@gmail.com>

POSIX's diff(1) requires output in normal diff format. However, busybox's diff's output is written in unified format.

POSIX requires no option for normal-diff format.

A hint in test-lib-functions::test_cmp said `diff -u` isn't available everywhere.

Workaround this problem by assuming `diff(1)` output is unified if we couldn't make anything from normal-diff format.

Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
---
 t/t4124-apply-ws-rule.sh | 6 ++++++
 1 file changed, 6 insertions(+)
diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh
index 971a5a7512..2a54ce96b5 100755
--- a/t/t4124-apply-ws-rule.sh
+++ b/t/t4124-apply-ws-rule.sh
@@ -52,6 +52,12 @@ test_fix () {
 
 	# find touched lines
 	$DIFF file target | sed -n -e "s/^> //p" >fixed
+	if ! test -s fixed; then
+		$DIFF file target |
+		grep '^+' |
+		grep -v '^+++' |
+		sed -e "s/+//" >fixed
+	fi
 
 	# the changed lines are all expected to change
 	fixed_cnt=$(wc -l <fixed)
-- 
2.26.0.rc2.310.g2932bb562d
Previous: Đoàn Trần Công DanhNext: Đoàn Trần Công Danh
Message 5 of 6 in “t4061: use POSIX compliance regex(7)”
  1. 1/6 t4061: use POSIX compliance regex(7)Đoàn Trần Công Danh, Mar 22, 2020
  2. Danh DoanMar 22, 2020
  3. 3/6 t5003: skip conversion test if unzip -a is unavailableĐoàn Trần Công Danh, Mar 22, 2020
  4. 4/6 t5616: use rev-parse instead to get HEAD's object_idĐoàn Trần Công Danh, Mar 22, 2020
  5. 6/6 t4124: fix test for non-compliance diffĐoàn Trần Công Danh, Mar 22, 2020
  6. 5/6 t7063: use POSIX find(1) syntaxĐoàn Trần Công Danh, Mar 22, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.