]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Add a large number of move/copy diff/patch tests
authorepriestley <git@epriestley.com>
Sat, 20 Oct 2012 15:43:31 +0000 (08:43 -0700)
committerepriestley <git@epriestley.com>
Sat, 20 Oct 2012 15:43:31 +0000 (08:43 -0700)
Summary: The way we represent some move/copy stuff is a bit messed up, but it mostly works, so add coverage before I mess with it.

Test Plan: Ran unit tests.

Reviewers: btrahan, vrana

Reviewed By: btrahan

CC: aran
Maniphest Tasks: T866

Differential Revision: https://secure.phabricator.com/D3752

12 files changed:
src/parser/__tests__/ArcanistBundleTestCase.php
src/parser/__tests__/bundle.git.tgz
src/parser/__tests__/patches/141452e2a775ee86409e8779dd2eda767b4fe8ab.gitpatch [new file with mode: 0644]
src/parser/__tests__/patches/1c5fe4e2243bb19d6b3bf15896177b13768e6eb6.gitpatch [new file with mode: 0644]
src/parser/__tests__/patches/2658fd01d5355abe5d4c7ead3a0e7b4b3449fe77.gitpatch [new file with mode: 0644]
src/parser/__tests__/patches/30d23787e1ecd254c884afbe37afa612f61e3904.gitpatch [new file with mode: 0644]
src/parser/__tests__/patches/6d9eb65a2c2b56dee64d72f59554c1cca748dd34.gitpatch [new file with mode: 0644]
src/parser/__tests__/patches/b0c9663ecda5f666f62dad245a3a7549aac5e636.gitpatch [new file with mode: 0644]
src/parser/__tests__/patches/b6ecdb3b4801f3028d88ba49940a558360847dbf.gitpatch [new file with mode: 0644]
src/parser/__tests__/patches/c0ba9bfe3695f95c3f558bc5797eeba421d32483.gitpatch [new file with mode: 0644]
src/parser/__tests__/patches/c573c25d1a767d270fed504cd993e78aba936338.gitpatch [new file with mode: 0644]
src/parser/__tests__/patches/d26628e588cf7d16368845b121c6ac6c781e81d0.gitpatch [new file with mode: 0644]

