Re: [PATCH] t9814: Guarantee only one source exists in git-p4 copy tests

4 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] t9814: Guarantee only one source exists in git-p4 copy tests

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:04:18

Vitor Antunes [off-list ref] writes:
* Modify source file (file2) before copying the file.
* Check that only file2 is the source in the output of "p4 filelog".
* Remove all "case" statements and replace them simple tests to check that
  source is "file2".

Signed-off-by: Vitor Antunes <redacted>
---
I am not a Perfoce user, so I'd like to ask Pete's and Luke's
comments on these changes.
quoted hunk
 t/t9814-git-p4-rename.sh |   46 +++++++++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 15 deletions(-)
diff --git a/t/t9814-git-p4-rename.sh b/t/t9814-git-p4-rename.sh
index 8b9c295..d8fb22d 100755
--- a/t/t9814-git-p4-rename.sh
+++ b/t/t9814-git-p4-rename.sh
@@ -132,6 +132,9 @@ test_expect_success 'detect copies' '
 		cd "$git" &&
 		git config git-p4.skipSubmitEdit true &&
 
+		echo "file8" >> file2 &&
Style: please lose SP between redirection and its target, i.e.

	echo file8 >>file2 &&

The same comment applies to everywhere else.
quoted hunk
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&
 		cp file2 file8 &&
 		git add file8 &&
 		git commit -a -m "Copy file2 to file8" &&
@@ -140,6 +143,10 @@ test_expect_success 'detect copies' '
 		p4 filelog //depot/file8 &&
 		p4 filelog //depot/file8 | test_must_fail grep -q "branch from" &&
 
+		echo "file9" >> file2 &&
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&
+
 		cp file2 file9 &&
 		git add file9 &&
 		git commit -a -m "Copy file2 to file9" &&
@@ -149,28 +156,39 @@ test_expect_success 'detect copies' '
 		p4 filelog //depot/file9 &&
 		p4 filelog //depot/file9 | test_must_fail grep -q "branch from" &&
 
+		echo "file10" >> file2 &&
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&
+
 		echo "file2" >>file2 &&
 		cp file2 file10 &&
 		git add file2 file10 &&
 		git commit -a -m "Modify and copy file2 to file10" &&
 		git diff-tree -r -C HEAD &&
+		src=$(git diff-tree -r -C HEAD | sed 1d | sed 2d | cut -f2) &&
+		test "$src" = file2 &&
 		git p4 submit &&
 		p4 filelog //depot/file10 &&
-		p4 filelog //depot/file10 | grep -q "branch from //depot/file" &&
+		p4 filelog //depot/file10 | grep -q "branch from //depot/file2" &&
+
+		echo "file11" >> file2 &&
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&
 
 		cp file2 file11 &&
 		git add file11 &&
 		git commit -a -m "Copy file2 to file11" &&
 		git diff-tree -r -C --find-copies-harder HEAD &&
 		src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
-		case "$src" in
-		file2 | file10) : ;; # happy
-		*) false ;; # not
-		esac &&
+		test "$src" = file2 &&
 		git config git-p4.detectCopiesHarder true &&
 		git p4 submit &&
 		p4 filelog //depot/file11 &&
-		p4 filelog //depot/file11 | grep -q "branch from //depot/file" &&
+		p4 filelog //depot/file11 | grep -q "branch from //depot/file2" &&
+
+		echo "file12" >> file2 &&
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&
 
 		cp file2 file12 &&
 		echo "some text" >>file12 &&
@@ -180,15 +198,16 @@ test_expect_success 'detect copies' '
 		level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&
 		test -n "$level" && test "$level" -gt 0 && test "$level" -lt 98 &&
 		src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
-		case "$src" in
-		file10 | file11) : ;; # happy
-		*) false ;; # not
-		esac &&
+		test "$src" = file2 &&
 		git config git-p4.detectCopies $(($level + 2)) &&
 		git p4 submit &&
 		p4 filelog //depot/file12 &&
 		p4 filelog //depot/file12 | test_must_fail grep -q "branch from" &&
 
