[PATCH v3 6/6] --color-words: Add test t4030

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Also add a script gen-expect.sh to generate the expected
diff output.

Signed-off-by: Ping Yin <pkufranky@xxxxxxxxx>
---
 t/t4030-diff-color-words.sh |   42 ++++++++++++++++++++++++++++++++++++++++++
 t/t4030/expect1             |    1 +
 t/t4030/expect10            |    1 +
 t/t4030/expect2             |    1 +
 t/t4030/expect3             |    1 +
 t/t4030/expect4             |    1 +
 t/t4030/expect5             |    1 +
 t/t4030/expect6             |    1 +
 t/t4030/expect7             |    1 +
 t/t4030/expect8             |    1 +
 t/t4030/expect9             |    1 +
 t/t4030/gen-expect.sh       |   35 +++++++++++++++++++++++++++++++++++
 12 files changed, 87 insertions(+), 0 deletions(-)
 create mode 100755 t/t4030-diff-color-words.sh
 create mode 100644 t/t4030/expect1
 create mode 100644 t/t4030/expect10
 create mode 100644 t/t4030/expect2
 create mode 100644 t/t4030/expect3
 create mode 100644 t/t4030/expect4
 create mode 100644 t/t4030/expect5
 create mode 100644 t/t4030/expect6
 create mode 100644 t/t4030/expect7
 create mode 100644 t/t4030/expect8
 create mode 100644 t/t4030/expect9
 create mode 100644 t/t4030/gen-expect.sh

diff --git a/t/t4030-diff-color-words.sh b/t/t4030-diff-color-words.sh
new file mode 100755
index 0000000..e1c8e8e
--- /dev/null
+++ b/t/t4030-diff-color-words.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+test_description='diff --color-words'
+
+. ./test-lib.sh
+. ../diff-lib.sh
+
+dotest() {
+	test_expect_success "$1" "
+	echo '$1' >t &&
+	git diff --color-words | tail -1 >actual &&
+	cat actual &&
+	test_cmp ../t4030/$2 actual
+"	
+}
+
+test_expect_success 'setup for foo bar(_baz' '
+	git config diff.nonwordchars "_()" &&
+	echo "foo bar(_baz" > t &&
+	git add t  &&
+	git commit -m "add t"
+'
+
+dotest "foo bar(_" expect1
+dotest "foo bar(" expect2
+dotest "foo bar" expect3
+dotest "foo (_baz" expect4
+dotest "foo _baz" expect5
+dotest "foo baz" expect6
+dotest "bar(_baz" expect7
+
+test_expect_success 'setup for foo bar(_' '
+	echo "foo bar(_" > t &&
+	git add t  &&
+	git commit -m "add t"
+'
+
+dotest "foo bar(" expect8
+dotest "foo bar" expect9
+dotest "foo bar_baz" expect10
+
+test_done
diff --git a/t/t4030/expect1 b/t/t4030/expect1
new file mode 100644
index 0000000..fb75467
--- /dev/null
+++ b/t/t4030/expect1
@@ -0,0 +1 @@
+foo bar(_baz
diff --git a/t/t4030/expect10 b/t/t4030/expect10
new file mode 100644
index 0000000..b36e5db
--- /dev/null
+++ b/t/t4030/expect10
@@ -0,0 +1 @@
+foo bar(__baz
diff --git a/t/t4030/expect2 b/t/t4030/expect2
new file mode 100644
index 0000000..6a9ca69
--- /dev/null
+++ b/t/t4030/expect2
@@ -0,0 +1 @@
+foo bar(_baz
diff --git a/t/t4030/expect3 b/t/t4030/expect3
new file mode 100644
index 0000000..d7d9885
--- /dev/null
+++ b/t/t4030/expect3
@@ -0,0 +1 @@
+foo bar(_baz
diff --git a/t/t4030/expect4 b/t/t4030/expect4
new file mode 100644
index 0000000..449fd6d
--- /dev/null
+++ b/t/t4030/expect4
@@ -0,0 +1 @@
+foo bar((_baz
diff --git a/t/t4030/expect5 b/t/t4030/expect5
new file mode 100644
index 0000000..eb184f7
--- /dev/null
+++ b/t/t4030/expect5
@@ -0,0 +1 @@
+foo bar(_baz
diff --git a/t/t4030/expect6 b/t/t4030/expect6
new file mode 100644
index 0000000..58591ad
--- /dev/null
+++ b/t/t4030/expect6
@@ -0,0 +1 @@
+foo bar(_baz
diff --git a/t/t4030/expect7 b/t/t4030/expect7
new file mode 100644
index 0000000..c68a1f1
--- /dev/null
+++ b/t/t4030/expect7
@@ -0,0 +1 @@
+foo bar(_baz
diff --git a/t/t4030/expect8 b/t/t4030/expect8
new file mode 100644
index 0000000..f48152f
--- /dev/null
+++ b/t/t4030/expect8
@@ -0,0 +1 @@
+foo bar(_
diff --git a/t/t4030/expect9 b/t/t4030/expect9
new file mode 100644
index 0000000..4f42b6c
--- /dev/null
+++ b/t/t4030/expect9
@@ -0,0 +1 @@
+foo bar(_
diff --git a/t/t4030/gen-expect.sh b/t/t4030/gen-expect.sh
new file mode 100644
index 0000000..da07535
--- /dev/null
+++ b/t/t4030/gen-expect.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+git config diff.nonwordchars "_()"
+
+echo "foo bar(_baz" >&2 &&
+echo "foo bar(_baz" > t
+
+git add t  &&
+git commit -m "add t"
+
+dotest() {
+	echo "$1" >&2 &&
+	echo "$1" >t  &&
+	git diff --color-words |
+	tail -1 > $2
+}
+
+dotest "foo bar(_" expect1
+dotest "foo bar(" expect2
+dotest "foo bar" expect3
+dotest "foo (_baz" expect4
+dotest "foo _baz" expect5
+dotest "foo baz" expect6
+dotest "bar(_baz" expect7
+
+
+echo "foo bar(_" >&2 &&
+echo "foo bar(_" >t
+
+git add t  &&
+git commit -m "add t"
+
+dotest "foo bar(" expect8
+dotest "foo bar" expect9
+dotest "foo bar_baz" expect10
-- 
1.5.5.1.121.g26b3

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux