Skip to content

Commit 4cf00ef

Browse files
committed
Fix travis build
Ignore windows / mac / linux carriage return differences Ignore test duration differences
1 parent ea96029 commit 4cf00ef

File tree

5 files changed

+26
-15
lines changed

5 files changed

+26
-15
lines changed

utplsql-maven-plugin/src/test/java/org/utpsql/maven/plugin/test/UtPLSQLMojoTest.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
import java.io.File;
44
import java.io.IOException;
5+
import java.nio.file.Files;
6+
import java.nio.file.Paths;
7+
import java.util.stream.Collectors;
8+
import java.util.stream.Stream;
59

610
import org.apache.commons.io.FileUtils;
711
import org.apache.maven.plugin.testing.MojoRule;
@@ -29,7 +33,7 @@ public void testDefinition() throws Exception
2933
Assert.assertNotNull(myMojo);
3034
myMojo.execute();
3135

32-
checkCoverReportsGenerated(PROJECT_NAME,"utplsql/coverage-sonar-reporter.xml", "utplsql/sonar-test-reporter.xml");
36+
checkReportsGenerated(PROJECT_NAME,"utplsql/coverage-sonar-reporter.xml", "utplsql/sonar-test-reporter.xml");
3337
}
3438
catch (Exception e)
3539
{
@@ -49,7 +53,7 @@ public void testRegexDefinition() throws Exception
4953
Assert.assertNotNull(myMojo);
5054
myMojo.execute();
5155

52-
checkCoverReportsGenerated(PROJECT_NAME,"utplsql/coverage-sonar-reporter.xml", "utplsql/sonar-test-reporter.xml");
56+
checkReportsGenerated(PROJECT_NAME,"utplsql/coverage-sonar-reporter.xml", "utplsql/sonar-test-reporter.xml");
5357
}
5458
catch (Exception e)
5559
{
@@ -62,7 +66,7 @@ public void testRegexDefinition() throws Exception
6266
*
6367
* @param files
6468
*/
65-
private void checkCoverReportsGenerated(String projectName, String... files)
69+
private void checkReportsGenerated(String projectName, String... files)
6670
{
6771
for (String filename : files)
6872
{
@@ -71,16 +75,23 @@ private void checkCoverReportsGenerated(String projectName, String... files)
7175

7276
Assert.assertTrue("The reporter for " + filename + " was not generated", outputFile.exists());
7377
try {
74-
// Duration is set to 1 before comparing contents.
78+
// Duration is set to 1 before comparing contents as it is always different.
79+
// Path separator is set to "/" to ensure windows / linux / mac compatibility
80+
Stream<String> stream = Files.lines(Paths.get(TARGET_DIRECTORY,projectName,"target",filename));
81+
String outputContent = stream.map(line -> line.replaceAll("(duration=\"[0-9\\.]*\")", "duration=\"1\""))
82+
.map(line -> line.replaceAll("\\\\", "/"))
83+
.map(line -> line.replaceAll("\r", "").replaceAll("\n", ""))
84+
.collect(Collectors.joining("\n"));
85+
86+
stream.close();
7587
Assert.assertEquals("The files differ!",
76-
FileUtils.readFileToString(outputFile, "utf-8").replaceAll("(duration=\"[0-9\\.]*\")", "duration=\"1\""),
77-
FileUtils.readFileToString(expectedOutputFile, "utf-8"));
88+
outputContent,
89+
FileUtils.readFileToString(expectedOutputFile, "utf-8").replace("\r",""));
7890
} catch (IOException e) {
7991
// TODO Auto-generated catch block
8092
e.printStackTrace();
8193
Assert.fail("Unexpected Exception running the test of Definition");
8294
}
8395
}
8496
}
85-
8697
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<coverage version="1">
2-
<file path="src\test\resources\regex-project\scripts\sources\app\packages\PKG_TEST_ME.bdy">
2+
<file path="src/test/resources/regex-project/scripts/sources/app/packages/PKG_TEST_ME.bdy">
33
<lineToCover lineNumber="8" covered="true"/>
44
<lineToCover lineNumber="9" covered="true"/>
55
<lineToCover lineNumber="10" covered="true"/>
@@ -9,4 +9,4 @@
99
<lineToCover lineNumber="22" covered="true"/>
1010
<lineToCover lineNumber="23" covered="true"/>
1111
</file>
12-
</coverage>
12+
</coverage>

utplsql-maven-plugin/src/test/resources/regex-project/expected-output/utplsql/sonar-test-reporter.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<testExecutions version="1">
2-
<file path="src\test\resources\regex-project\scripts\test\app\packages\TEST_PKG_TEST_ME.bdy">
2+
<file path="src/test/resources/regex-project/scripts/test/app/packages/TEST_PKG_TEST_ME.bdy">
33
<testCase name="test_fc_input_1" duration="1" >
44
</testCase>
55
<testCase name="test_fc_input_0" duration="1" >
@@ -15,4 +15,4 @@
1515
<testCase name="test_pr_test_me_cursor" duration="1" >
1616
</testCase>
1717
</file>
18-
</testExecutions>
18+
</testExecutions>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<coverage version="1">
2-
<file path="src\test\resources\simple-project\scripts\sources\APP.PKG_TEST_ME.bdy">
2+
<file path="src/test/resources/simple-project/scripts/sources/APP.PKG_TEST_ME.bdy">
33
<lineToCover lineNumber="8" covered="true"/>
44
<lineToCover lineNumber="9" covered="true"/>
55
<lineToCover lineNumber="10" covered="true"/>
@@ -9,4 +9,4 @@
99
<lineToCover lineNumber="22" covered="true"/>
1010
<lineToCover lineNumber="23" covered="true"/>
1111
</file>
12-
</coverage>
12+
</coverage>

utplsql-maven-plugin/src/test/resources/simple-project/expected-output/utplsql/sonar-test-reporter.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<testExecutions version="1">
2-
<file path="src\test\resources\simple-project\scripts\tests\APP.TEST_PKG_TEST_ME.bdy">
2+
<file path="src/test/resources/simple-project/scripts/tests/APP.TEST_PKG_TEST_ME.bdy">
33
<testCase name="test_fc_input_1" duration="1" >
44
</testCase>
55
<testCase name="test_fc_input_0" duration="1" >
@@ -15,4 +15,4 @@
1515
<testCase name="test_pr_test_me_cursor" duration="1" >
1616
</testCase>
1717
</file>
18-
</testExecutions>
18+
</testExecutions>

0 commit comments

Comments
 (0)