+		echo "file13" >> file2 &&
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&
+
 		cp file2 file13 &&
 		echo "different text" >>file13 &&
 		git add file13 &&
@@ -197,14 +216,11 @@ test_expect_success 'detect copies' '
 		level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&
 		test -n "$level" && test "$level" -gt 2 && test "$level" -lt 100 &&
 		src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
-		case "$src" in
-		file10 | file11 | file12) : ;; # happy
-		*) false ;; # not
-		esac &&
+		test "$src" = file2 &&
 		git config git-p4.detectCopies $(($level - 2)) &&
 		git p4 submit &&
 		p4 filelog //depot/file13 &&
-		p4 filelog //depot/file13 | grep -q "branch from //depot/file"
+		p4 filelog //depot/file13 | grep -q "branch from //depot/file2"
 	)
 '

Re: [PATCH] t9814: Guarantee only one source exists in git-p4 copy tests

From: Luke Diamand <hidden>
Date: 2016-06-15 23:04:19

I'm on holiday this week, so I'll not get a chance to look at these
properly until next week.

Luke


On 30 March 2015 at 04:03, Junio C Hamano [off-list ref] wrote:
Vitor Antunes [off-list ref] writes:
quoted
* Modify source file (file2) before copying the file.
* Check that only file2 is the source in the output of "p4 filelog".
* Remove all "case" statements and replace them simple tests to check that
  source is "file2".

Signed-off-by: Vitor Antunes <redacted>
---
I am not a Perfoce user, so I'd like to ask Pete's and Luke's
comments on these changes.
quoted
 t/t9814-git-p4-rename.sh |   46 +++++++++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 15 deletions(-)
diff --git a/t/t9814-git-p4-rename.sh b/t/t9814-git-p4-rename.sh
index 8b9c295..d8fb22d 100755
--- a/t/t9814-git-p4-rename.sh
+++ b/t/t9814-git-p4-rename.sh
@@ -132,6 +132,9 @@ test_expect_success 'detect copies' '
              cd "$git" &&
              git config git-p4.skipSubmitEdit true &&

+             echo "file8" >> file2 &&
Style: please lose SP between redirection and its target, i.e.

        echo file8 >>file2 &&

The same comment applies to everywhere else.
quoted
+             git commit -a -m "Differentiate file2" &&
+             git p4 submit &&
              cp file2 file8 &&
              git add file8 &&
              git commit -a -m "Copy file2 to file8" &&
@@ -140,6 +143,10 @@ test_expect_success 'detect copies' '
              p4 filelog //depot/file8 &&
              p4 filelog //depot/file8 | test_must_fail grep -q "branch from" &&

+             echo "file9" >> file2 &&
+             git commit -a -m "Differentiate file2" &&
+             git p4 submit &&
+
              cp file2 file9 &&
              git add file9 &&
              git commit -a -m "Copy file2 to file9" &&
@@ -149,28 +156,39 @@ test_expect_success 'detect copies' '
              p4 filelog //depot/file9 &&
              p4 filelog //depot/file9 | test_must_fail grep -q "branch from" &&

+             echo "file10" >> file2 &&
+             git commit -a -m "Differentiate file2" &&
+             git p4 submit &&
+
              echo "file2" >>file2 &&
              cp file2 file10 &&
              git add file2 file10 &&
              git commit -a -m "Modify and copy file2 to file10" &&
              git diff-tree -r -C HEAD &&
+             src=$(git diff-tree -r -C HEAD | sed 1d | sed 2d | cut -f2) &&
+             test "$src" = file2 &&
              git p4 submit &&
              p4 filelog //depot/file10 &&
-             p4 filelog //depot/file10 | grep -q "branch from //depot/file" &&
+             p4 filelog //depot/file10 | grep -q "branch from //depot/file2" &&
+
+             echo "file11" >> file2 &&
+             git commit -a -m "Differentiate file2" &&
+             git p4 submit &&

              cp file2 file11 &&
              git add file11 &&
              git commit -a -m "Copy file2 to file11" &&
              git diff-tree -r -C --find-copies-harder HEAD &&
              src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
