Skip to content

Commit

Permalink
Reactivate TestMetrics4BearsJsonFile
Browse files Browse the repository at this point in the history
Signed-off-by: André Silva <[email protected]>
  • Loading branch information
andre15silva committed May 14, 2021
1 parent d885acb commit 07893b7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@ public void tearDown() throws IOException {
FileHelper.deleteFile(tmpDir);
}

/*
FIXME: Previous error was fixed. Path to bears-chema.json is now working.
Current issue is that the json file that the result is compared to isn't reproducible.
One way to fix the issue would be to set the JSON comparison to LENIENT, and edit the json to contain only the parts that never change between runs.
*/
@Ignore
@Test
public void testBearsJsonFileWithPassingPassingBuilds() throws IOException, ProcessingException {
long buggyBuildCandidateId = 225920540; // https://travis-ci.com/github/repairnator/test-repairnator-bears/builds/225920540
Expand Down Expand Up @@ -159,7 +153,7 @@ public void testBearsJsonFileWithPassingPassingBuilds() throws IOException, Proc
String fieldComparisonFailureName = fieldComparisonFailure.getField();
if (fieldComparisonFailureName.equals("tests.failingModule") ||
fieldComparisonFailureName.equals("reproductionBuggyBuild.projectRootPomPath")) {
String path = "repairnator/test-repairnator-bears/386337343";
String path = "repairnator/test-repairnator-bears";
String expected = (String) fieldComparisonFailure.getExpected();
expected = expected.substring(expected.indexOf(path), expected.length());
String actual = (String) fieldComparisonFailure.getActual();
Expand All @@ -175,14 +169,9 @@ public void testBearsJsonFileWithPassingPassingBuilds() throws IOException, Proc
}
}

