Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Cartaud2016-02-25 17:00:21 +0000
committerMathieu Cartaud2016-02-25 17:00:21 +0000
commitd2e962e8b3616d70c704a2c2540003483fb3a1b6 (patch)
treee65fd7bde0d44cece441574e4f3357a673469a5b
parentdb3c0affd6036d9cdcbe211d6193dc25fd4d142b (diff)
downloadorg.eclipse.emf.compare-d2e962e8b3616d70c704a2c2540003483fb3a1b6.tar.gz
org.eclipse.emf.compare-d2e962e8b3616d70c704a2c2540003483fb3a1b6.tar.xz
org.eclipse.emf.compare-d2e962e8b3616d70c704a2c2540003483fb3a1b6.zip
Fix error in Git tests setup
Change-Id: Iada88223cb94e085ed7e63f27505e733c07eab1a Signed-off-by: Mathieu Cartaud <mathieu.cartaud@obeo.fr>
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui.tests.git/src/org/eclipse/emf/compare/ide/ui/tests/egit/CompareGitTestCase.java3
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui.tests.git/src/org/eclipse/emf/compare/ide/ui/tests/unit/GitLogicalMergeTest.java33
2 files changed, 22 insertions, 14 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.git/src/org/eclipse/emf/compare/ide/ui/tests/egit/CompareGitTestCase.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.git/src/org/eclipse/emf/compare/ide/ui/tests/egit/CompareGitTestCase.java
index 80dcba71a..d8c3928aa 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui.tests.git/src/org/eclipse/emf/compare/ide/ui/tests/egit/CompareGitTestCase.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.git/src/org/eclipse/emf/compare/ide/ui/tests/egit/CompareGitTestCase.java
@@ -116,6 +116,9 @@ public class CompareGitTestCase extends CompareTestCase {
assertEquals(expectedConflicts, compareResult.getConflicts().size());
assertDiffCount(compareResult.getDifferences(), diffsInDestination, diffsInSource);
+
+ // Other test call this method. The repository must be on the same branch at the end.
+ repository.checkoutBranch(source);
}
protected Comparison compare(String sourceRev, String targetRev, IFile file) throws Exception {
diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.git/src/org/eclipse/emf/compare/ide/ui/tests/unit/GitLogicalMergeTest.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.git/src/org/eclipse/emf/compare/ide/ui/tests/unit/GitLogicalMergeTest.java
index cc56ac597..8c2da6590 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui.tests.git/src/org/eclipse/emf/compare/ide/ui/tests/unit/GitLogicalMergeTest.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.git/src/org/eclipse/emf/compare/ide/ui/tests/unit/GitLogicalMergeTest.java
@@ -22,6 +22,8 @@ import static org.junit.Assert.fail;
import java.io.IOException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
@@ -437,7 +439,9 @@ public class GitLogicalMergeTest extends AbstractGitLogicalModelTest {
* the cross reference).
*/
compareBothDirectionsAndCheck(iFile1, MASTER, BRANCH, 1, 1, 1);
- compareBothDirectionsAndCheck(iFile2, MASTER, BRANCH, 0, 1, 0);
+ compareADirectionAndCheck(iFile2, MASTER, BRANCH, 0, 1, 0);
+ compareADirectionAndCheck(iFile2, BRANCH, MASTER, 1, 1, 1);
+ repository.checkoutBranch(MASTER);
}
/**
@@ -490,7 +494,8 @@ public class GitLogicalMergeTest extends AbstractGitLogicalModelTest {
* remote file1), but not when starting from file1 (since in such a case, we have no way to discover
* the cross reference).
*/
- compareBothDirectionsAndCheck(iFile1, MASTER, BRANCH, 0, 1, 0);
+ compareADirectionAndCheck(iFile1, MASTER, BRANCH, 0, 1, 0);
+ compareADirectionAndCheck(iFile1, BRANCH, MASTER, 1, 1, 1);
compareBothDirectionsAndCheck(iFile2, MASTER, BRANCH, 1, 1, 1);
}
@@ -552,13 +557,8 @@ public class GitLogicalMergeTest extends AbstractGitLogicalModelTest {
final Status status = repository.status();
assertFalse(status.hasUncommittedChanges());
- /*
- * The files are related locally, but EMF Compare cannot detect that when starting from file2 (it is
- * file1 that references file2) since the three sides of this comparison are created using the
- * subscriber's data.
- */
compareBothDirectionsAndCheck(iFile1, MASTER, BRANCH, 0, 1, 3);
- compareBothDirectionsAndCheck(iFile2, MASTER, BRANCH, 0, 0, 1);
+ compareBothDirectionsAndCheck(iFile2, MASTER, BRANCH, 0, 1, 3);
}
/**
@@ -613,13 +613,9 @@ public class GitLogicalMergeTest extends AbstractGitLogicalModelTest {
final Status status = repository.status();
assertFalse(status.hasUncommittedChanges());
- /*
- * The files are related locally, but EMF Compare cannot detect that when starting from file2 (it is
- * file1 that references file2) since the three sides of this comparison are created using the
- * subscriber's data.
- */
compareBothDirectionsAndCheck(iFile1, MASTER, BRANCH, 0, 1, 1);
- compareBothDirectionsAndCheck(iFile2, MASTER, BRANCH, 0, 0, 1);
+ compareBothDirectionsAndCheck(iFile2, MASTER, BRANCH, 0, 1, 1);
+
}
/*
@@ -1219,4 +1215,13 @@ public class GitLogicalMergeTest extends AbstractGitLogicalModelTest {
assertTrue(class1.getESuperTypes().contains(class3));
assertEquals(1, class1.getESuperTypes().size());
}
+
+ private void compareADirectionAndCheck(IFile file, String source, String destination,
+ int expectedConflicts, int diffsInSource, int diffsInDestination) throws Exception {
+ repository.checkoutBranch(source);
+ Comparison compareResult = compare(source, destination, file);
+
+ assertEquals(expectedConflicts, compareResult.getConflicts().size());
+ assertDiffCount(compareResult.getDifferences(), diffsInSource, diffsInDestination);
+ }
}

Back to the top