-             case "$src" in
-             file2 | file10) : ;; # happy
-             *) false ;; # not
-             esac &&
+             test "$src" = file2 &&
              git config git-p4.detectCopiesHarder true &&
              git p4 submit &&
              p4 filelog //depot/file11 &&
-             p4 filelog //depot/file11 | grep -q "branch from //depot/file" &&
+             p4 filelog //depot/file11 | grep -q "branch from //depot/file2" &&
+
+             echo "file12" >> file2 &&
+             git commit -a -m "Differentiate file2" &&
+             git p4 submit &&

              cp file2 file12 &&
              echo "some text" >>file12 &&
@@ -180,15 +198,16 @@ test_expect_success 'detect copies' '
              level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&
              test -n "$level" && test "$level" -gt 0 && test "$level" -lt 98 &&
              src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
-             case "$src" in
-             file10 | file11) : ;; # happy
-             *) false ;; # not
-             esac &&
+             test "$src" = file2 &&
              git config git-p4.detectCopies $(($level + 2)) &&
              git p4 submit &&
              p4 filelog //depot/file12 &&
              p4 filelog //depot/file12 | test_must_fail grep -q "branch from" &&

+             echo "file13" >> file2 &&
+             git commit -a -m "Differentiate file2" &&
+             git p4 submit &&
+
              cp file2 file13 &&
              echo "different text" >>file13 &&
              git add file13 &&
@@ -197,14 +216,11 @@ test_expect_success 'detect copies' '
              level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&
              test -n "$level" && test "$level" -gt 2 && test "$level" -lt 100 &&
              src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
-             case "$src" in
-             file10 | file11 | file12) : ;; # happy
-             *) false ;; # not
-             esac &&
+             test "$src" = file2 &&
              git config git-p4.detectCopies $(($level - 2)) &&
              git p4 submit &&
              p4 filelog //depot/file13 &&
-             p4 filelog //depot/file13 | grep -q "branch from //depot/file"
+             p4 filelog //depot/file13 | grep -q "branch from //depot/file2"
      )
 '

[PATCH V2] t9814: Guarantee only one source exists in git-p4 copy tests

From: Vitor Antunes <hidden>
Date: 2016-06-15 23:04:20

* Modify source file (file2) before copying the file.
* Check that only file2 is the source in the output of "p4 filelog".
* Remove all "case" statements and replace them with simple tests to check
  that source is "file2".

Signed-off-by: Vitor Antunes <redacted>
---
 t/t9814-git-p4-rename.sh |   46 +++++++++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 15 deletions(-)
diff --git a/t/t9814-git-p4-rename.sh b/t/t9814-git-p4-rename.sh
index 8b9c295..99bb71b 100755
--- a/t/t9814-git-p4-rename.sh
+++ b/t/t9814-git-p4-rename.sh
@@ -132,6 +132,9 @@ test_expect_success 'detect copies' '
 		cd "$git" &&
 		git config git-p4.skipSubmitEdit true &&
 
+		echo "file8" >>file2 &&
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&
 		cp file2 file8 &&
 		git add file8 &&
 		git commit -a -m "Copy file2 to file8" &&
@@ -140,6 +143,10 @@ test_expect_success 'detect copies' '
 		p4 filelog //depot/file8 &&
 		p4 filelog //depot/file8 | test_must_fail grep -q "branch from" &&
 
+		echo "file9" >>file2 &&
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&
+
 		cp file2 file9 &&
 		git add file9 &&
 		git commit -a -m "Copy file2 to file9" &&
@@ -149,28 +156,39 @@ test_expect_success 'detect copies' '
 		p4 filelog //depot/file9 &&
 		p4 filelog //depot/file9 | test_must_fail grep -q "branch from" &&
 
+		echo "file10" >>file2 &&
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&
+
 		echo "file2" >>file2 &&
 		cp file2 file10 &&
 		git add file2 file10 &&
 		git commit -a -m "Modify and copy file2 to file10" &&
 		git diff-tree -r -C HEAD &&
