From: Johannes Schindelin <Johannes.Schindelin@gmx.de> To: "Đoàn Trần Công Danh" <congdanhqx@gmail.com> Cc: git@vger.kernel.org Subject: Re: [PATCH v2 7/8] t4124: fix test for non-compliant diff(1) Date: Mon, 23 Mar 2020 14:58:13 +0100 (CET) Message-ID: <nycvar.QRO.7.76.6.2003231456200.46@tvgsbejvaqbjf.bet> (raw) In-Reply-To: <10f39c3d30d13e9141f081f985a0620954cc7493.1584838148.git.congdanhqx@gmail.com> [-- Attachment #1: Type: text/plain, Size: 2717 bytes --] Hi, On Sun, 22 Mar 2020, Đoàn Trần Công Danh wrote: > 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..075b1912be 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 > + # busybox's diff(1) output unified format > + if ! test -s fixed; then > + $DIFF file target | > + grep -v '^+++ target' | > + sed -e "/^+/s/+//" >fixed > + fi In my patches (which are too unpolished to contribute, I have not found time to clean them up in several years), I do this differently: -- snip -- commit cb2f3a28dbf40b92d3d9ca0f3177cd5afb7c4196 Author: Johannes Schindelin <Johannes.Schindelin@gmx.de> Date: Wed Jul 5 22:21:57 2017 +0200 t4124: avoid using "normal" diff mode Everybody and their dogs, cats and other pets settled on using unified diffs. It is a really quaint holdover from a long-gone era that GNU diff outputs "normal" diff by default. Yet, t4124 relied on that mode. This mode is so out of fashion in the meantime, though, that e.g. BusyBox' diff decided not even to bother to support it. It only supports unified diffs. So let's just switch away from "normal" diffs and use unified diffs, as we really are only interested in the `+` lines. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh index 971a5a7512ac..133557b99333 100755 --- a/t/t4124-apply-ws-rule.sh +++ b/t/t4124-apply-ws-rule.sh @@ -51,7 +51,7 @@ test_fix () { apply_patch --whitespace=fix || return 1 # find touched lines - $DIFF file target | sed -n -e "s/^> //p" >fixed + $DIFF -u file target | sed -n -e "3,\$s/^+//p" >fixed # the changed lines are all expected to change fixed_cnt=$(wc -l <fixed) -- snap -- Food for thought? Ciao, Dscho > > # the changed lines are all expected to change > fixed_cnt=$(wc -l <fixed) > -- > 2.26.0.rc2.310.g2932bb562d > > >
next prev parent reply other threads:[~2020-03-23 13:58 UTC|newest] Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-22 0:55 [PATCH v2 0/8] fix test failure with busybox Đoàn Trần Công Danh 2020-03-22 0:55 ` [PATCH v2 1/8] t4061: use POSIX compliant regex(7) Đoàn Trần Công Danh 2020-03-22 0:55 ` [PATCH v2 2/8] test-lib-functions: test_cmp: eval $GIT_TEST_CMP Đoàn Trần Công Danh 2020-03-22 0:55 ` [PATCH v2 3/8] t5003: drop the subshell in test_lazy_prereq Đoàn Trần Công Danh 2020-03-22 0:55 ` [PATCH v2 4/8] t5003: skip conversion test if unzip -a is unavailable Đoàn Trần Công Danh 2020-03-22 0:55 ` [PATCH v2 5/8] t5616: use rev-parse instead to get HEAD's object_id Đoàn Trần Công Danh 2020-03-22 0:55 ` [PATCH v2 6/8] t7063: drop non-POSIX argument "-ls" from find(1) Đoàn Trần Công Danh 2020-03-23 14:11 ` Johannes Schindelin 2020-03-23 14:37 ` Torsten Bögershausen 2020-03-23 15:11 ` Danh Doan 2020-03-23 20:30 ` Junio C Hamano 2020-03-23 15:55 ` Junio C Hamano 2020-03-24 22:31 ` Johannes Schindelin 2020-03-24 23:46 ` Junio C Hamano 2020-03-22 0:55 ` [PATCH v2 7/8] t4124: fix test for non-compliant diff(1) Đoàn Trần Công Danh 2020-03-23 13:58 ` Johannes Schindelin [this message] 2020-03-23 15:04 ` Danh Doan 2020-03-23 20:50 ` Junio C Hamano 2020-03-24 3:40 ` Danh Doan 2020-03-24 18:47 ` Junio C Hamano 2020-03-25 14:24 ` Danh Doan 2020-03-24 22:29 ` Johannes Schindelin 2020-03-24 23:37 ` Junio C Hamano 2020-03-25 18:23 ` Johannes Schindelin 2020-03-22 0:55 ` [PATCH v2 8/8] t5703: feed raw data into test-tool unpack-sideband Đoàn Trần Công Danh 2020-03-22 6:08 ` [PATCH v2 0/8] fix test failure with busybox Jeff King 2020-03-26 4:37 ` [PATCH v4 " Đoàn Trần Công Danh 2020-03-26 4:37 ` [PATCH v4 1/8] t4061: use POSIX compliant regex(7) Đoàn Trần Công Danh 2020-03-26 4:37 ` [PATCH v4 2/8] test-lib-functions: test_cmp: eval $GIT_TEST_CMP Đoàn Trần Công Danh 2020-03-26 4:37 ` [PATCH v4 3/8] t5003: drop the subshell in test_lazy_prereq Đoàn Trần Công Danh 2020-03-26 4:37 ` [PATCH v4 4/8] t5003: skip conversion test if unzip -a is unavailable Đoàn Trần Công Danh 2020-03-26 4:37 ` [PATCH v4 5/8] t5616: use rev-parse instead to get HEAD's object_id Đoàn Trần Công Danh 2020-03-26 4:37 ` [PATCH v4 6/8] t7063: drop non-POSIX argument "-ls" from find(1) Đoàn Trần Công Danh 2020-03-26 4:37 ` [PATCH v4 7/8] t4124: fix test for non-compliant diff(1) Đoàn Trần Công Danh 2020-03-27 1:18 ` Junio C Hamano 2020-03-26 4:37 ` [PATCH v4 8/8] t5703: feed raw data into test-tool unpack-sideband Đoàn Trần Công Danh
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: http://vger.kernel.org/majordomo-info.html * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=nycvar.QRO.7.76.6.2003231456200.46@tvgsbejvaqbjf.bet \ --to=johannes.schindelin@gmx.de \ --cc=congdanhqx@gmail.com \ --cc=git@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
git@vger.kernel.org list mirror (unofficial, one of many) This inbox may be cloned and mirrored by anyone: git clone --mirror https://public-inbox.org/git git clone --mirror http://ou63pmih66umazou.onion/git git clone --mirror http://czquwvybam4bgbro.onion/git git clone --mirror http://hjrcffqmbrq6wope.onion/git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V1 git git/ https://public-inbox.org/git \ git@vger.kernel.org public-inbox-index git Example config snippet for mirrors. Newsgroups are available over NNTP: nntp://news.public-inbox.org/inbox.comp.version-control.git nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git nntp://news.gmane.io/gmane.comp.version-control.git note: .onion URLs require Tor: https://www.torproject.org/ code repositories for the project(s) associated with this inbox: https://80x24.org/mirrors/git.git AGPL code for this site: git clone https://public-inbox.org/public-inbox.git