/*
FIXME: See message of the previous test. Plus, the buildId isn't on travis.com and it has been deleted from travis.org
To fix this, another build needs to replace this one, so results may be different.
*/
@Ignore
@Test
public void testRepairnatorJsonFileWithFailingBuild() throws IOException, ProcessingException {
long buggyBuildCandidateId = 208897371; // https://travis-ci.org/surli/failingProject/builds/208897371
long buggyBuildCandidateId = 220944190; // https://travis-ci.com/github/repairnator/failingProject/builds/220944190

tmpDir = Files.createTempDirectory("test_repairnator_json_file_failing_build").toFile();

Expand All @@ -194,7 +183,7 @@ public void testRepairnatorJsonFileWithFailingBuild() throws IOException, Proces
config.setLauncherMode(LauncherMode.REPAIR);
config.setRepairTools(new HashSet<>(Arrays.asList("NopolSingleTest")));

ProjectInspector inspector = new ProjectInspector(buildToBeInspected, tmpDir.getAbsolutePath(), null, null);
ProjectInspector inspector = InspectorFactory.getTravisInspector(buildToBeInspected, tmpDir.getAbsolutePath(), null);
inspector.run();

// check repairnator.json against schema
Expand Down Expand Up @@ -235,9 +224,15 @@ public void testRepairnatorJsonFileWithFailingBuild() throws IOException, Proces

for (FieldComparisonFailure fieldComparisonFailure : result.getFieldFailures()) {
String fieldComparisonFailureName = fieldComparisonFailure.getField();
if (fieldComparisonFailureName.equals("tests.failingModule") ||
if (fieldComparisonFailureName.equals("tests.failureDetails[0].detail")) {
String expected = (String) fieldComparisonFailure.getExpected();
String actual = (String) fieldComparisonFailure.getActual();
assertTrue("Property failing: " + fieldComparisonFailureName,
actual.replaceAll("\\s+", "")
.equals(expected.replaceAll("\\s+", "")));
} else if (fieldComparisonFailureName.equals("tests.failingModule") ||
fieldComparisonFailureName.equals("reproductionBuggyBuild.projectRootPomPath")) {
String path = "surli/failingProject/208897371";
String path = "repairnator/failingProject";
String expected = (String) fieldComparisonFailure.getExpected();
expected = expected.substring(expected.indexOf(path), expected.length());
String actual = (String) fieldComparisonFailure.getActual();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"version": "Bears 1.0",
"type": "passing_passing",
"repository": {
"name": "fermadeiral/test-repairnator-bears",
"name": "repairnator/test-repairnator-bears",
"githubId": 135598437,
"url": "https://github.com/fermadeiral/test-repairnator-bears",
"url": "https://github.com/repairnator/test-repairnator-bears",
"isFork": false,
"original": {
"name": "",
Expand All @@ -16,34 +16,34 @@
},
"builds": {
"buggyBuild": {
"id": 386337343,
"url": "http://travis-ci.org/fermadeiral/test-repairnator-bears/builds/386337343",
"date": "May 31, 2018 4:33:25 PM"
"id": 225920540,
"url": "http://travis-ci.org/repairnator/test-repairnator-bears/builds/225920540",
"date": "May 14, 2021, 11:10:26 AM"
},
"fixerBuild": {
"id": 386348522,
"url": "http://travis-ci.org/fermadeiral/test-repairnator-bears/builds/386348522",
"date": "May 31, 2018 5:01:06 PM"
"id": 225920529,
"url": "http://travis-ci.org/repairnator/test-repairnator-bears/builds/225920529",
"date": "May 14, 2021, 11:10:18 AM"
}
},
"commits": {
"buggyBuild": {
"repoName": "fermadeiral/test-repairnator-bears",
"repoName": "repairnator/test-repairnator-bears",
"branchName": "master",
"sha": "bfdf6af10937db8ecde7a060b55d18864663abd5",
"url": "http://github.com/fermadeiral/test-repairnator-bears/commit/bfdf6af10937db8ecde7a060b55d18864663abd5",
"url": "http://github.com/repairnator/test-repairnator-bears/commit/bfdf6af10937db8ecde7a060b55d18864663abd5",
"date": "May 31, 2018 4:32:11 PM"
},
"fixerBuild": {
"repoName": "fermadeiral/test-repairnator-bears",
"repoName": "repairnator/test-repairnator-bears",
"branchName": "master",
"sha": "5b2ed0064d4c5e0fade39125cc071bd6593df869",
"url": "http://github.com/fermadeiral/test-repairnator-bears/commit/5b2ed0064d4c5e0fade39125cc071bd6593df869",
"url": "http://github.com/repairnator/test-repairnator-bears/commit/5b2ed0064d4c5e0fade39125cc071bd6593df869",
"date": "May 31, 2018 4:59:52 PM"
}
},
"tests": {
"failingModule": "/tmp/test_bears_json_file_passing_passing_builds4300363164793498124/fermadeiral/test-repairnator-bears/386337343/test-repairnator-bears-patchstats",
"failingModule": "/tmp/test_bears_json_file_passing_passing_builds4300363164793498124/repairnator/test-repairnator-bears/test-repairnator-bears-patchstats",
"overallMetrics": {
"numberRunning": 9,
"numberPassing": 8,
Expand Down Expand Up @@ -73,7 +73,7 @@
"testClass": "PatchStatsTest",
"testMethod": "testComputeFilesWithCommitThatRenameFile",
"failureName": "java.lang.AssertionError",
"detail": "expected:\u003c10\u003e but was:\u003c9\u003e",
"detail": "java.lang.AssertionError: expected:\u003c10\u003e but was:\u003c9\u003e\n\tat org.junit.Assert.fail(Assert.java:88)\n\tat org.junit.Assert.failNotEquals(Assert.java:834)\n\tat org.junit.Assert.assertEquals(Assert.java:645)\n\tat org.junit.Assert.assertEquals(Assert.java:631)\n\tat PatchStatsTest.testComputeFilesWithCommitThatRenameFile(PatchStatsTest.java:62)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:566)\n\tat org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)\n\tat org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)\n\tat org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)\n\tat org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)\n\tat org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)\n\tat org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)\n\tat org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)\n\tat org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)\n\tat org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)\n\tat org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)\n\tat org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)\n\tat org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)\n\tat org.junit.runners.ParentRunner.run(ParentRunner.java:363)\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:566)\n\tat org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)\n\tat org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)\n\tat org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)\n\tat org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)\n\tat org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)",
"isError": false
}
]
Expand All @@ -91,6 +91,7 @@
},
"projectMetrics": {
"numberModules": 2,
"numberPlugins": 0,
"numberSourceFiles": 2,
"numberTestFiles": 3,
"numberLibrariesFailingModule": 4,
Expand Down Expand Up @@ -146,6 +147,6 @@
]
}
},
"projectRootPomPath": "/tmp/test_bears_json_file_passing_passing_builds4300363164793498124/fermadeiral/test-repairnator-bears/386337343/pom.xml"
"projectRootPomPath": "/tmp/test_bears_json_file_passing_passing_builds4300363164793498124/repairnator/test-repairnator-bears/pom.xml"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"type": "only_fail",
"repository": {
"name": "surli/failingProject",
"githubId": 78415513,
"url": "https://github.com/surli/failingProject",
"name": "repairnator/failingProject",
"githubId": 345049665,
"url": "https://github.com/repairnator/failingProject",
"isFork": false,
"original": {
"name": "",
Expand All @@ -15,22 +15,22 @@
},
"builds": {
"buggyBuild": {
"id": 208897371,
"url": "http://travis-ci.org/surli/failingProject/builds/208897371",
"date": "Mar 8, 2017 4:07:02 AM"
"id": 220944190,
"url": "http://travis-ci.org/repairnator/failingProject/builds/220944190",
"date": "Mar 23, 2021, 10:44:24 AM"
}
},
"commits": {
"buggyBuild": {
"repoName": "surli/failingProject",
"repoName": "repairnator/failingProject",
"branchName": "only-one-failing",
"sha": "e17771af92490121d4b1655c0bdf36b3692f1ce3",
"url": "http://github.com/surli/failingProject/commit/e17771af92490121d4b1655c0bdf36b3692f1ce3",
"url": "http://github.com/repairnator/failingProject/commit/e17771af92490121d4b1655c0bdf36b3692f1ce3",
"date": "Mar 8, 2017 4:05:44 AM"
}
},
"tests": {
"failingModule": "/tmp/test_bears_json_file_failing_build4879665694333003261/surli/failingProject/208897371",
"failingModule": "/tmp/test_bears_json_file_failing_build4879665694333003261/repairnator/failingProject",
"overallMetrics": {
"numberRunning": 8,
"numberPassing": 7,
Expand Down Expand Up @@ -60,7 +60,7 @@
"testClass": "nopol_examples.nopol_example_1.NopolExampleTest",
"testMethod": "test5",
"failureName": "java.lang.StringIndexOutOfBoundsException",
"detail": "String index out of range: -5",
"detail": "java.lang.StringIndexOutOfBoundsException: String index out of range: -5\n\tat java.base/java.lang.StringLatin1.charAt(StringLatin1.java:47)\n\tat java.base/java.lang.String.charAt(String.java:693)\n\tat nopol_examples.nopol_example_1.NopolExample.charAt(NopolExample.java:16)\n\tat nopol_examples.nopol_example_1.NopolExampleTest.test5(NopolExampleTest.java:39)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:566)\n\tat org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)\n\tat org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)\n\tat org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)\n\tat org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)\n\tat org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)\n\tat org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)\n\tat org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)\n\tat org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)\n\tat org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)\n\tat org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)\n\tat org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)\n\tat org.junit.runners.ParentRunner.run(ParentRunner.java:309)\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)\n\tat org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:566)\n\tat org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)\n\tat org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)\n\tat org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)\n\tat org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)\n\tat org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)",
"isError": true
}
]
Expand All @@ -78,6 +78,7 @@
},
"projectMetrics": {
"numberModules": 1,
"numberPlugins": 0,
"numberSourceFiles": 10,
"numberTestFiles": 1,
"numberLibrariesFailingModule": 2,
Expand Down Expand Up @@ -137,6 +138,6 @@
]
}
},
"projectRootPomPath": "/tmp/test_bears_json_file_failing_build4879665694333003261/surli/failingProject/208897371/pom.xml"
"projectRootPomPath": "/tmp/test_bears_json_file_failing_build4879665694333003261/repairnator/failingProject/pom.xml"
}
}

0 comments on commit 07893b7

Please sign in to comment.