+		src=$(git diff-tree -r -C HEAD | sed 1d | sed 2d | cut -f2) &&
+		test "$src" = file2 &&
 		git p4 submit &&
 		p4 filelog //depot/file10 &&
-		p4 filelog //depot/file10 | grep -q "branch from //depot/file" &&
+		p4 filelog //depot/file10 | grep -q "branch from //depot/file2" &&
+
+		echo "file11" >>file2 &&
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&
 
 		cp file2 file11 &&
 		git add file11 &&
 		git commit -a -m "Copy file2 to file11" &&
 		git diff-tree -r -C --find-copies-harder HEAD &&
 		src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
-		case "$src" in
-		file2 | file10) : ;; # happy
-		*) false ;; # not
-		esac &&
+		test "$src" = file2 &&
 		git config git-p4.detectCopiesHarder true &&
 		git p4 submit &&
 		p4 filelog //depot/file11 &&
-		p4 filelog //depot/file11 | grep -q "branch from //depot/file" &&
+		p4 filelog //depot/file11 | grep -q "branch from //depot/file2" &&
+
+		echo "file12" >>file2 &&
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&
 
 		cp file2 file12 &&
 		echo "some text" >>file12 &&
@@ -180,15 +198,16 @@ test_expect_success 'detect copies' '
 		level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&
 		test -n "$level" && test "$level" -gt 0 && test "$level" -lt 98 &&
 		src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
-		case "$src" in
-		file10 | file11) : ;; # happy
-		*) false ;; # not
-		esac &&
+		test "$src" = file2 &&
 		git config git-p4.detectCopies $(($level + 2)) &&
 		git p4 submit &&
 		p4 filelog //depot/file12 &&
 		p4 filelog //depot/file12 | test_must_fail grep -q "branch from" &&
 
+		echo "file13" >>file2 &&
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&
+
 		cp file2 file13 &&
 		echo "different text" >>file13 &&
 		git add file13 &&
@@ -197,14 +216,11 @@ test_expect_success 'detect copies' '
 		level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&
 		test -n "$level" && test "$level" -gt 2 && test "$level" -lt 100 &&
 		src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
-		case "$src" in
-		file10 | file11 | file12) : ;; # happy
-		*) false ;; # not
-		esac &&
+		test "$src" = file2 &&
 		git config git-p4.detectCopies $(($level - 2)) &&
 		git p4 submit &&
 		p4 filelog //depot/file13 &&
-		p4 filelog //depot/file13 | grep -q "branch from //depot/file"
+		p4 filelog //depot/file13 | grep -q "branch from //depot/file2"
 	)
 '
 
-- 
1.7.10.4

Re: [PATCH] t9814: Guarantee only one source exists in git-p4 copy tests

From: Luke Diamand <hidden>
Date: 2016-06-15 23:04:22

On 30/03/15 04:03, Junio C Hamano wrote:
Vitor Antunes [off-list ref] writes:
quoted
* Modify source file (file2) before copying the file.
* Check that only file2 is the source in the output of "p4 filelog".
* Remove all "case" statements and replace them simple tests to check that
   source is "file2".

Signed-off-by: Vitor Antunes <redacted>
---
I am not a Perfoce user, so I'd like to ask Pete's and Luke's
comments on these changes.
It's much clearer now that the guessing of file source has been cleaned 
up, thanks. Ack.

Luke


quoted
  t/t9814-git-p4-rename.sh |   46 +++++++++++++++++++++++++++++++---------------
  1 file changed, 31 insertions(+), 15 deletions(-)
diff --git a/t/t9814-git-p4-rename.sh b/t/t9814-git-p4-rename.sh
index 8b9c295..d8fb22d 100755
--- a/t/t9814-git-p4-rename.sh
+++ b/t/t9814-git-p4-rename.sh
@@ -132,6 +132,9 @@ test_expect_success 'detect copies' '
  		cd "$git" &&
  		git config git-p4.skipSubmitEdit true &&

