All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thell Fowler <git@tbfowler.name>
To: git@vger.kernel.org
Cc: Johannes.Schindelin@gmx.de, Thell Fowler <git@tbfowler.name>
Subject: [PATCH-v2/RFC 1/6] Add supplemental test for trailing-whitespace on incomplete lines
Date: Sat, 22 Aug 2009 22:49:12 -0500	[thread overview]
Message-ID: <1250999357-10827-1-git-send-email-git@tbfowler.name> (raw)
In-Reply-To: <1250999285-10683-1-git-send-email-git@tbfowler.name>

*** For illustrative purposes only and not meant for upstream ***

  - Adds a stand-alone test that loops through A-side B-side with
    and without new-lines from 0 to 3 spaces per side.
    This is a draft test meant to expose the issue with xutils.c
    handling of incomplete lines and trailing-spaces.

Signed-off-by: Thell Fowler <git@tbfowler.name>
---
 t/t4015-diff-trailing-whitespace.sh |   95 +++++++++++++++++++++++++++++++++++
 1 files changed, 95 insertions(+), 0 deletions(-)
 create mode 100755 t/t4015-diff-trailing-whitespace.sh

diff --git a/t/t4015-diff-trailing-whitespace.sh b/t/t4015-diff-trailing-whitespace.sh
new file mode 100755
index 0000000..079fba5
--- /dev/null
+++ b/t/t4015-diff-trailing-whitespace.sh
@@ -0,0 +1,95 @@
+#!/bin/sh
+
+test_description='Test trailing whitespace in diff engine.
+
+'
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/diff-lib.sh
+
+# Trailing-space testing with and without newlines.
+prepare_diff_file () {
+	printf "%s%$2s" foo "" >"$1"
+	if [ $3 = "+nl" ]
+	then
+		printf "\n" >>"$1"
+	fi
+}
+
+diff_trailing () {
+	foo="foo___"
+	prepare_diff_file "left" "$2" "$3"
+	lfoo=$( expr substr $foo 1 $((3+$2)) )
+	lfoo=${lfoo}"$3"
+
+	prepare_diff_file "right" "$4" "$5"
+	rfoo=$( expr substr $foo 1 $((3+$4)) )
+	rfoo=${rfoo}"$5"
+
+	label="-$1 $lfoo $rfoo ($6)"
+
+	if [ "$6" != "should_diff" ]
+	then
+		negate='!'
+	else
+		negate=''
+	fi
+
+	if [ -z "$7" ]
+	then
+		test_expect_success "$label" \
+		"$negate git diff --no-index -$1 -- left right | grep -q foo"
+	else
+		test_expect_failure "$label" \
+		"$negate git diff --no-index -$1 -- left right | grep -q foo"
+	fi
+
+	test_debug "git diff --no-index -$1 -- left right | grep foo"
+}
+
+touch diffout
+for arg in -ignore-all-space -ignore-space-at-eol -ignore-space-change
+do
+	for i1 in 0 1 2 3
+	do
+		for i2 in 0 1 2 3
+		do
+			diff_trailing $arg $i1 +nl $i2 -nl should_not_diff >> diffout
+			diff_trailing $arg $i1 -nl $i2 +nl should_not_diff >> diffout
+
+			if [ $i1 -ne $i2 ]
+			then
+				diff_trailing $arg $i1 +nl $i2 +nl should_not_diff >> diffout
+				diff_trailing $arg $i1 -nl $i2 -nl should_not_diff >> diffout
+			fi
+		done
+	done
+done
+
+test_debug 'grep "FAIL" diffout'
+
+for arg in all eol change
+do
+	grep "FAIL" diffout | \
+	grep "$arg" | \
+	cut -d " " -f 4- | \
+
+	##  Playing with filtering to isolate core issue.
+	#sort -k 2,2 -k 3,3 | \
+	#awk '{ forward = $2 " " $3; reverse = $3 " " $2}
+	#	!seen[forward]++ && !seen[reverse]++' | \
+	#sort -k 2,2 | \
+
+	##  Playing with filtering to isolate core issue.
+	##  This seems like the most illustrative output...
+	awk '{ key=$3 ; gsub(/-/, "+", key) ; key=$2 ":" key ; if ( hash[key]++ == 0 ) print ; }'
+
+	##  Playing with filtering to isolate core issue.
+	#awk '{ if ( $3 ~ /.*\-/ )
+	#		print $0
+	#	else
+	#		print $1 " " $3 " " $2 " " $4
+	#	; }' | \
+	#sort -k 2,2 -k 3,3
+done
+
+test_done
-- 
1.6.4.176.g556a4

  reply	other threads:[~2009-08-23  3:50 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-04 23:33 Help/Advice needed on diff bug in xutils.c Thell Fowler
2009-08-05 20:45 ` Johannes Schindelin
2009-08-10 18:54   ` Thell Fowler
2009-08-12  0:47   ` [PATCH/RFC] Add diff tests for trailing-space and now newline Thell Fowler
2009-08-19 23:05 ` [PATCH 0/6 RFC] Series to correct xutils incomplete line handling Thell Fowler
2009-08-21 17:39   ` Thell Fowler
2009-08-21 22:16     ` Alex Riesen
2009-08-22  4:23       ` Thell Fowler
     [not found] ` <cover.1250719760.git.git@tbfowler.name>
2009-08-19 23:06   ` [PATCH 1/6] Add supplemental test for trailing-whitespace on incomplete lines Thell Fowler
2009-08-19 23:06   ` [PATCH 2/6] Make xdl_hash_record_with_whitespace ignore eof Thell Fowler
2009-08-19 23:07   ` [PATCH 3/6] Make diff -w handle trailing-spaces on incomplete lines Thell Fowler
2009-08-20 23:09     ` Thell Fowler
2009-08-19 23:07   ` [PATCH 4/6] Make diff -b " Thell Fowler
2009-08-19 23:08   ` [PATCH 5/6] Make diff --ignore-space-at-eol handle " Thell Fowler
2009-08-19 23:09   ` [PATCH 6/6] Add diff tests for trailing-space on " Thell Fowler
2009-08-23  3:47 ` [PATCH-v2/RFC 0/6] improvements for trailing-space processing " Thell Fowler
2009-08-23  3:49   ` Thell Fowler [this message]
2009-08-23  3:49   ` [PATCH-v2/RFC 2/6] xutils: fix hash with whitespace on incomplete line Thell Fowler
2009-08-23  7:51     ` Junio C Hamano
2009-08-23 17:02       ` Thell Fowler
2009-08-23  3:49   ` [PATCH-v2/RFC 3/6] xutils: fix ignore-all-space " Thell Fowler
2009-08-23  7:57     ` Junio C Hamano
2009-08-23  8:18       ` Nanako Shiraishi
2009-08-23  8:56         ` Junio C Hamano
2009-08-23 21:07           ` Nanako Shiraishi
2009-08-23 21:14             ` Junio C Hamano
2009-08-23 22:13             ` Thell Fowler
2009-08-23 22:30               ` Junio C Hamano
2009-08-24  4:16                 ` [PATCH] Teach mailinfo to ignore everything before -- >8 -- mark Nicolas Sebrecht
2009-08-24  4:51                   ` Junio C Hamano
2009-08-24  5:36                     ` Junio C Hamano
2009-08-24  6:21                       ` [PATCH] " Nicolas Sebrecht
2009-08-24  6:58                         ` Junio C Hamano
2009-08-24  7:31                           ` Nicolas Sebrecht
2009-08-24 14:02                             ` Don Zickus
2009-08-24 21:48                               ` Junio C Hamano
2009-08-24  5:16                   ` [PATCH] " Nanako Shiraishi
2009-08-24  7:17                     ` [PATCH] " Nicolas Sebrecht
2009-08-24  7:24                       ` Nicolas Sebrecht
2009-08-24 22:17                       ` Junio C Hamano
2009-08-25 16:18                         ` Nicolas Sebrecht
2009-08-26  1:51                           ` Junio C Hamano
     [not found]                             ` <20090826110332.6117@nanako3.lavabit.com>
2009-08-26  2:20                               ` Junio C Hamano
2009-08-26  3:03                             ` Junio C Hamano
2009-08-26  5:02                               ` Nicolas Sebrecht
2009-08-26  8:57                                 ` Jakub Narebski
2009-08-26  9:00                                   ` Johannes Schindelin
2009-08-27  5:46                                     ` Junio C Hamano
2009-08-27 10:49                                       ` Johannes Schindelin
2009-08-26  9:03                                   ` Junio C Hamano
2009-08-26  3:54                             ` Nicolas Sebrecht
2009-08-24  8:09                     ` [PATCH] " Nanako Shiraishi
2009-08-23 17:01       ` [PATCH-v2/RFC 3/6] xutils: fix ignore-all-space on incomplete line Thell Fowler
2009-08-23 19:40         ` Junio C Hamano
2009-08-23 20:33           ` Thell Fowler
2009-08-23 21:11             ` Junio C Hamano
2009-08-24  3:26               ` Thell Fowler
2009-08-24  6:02                 ` Junio C Hamano
2009-08-24 14:13                   ` Thell Fowler
2009-08-25  5:58                     ` Thell Fowler
2009-08-23  3:49   ` [PATCH-v2/RFC 4/6] xutils: fix ignore-space-change " Thell Fowler
2009-08-23  3:49   ` [PATCH-v2/RFC 5/6] xutils: fix ignore-space-at-eol " Thell Fowler
2009-08-23  3:49   ` [PATCH-v2/RFC 6/6] t4015: add tests for trailing-space " Thell Fowler

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1250999357-10827-1-git-send-email-git@tbfowler.name \
    --to=git@tbfowler.name \
    --cc=Johannes.Schindelin@gmx.de \
    --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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.