summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1d9e6f9)
raw | patch | inline | side by side (parent: 1d9e6f9)
author | Junio C Hamano <junkio@cox.net> | |
Tue, 31 May 2005 21:47:25 +0000 (14:47 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Tue, 31 May 2005 23:17:27 +0000 (16:17 -0700) |
There were duplicate script pieces to help comparing diff
output, which this patch consolidates into the t/diff-lib.sh
library.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
output, which this patch consolidates into the t/diff-lib.sh
library.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
t/diff-lib.sh | [new file with mode: 0644] | patch | blob |
t/t4003-diff-rename-1.sh | patch | blob | history | |
t/t4005-diff-rename-2.sh | patch | blob | history | |
t/t4007-rename-3.sh | patch | blob | history | |
t/t4008-diff-break-rewrite.sh | patch | blob | history | |
t/t4009-diff-rename-4.sh | patch | blob | history |
diff --git a/t/diff-lib.sh b/t/diff-lib.sh
--- /dev/null
+++ b/t/diff-lib.sh
@@ -0,0 +1,35 @@
+:
+
+_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
+_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
+sanitize_diff_raw='/^:/s/ '"$_x40"' '"$_x40"' \([A-Z]\)[0-9]* / X X \1# /'
+compare_diff_raw () {
+ # When heuristics are improved, the score numbers would change.
+ # Ignore them while comparing.
+ # Also we do not check SHA1 hash generation in this test, which
+ # is a job for t0000-basic.sh
+
+ sed -e "$sanitize_diff_raw" <"$1" >.tmp-1
+ sed -e "$sanitize_diff_raw" <"$2" >.tmp-2
+ diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
+}
+
+sanitize_diff_raw_z='/^:/s/ '"$_x40"' '"$_x40"' \([A-Z]\)[0-9]*$/ X X \1#/'
+compare_diff_raw_z () {
+ # When heuristics are improved, the score numbers would change.
+ # Ignore them while comparing.
+ # Also we do not check SHA1 hash generation in this test, which
+ # is a job for t0000-basic.sh
+
+ tr '\0' '\012' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1
+ tr '\0' '\012' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2
+ diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
+}
+
+compare_diff_patch () {
+ # When heuristics are improved, the score numbers would change.
+ # Ignore them while comparing.
+ sed -e '/^[dis]*imilarity index [0-9]*%$/d' <"$1" >.tmp-1
+ sed -e '/^[dis]*imilarity index [0-9]*%$/d' <"$2" >.tmp-2
+ diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
+}
index c5f325577ddb2486de8e01bde350f9903f3bde04..7a5f73a3101cb7a5bb63dff6c2f00bcebcf12c2f 100644 (file)
--- a/t/t4003-diff-rename-1.sh
+++ b/t/t4003-diff-rename-1.sh
'
. ./test-lib.sh
-
-compare_diff_patch () {
- # When heuristics are improved, the score numbers would change.
- # Ignore them while comparing.
- sed -e '/^similarity index [0-9]*%$/d' <"$1" >.tmp-1
- sed -e '/^similarity index [0-9]*%$/d' <"$2" >.tmp-2
- diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
-}
+. ../diff-lib.sh ;# test-lib chdir's into trash
test_expect_success \
'prepare reference tree' \
index 5ac29d1f98438d3530bbc8b0bdaced58200aca37..fa2b1556b2ae2faa52a54db7b180aaa90baabe96 100644 (file)
--- a/t/t4005-diff-rename-2.sh
+++ b/t/t4005-diff-rename-2.sh
'
. ./test-lib.sh
-
-_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
-_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
-sanitize_diff_raw='s/ '"$_x40"' '"$_x40"' \([A-Z]\)[0-9]* / X X \1# /'
-compare_diff_raw () {
- # When heuristics are improved, the score numbers would change.
- # Ignore them while comparing.
- # Also we do not check SHA1 hash generation in this test, which
- # is a job for t0000-basic.sh
-
- sed -e "$sanitize_diff_raw" <"$1" >.tmp-1
- sed -e "$sanitize_diff_raw" <"$2" >.tmp-2
- diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
-}
-
-compare_diff_patch () {
- # When heuristics are improved, the score numbers would change.
- # Ignore them while comparing.
- sed -e '/^similarity index [0-9]*%$/d' <"$1" >.tmp-1
- sed -e '/^similarity index [0-9]*%$/d' <"$2" >.tmp-2
- diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
-}
+. ../diff-lib.sh ;# test-lib chdir's into trash
test_expect_success \
'prepare reference tree' \
diff --git a/t/t4007-rename-3.sh b/t/t4007-rename-3.sh
index 76ae7201f0d19b7933ca44958b7c468193ec9778..a55d6b65d191b338194e945408c4f8b807cfba52 100644 (file)
--- a/t/t4007-rename-3.sh
+++ b/t/t4007-rename-3.sh
'
. ./test-lib.sh
-
-_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
-_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
-sanitize_diff_raw='s/ '"$_x40"' '"$_x40"' \([A-Z]\)[0-9]* / X X \1# /'
-compare_diff_raw () {
- # When heuristics are improved, the score numbers would change.
- # Ignore them while comparing.
- # Also we do not check SHA1 hash generation in this test, which
- # is a job for t0000-basic.sh
-
- sed -e "$sanitize_diff_raw" <"$1" >.tmp-1
- sed -e "$sanitize_diff_raw" <"$2" >.tmp-2
- diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
-}
+. ../diff-lib.sh ;# test-lib chdir's into trash
test_expect_success \
'prepare reference tree' \
index 7189462a9ef23aed6a701526faf73c765f9c2639..94205b94aeb8c685206563fb4cbcab26a138ec50 100644 (file)
Further, with -B and -M together, these should turn into two renames.
'
. ./test-lib.sh
-
-_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
-_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
-sanitize_diff_raw='s/ '"$_x40"' '"$_x40"' \([CDNR]\)[0-9]* / X X \1# /'
-compare_diff_raw () {
- # When heuristics are improved, the score numbers would change.
- # Ignore them while comparing.
- # Also we do not check SHA1 hash generation in this test, which
- # is a job for t0000-basic.sh
-
- sed -e "$sanitize_diff_raw" <"$1" >.tmp-1
- sed -e "$sanitize_diff_raw" <"$2" >.tmp-2
- diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
-}
+. ../diff-lib.sh ;# test-lib chdir's into trash
test_expect_success \
setup \
index 01d276692669f2241471b8ad611b17d51e2a98ab..7d8ca6dc3580b6e72adb52232d208a86abe5332f 100644 (file)
--- a/t/t4009-diff-rename-4.sh
+++ b/t/t4009-diff-rename-4.sh
'
. ./test-lib.sh
-
-_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
-_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
-sanitize_diff_raw='/^:/s/ '"$_x40"' '"$_x40"' \([A-Z]\)[0-9]*$/ X X \1#/'
-compare_diff_raw () {
- # When heuristics are improved, the score numbers would change.
- # Ignore them while comparing.
- # Also we do not check SHA1 hash generation in this test, which
- # is a job for t0000-basic.sh
-
- tr '\0' '\012' <"$1" | sed -e "$sanitize_diff_raw" >.tmp-1
- tr '\0' '\012' <"$2" | sed -e "$sanitize_diff_raw" >.tmp-2
- diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
-}
-
-compare_diff_patch () {
- # When heuristics are improved, the score numbers would change.
- # Ignore them while comparing.
- sed -e '/^similarity index [0-9]*%$/d' <"$1" >.tmp-1
- sed -e '/^similarity index [0-9]*%$/d' <"$2" >.tmp-2
- diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
-}
+. ../diff-lib.sh ;# test-lib chdir's into trash
test_expect_success \
'prepare reference tree' \
test_expect_success \
'validate output from rename/copy detection (#1)' \
- 'compare_diff_raw current expected'
+ 'compare_diff_raw_z current expected'
# make sure diff-helper can grok it.
mv current diff-raw
test_expect_success \
'validate output from rename/copy detection (#2)' \
- 'compare_diff_raw current expected'
+ 'compare_diff_raw_z current expected'
# make sure diff-helper can grok it.
mv current diff-raw
test_expect_success \
'validate output from rename/copy detection (#3)' \
- 'compare_diff_raw current expected'
+ 'compare_diff_raw_z current expected'
# make sure diff-helper can grok it.
mv current diff-raw