+		echo "file8" >> file2 &&
Style: please lose SP between redirection and its target, i.e.

	echo file8 >>file2 &&

The same comment applies to everywhere else.
quoted
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&
  		cp file2 file8 &&
  		git add file8 &&
  		git commit -a -m "Copy file2 to file8" &&
@@ -140,6 +143,10 @@ test_expect_success 'detect copies' '
  		p4 filelog //depot/file8 &&
  		p4 filelog //depot/file8 | test_must_fail grep -q "branch from" &&

+		echo "file9" >> file2 &&
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&
+
  		cp file2 file9 &&
  		git add file9 &&
  		git commit -a -m "Copy file2 to file9" &&
@@ -149,28 +156,39 @@ test_expect_success 'detect copies' '
  		p4 filelog //depot/file9 &&
  		p4 filelog //depot/file9 | test_must_fail grep -q "branch from" &&

+		echo "file10" >> file2 &&
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&
+
  		echo "file2" >>file2 &&
  		cp file2 file10 &&
  		git add file2 file10 &&
  		git commit -a -m "Modify and copy file2 to file10" &&
  		git diff-tree -r -C HEAD &&
+		src=$(git diff-tree -r -C HEAD | sed 1d | sed 2d | cut -f2) &&
+		test "$src" = file2 &&
  		git p4 submit &&
  		p4 filelog //depot/file10 &&
-		p4 filelog //depot/file10 | grep -q "branch from //depot/file" &&
+		p4 filelog //depot/file10 | grep -q "branch from //depot/file2" &&
+
+		echo "file11" >> file2 &&
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&

  		cp file2 file11 &&
  		git add file11 &&
  		git commit -a -m "Copy file2 to file11" &&
  		git diff-tree -r -C --find-copies-harder HEAD &&
  		src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
-		case "$src" in
-		file2 | file10) : ;; # happy
-		*) false ;; # not
-		esac &&
+		test "$src" = file2 &&
  		git config git-p4.detectCopiesHarder true &&
  		git p4 submit &&
  		p4 filelog //depot/file11 &&
-		p4 filelog //depot/file11 | grep -q "branch from //depot/file" &&
+		p4 filelog //depot/file11 | grep -q "branch from //depot/file2" &&
+
+		echo "file12" >> file2 &&
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&

  		cp file2 file12 &&
  		echo "some text" >>file12 &&
@@ -180,15 +198,16 @@ test_expect_success 'detect copies' '
  		level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&
  		test -n "$level" && test "$level" -gt 0 && test "$level" -lt 98 &&
  		src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
-		case "$src" in
-		file10 | file11) : ;; # happy
-		*) false ;; # not
-		esac &&
+		test "$src" = file2 &&
  		git config git-p4.detectCopies $(($level + 2)) &&
  		git p4 submit &&
  		p4 filelog //depot/file12 &&
  		p4 filelog //depot/file12 | test_must_fail grep -q "branch from" &&

+		echo "file13" >> file2 &&
+		git commit -a -m "Differentiate file2" &&
+		git p4 submit &&
+
  		cp file2 file13 &&
  		echo "different text" >>file13 &&
  		git add file13 &&
@@ -197,14 +216,11 @@ test_expect_success 'detect copies' '
  		level=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f1 | cut -d" " -f5 | sed "s/C0*//") &&
  		test -n "$level" && test "$level" -gt 2 && test "$level" -lt 100 &&
  		src=$(git diff-tree -r -C --find-copies-harder HEAD | sed 1d | cut -f2) &&
-		case "$src" in
-		file10 | file11 | file12) : ;; # happy
-		*) false ;; # not
-		esac &&
+		test "$src" = file2 &&
  		git config git-p4.detectCopies $(($level - 2)) &&
  		git p4 submit &&
  		p4 filelog //depot/file13 &&
-		p4 filelog //depot/file13 | grep -q "branch from //depot/file"
+		p4 filelog //depot/file13 | grep -q "branch from //depot/file2"
  	)
  '
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help