index dbb9daf00d50d50c7ce20d002ad57c13a4775033..a683748340f85a8e586fa28526785eb2ee5a736a 100644 (file)
@@ -146,6 +146,154 @@ final class ArcanistBundleTestCase extends ArcanistTestCase {
     }
 
     switch ($commit) {
+      case 'c573c25d1a767d270fed504cd993e78aba936338':
+        // "Copy a koan over text, editing the original koan."
+        // Git doesn't really do anything meaningful with this.
+
+        $this->assertEqual(2, count($changes));
+
+        $c = $changes['koan'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_CHANGE,
+          $c->getType());
+
+        $c = $changes['text'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_CHANGE,
+          $c->getType());
+
+        break;
+      case 'd26628e588cf7d16368845b121c6ac6c781e81d0':
+        // "Copy a koan, modifying both the source and destination."
+
+        $this->assertEqual(2, count($changes));
+
+        $c = $changes['koan'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_COPY_AWAY,
+          $c->getType());
+
+        $c = $changes['koan2'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_COPY_HERE,
+          $c->getType());
+
+        break;
+      case 'b0c9663ecda5f666f62dad245a3a7549aac5e636':
+        // "Remove a koan copy."
+
+        $this->assertEqual(1, count($changes));
+
+        $c = $changes['koan2'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_DELETE,
+          $c->getType());
+
+        break;
+      case 'b6ecdb3b4801f3028d88ba49940a558360847dbf':
+        // "Copy a koan and edit the destination."
+        // Git does not detect this as a copy without --find-copies-harder.
+
+        $this->assertEqual(1, count($changes));
+
+        $c = $changes['koan2'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_ADD,
+          $c->getType());
+
+        break;
+      case '30d23787e1ecd254c884afbe37afa612f61e3904':
+        // "Move and edit a koan."
+
+        $this->assertEqual(2, count($changes));
+
+        $c = $changes['koan2'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_MOVE_AWAY,
+          $c->getType());
+
+        $c = $changes['koan'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_MOVE_HERE,
+          $c->getType());
+
+        break;
+      case 'c0ba9bfe3695f95c3f558bc5797eeba421d32483':
+        // "Remove two koans."
+
+        $this->assertEqual(2, count($changes));
+
+        $c = $changes['koan3'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_DELETE,
+          $c->getType());
+
+        $c = $changes['koan4'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_DELETE,
+          $c->getType());
+
+        break;
+      case '2658fd01d5355abe5d4c7ead3a0e7b4b3449fe77':
+        // "Multicopy a koan."
+
+        $this->assertEqual(3, count($changes));
+
+        $c = $changes['koan'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_MULTICOPY,
+          $c->getType());
+
+        $c = $changes['koan3'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_COPY_HERE,
+          $c->getType());
+
+        $c = $changes['koan4'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_MOVE_HERE,
+          $c->getType());
+
+        break;
+      case '1c5fe4e2243bb19d6b3bf15896177b13768e6eb6':
+        // "Copy a koan."
+        // Git does not detect this as a copy without --find-copies-harder.
+
+        $this->assertEqual(1, count($changes));
+
+        $c = $changes['koan'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_ADD,
+          $c->getType());
+
+        break;
+      case '6d9eb65a2c2b56dee64d72f59554c1cca748dd34':
+        // "Move a koan."
+
+        $this->assertEqual(2, count($changes));
+
+        $c = $changes['koan'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_MOVE_AWAY,
+          $c->getType());
+
+        $c = $changes['koan2'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_MOVE_HERE,
+          $c->getType());
+
+        break;
+      case '141452e2a775ee86409e8779dd2eda767b4fe8ab':
+        // "Add a koan."
+
+        $this->assertEqual(1, count($changes));
+
+        $c = $changes['koan'];
+        $this->assertEqual(
+          ArcanistDiffChangeType::TYPE_ADD,
+          $c->getType());
+
+        break;
       case '5dec8bf28557f078d1987c4e8cfb53d08310f522':
         // "Copy an image, and replace the original."
         // `image_2.png` is copied to `image.png` and then replaced.
index 99178e93552775bd8f074e2503ffb522145d3d26..9ad428c61c6c69d7790b4534d1692ec497d82716 100644 (file)
Binary files a/src/parser/__tests__/bundle.git.tgz and b/src/parser/__tests__/bundle.git.tgz differ
diff --git a/src/parser/__tests__/patches/141452e2a775ee86409e8779dd2eda767b4fe8ab.gitpatch b/src/parser/__tests__/patches/141452e2a775ee86409e8779dd2eda767b4fe8ab.gitpatch
new file mode 100644 (file)
index 0000000..ca108c1
--- /dev/null
@@ -0,0 +1,18 @@
+diff --git a/koan b/koan
+new file mode 100644
+--- /dev/null
++++ b/koan
+@@ -0,0 +1,12 @@
++A monk asked Joshu,
++"Has a dog Buddha nature?"
++Joshu replied, "Mu".
++
++The quick brown
++fox jumped over
++the lazy dog.
++
++Git only detects changes
++as moves if both files
++are mostly similar. So
++you need a lot of text.
+
diff --git a/src/parser/__tests__/patches/1c5fe4e2243bb19d6b3bf15896177b13768e6eb6.gitpatch b/src/parser/__tests__/patches/1c5fe4e2243bb19d6b3bf15896177b13768e6eb6.gitpatch
new file mode 100644 (file)
index 0000000..ca108c1
--- /dev/null
@@ -0,0 +1,18 @@
+diff --git a/koan b/koan
+new file mode 100644
+--- /dev/null
++++ b/koan
+@@ -0,0 +1,12 @@
++A monk asked Joshu,
++"Has a dog Buddha nature?"
++Joshu replied, "Mu".
++
++The quick brown
++fox jumped over
++the lazy dog.
++
++Git only detects changes
++as moves if both files
++are mostly similar. So
++you need a lot of text.
+
diff --git a/src/parser/__tests__/patches/2658fd01d5355abe5d4c7ead3a0e7b4b3449fe77.gitpatch b/src/parser/__tests__/patches/2658fd01d5355abe5d4c7ead3a0e7b4b3449fe77.gitpatch
new file mode 100644 (file)
index 0000000..b829531
--- /dev/null
@@ -0,0 +1,7 @@
+diff --git a/koan b/koan3
+rename from koan
+rename to koan3
+diff --git a/koan b/koan4
+rename from koan
+rename to koan4
+
diff --git a/src/parser/__tests__/patches/30d23787e1ecd254c884afbe37afa612f61e3904.gitpatch b/src/parser/__tests__/patches/30d23787e1ecd254c884afbe37afa612f61e3904.gitpatch
new file mode 100644 (file)
index 0000000..34a4e54
--- /dev/null
@@ -0,0 +1,14 @@
+diff --git a/koan2 b/koan
+rename from koan2
+rename to koan
+--- a/koan2
++++ b/koan
+@@ -1,6 +1,6 @@
+ A monk asked Joshu,
+ "Has a dog Buddha nature?"
+-Joshu replied, "Mu".
++Joshu replied, "No".
+ 
+ The quick brown
+ fox jumped over
+
diff --git a/src/parser/__tests__/patches/6d9eb65a2c2b56dee64d72f59554c1cca748dd34.gitpatch b/src/parser/__tests__/patches/6d9eb65a2c2b56dee64d72f59554c1cca748dd34.gitpatch
new file mode 100644 (file)
index 0000000..a951924
--- /dev/null
@@ -0,0 +1,4 @@
+diff --git a/koan b/koan2
+rename from koan
+rename to koan2
+
diff --git a/src/parser/__tests__/patches/b0c9663ecda5f666f62dad245a3a7549aac5e636.gitpatch b/src/parser/__tests__/patches/b0c9663ecda5f666f62dad245a3a7549aac5e636.gitpatch
new file mode 100644 (file)
index 0000000..db11d5d
--- /dev/null
@@ -0,0 +1,18 @@
+diff --git a/koan2 b/koan2
+deleted file mode 100644
+--- a/koan2
++++ /dev/null
+@@ -1,12 +0,0 @@
+-A monk asked Joshu,
+-"Has a dog Buddha nature?"
+-Joshu replied, "Yes".
+-
+-The quick brown
+-fox jumped over
+-the lazy dog.
+-
+-Git only detects changes
+-as moves if both files
+-are mostly similar. So
+-you need a lot of text.
+
diff --git a/src/parser/__tests__/patches/b6ecdb3b4801f3028d88ba49940a558360847dbf.gitpatch b/src/parser/__tests__/patches/b6ecdb3b4801f3028d88ba49940a558360847dbf.gitpatch
new file mode 100644 (file)
index 0000000..5c75891
--- /dev/null
@@ -0,0 +1,18 @@
+diff --git a/koan2 b/koan2
+new file mode 100644
+--- /dev/null
++++ b/koan2
+@@ -0,0 +1,12 @@
++A monk asked Joshu,
++"Has a dog Buddha nature?"
++Joshu replied, "Yes".
++
++The quick brown
++fox jumped over
++the lazy dog.
++
++Git only detects changes
++as moves if both files
++are mostly similar. So
++you need a lot of text.
+
diff --git a/src/parser/__tests__/patches/c0ba9bfe3695f95c3f558bc5797eeba421d32483.gitpatch b/src/parser/__tests__/patches/c0ba9bfe3695f95c3f558bc5797eeba421d32483.gitpatch
new file mode 100644 (file)
index 0000000..e189ef0
--- /dev/null
@@ -0,0 +1,35 @@
+diff --git a/koan3 b/koan3
+deleted file mode 100644
+--- a/koan3
++++ /dev/null
+@@ -1,12 +0,0 @@
+-A monk asked Joshu,
+-"Has a dog Buddha nature?"
+-Joshu replied, "Mu".
+-
+-The quick brown
+-fox jumped over
+-the lazy dog.
+-
+-Git only detects changes
+-as moves if both files
+-are mostly similar. So
+-you need a lot of text.
+diff --git a/koan4 b/koan4
+deleted file mode 100644
+--- a/koan4
++++ /dev/null
+@@ -1,12 +0,0 @@
+-A monk asked Joshu,
+-"Has a dog Buddha nature?"
+-Joshu replied, "Mu".
+-
+-The quick brown
+-fox jumped over
+-the lazy dog.
+-
+-Git only detects changes
+-as moves if both files
+-are mostly similar. So
+-you need a lot of text.
+
diff --git a/src/parser/__tests__/patches/c573c25d1a767d270fed504cd993e78aba936338.gitpatch b/src/parser/__tests__/patches/c573c25d1a767d270fed504cd993e78aba936338.gitpatch
new file mode 100644 (file)
index 0000000..e517edd
--- /dev/null
@@ -0,0 +1,31 @@
+diff --git a/koan b/koan
+--- a/koan
++++ b/koan
+@@ -1,6 +1,6 @@
+ A monk asked Joshu,
+ "Has a dog Buddha nature?"
+-Joshu replied, "What?".
++Joshu replied, "Hmm?".
+ 
+ The quick brown
+ fox jumped over
+diff --git a/text b/text
+--- a/text
++++ b/text
+@@ -1,3 +1,12 @@
+-quack quack
+-I am a duck
+-quack quack
++A monk asked Joshu,
++"Has a dog Buddha nature?"
++Joshu replied, "What?".
++
++The quick brown
++fox jumped over
++the lazy dog.
++
++Git only detects changes
++as moves if both files
++are mostly similar. So
++you need a lot of text.
+
diff --git a/src/parser/__tests__/patches/d26628e588cf7d16368845b121c6ac6c781e81d0.gitpatch b/src/parser/__tests__/patches/d26628e588cf7d16368845b121c6ac6c781e81d0.gitpatch
new file mode 100644 (file)
index 0000000..7adb8b1
--- /dev/null
@@ -0,0 +1,25 @@
+diff --git a/koan b/koan
+--- a/koan
++++ b/koan
+@@ -1,6 +1,6 @@
+ A monk asked Joshu,
+ "Has a dog Buddha nature?"
+-Joshu replied, "No".
++Joshu replied, "What?".
+ 
+ The quick brown
+ fox jumped over
+diff --git a/koan b/koan2
+copy from koan
+copy to koan2
+--- a/koan
++++ b/koan2
+@@ -1,6 +1,6 @@
+ A monk asked Joshu,
+ "Has a dog Buddha nature?"
+-Joshu replied, "No".
++Joshu replied, "Unask the question!".
+ 
+ The quick brown
+ fox jumped over
+