You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by ss...@apache.org on 2024/06/07 06:37:12 UTC
(xmlgraphics-batik) branch temp/ssteiner-windows updated (964b035f8 -> 022bf920f)
This is an automated email from the ASF dual-hosted git repository.
ssteiner pushed a change to branch temp/ssteiner-windows
in repository https://gitbox.apache.org/repos/asf/xmlgraphics-batik.git
discard 964b035f8 Fix tests on windows by Peter Hull
new 022bf920f Fix tests on windows by Peter Hull
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (964b035f8)
\
N -- N -- N refs/heads/temp/ssteiner-windows (022bf920f)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../test/java/org/apache/batik/test/xml/JUnitRunnerTestCase.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org
(xmlgraphics-batik) 01/01: Fix tests on windows by Peter Hull
Posted by ss...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ssteiner pushed a commit to branch temp/ssteiner-windows
in repository https://gitbox.apache.org/repos/asf/xmlgraphics-batik.git
commit 022bf920f25a6001cfa4d0d2b80aa7da1808c931
Author: Peter Hull <pe...@gmail.com>
AuthorDate: Mon Jun 3 14:30:38 2024 +0100
Fix tests on windows by Peter Hull
Force test resource files to be binary
On Windows, git would treat the unencoded files as text and apply CRLF line endings, so their base 64 encodings would not match the reference files.
Work around timing issues on Windows
On Windows the elapsed time was quite unreliable, causing intermittent fails in the performance tests, presumably made worse because PCs / the JRE are faster now then when this code was written.
Also fixed up a few warnings/javadoc issues and replaced a home-grown bubble sort with Arrays.sort.
---
.github/workflows/maven.yml | 2 +-
.../apache/batik/test/xml/JUnitRunnerTestCase.java | 5 ++
.../org/apache/batik/test/PerformanceTest.java | 59 ++++++++++++----------
.../resources/org/apache/batik/util/.gitattributes | 1 +
4 files changed, 38 insertions(+), 29 deletions(-)
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 8ae94b9a2..032cf8e51 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
jdk: ['8', '11', '17']
- os: [ubuntu-latest]
+ os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v4
diff --git a/batik-test-old/src/test/java/org/apache/batik/test/xml/JUnitRunnerTestCase.java b/batik-test-old/src/test/java/org/apache/batik/test/xml/JUnitRunnerTestCase.java
index 177536831..e93794c51 100644
--- a/batik-test-old/src/test/java/org/apache/batik/test/xml/JUnitRunnerTestCase.java
+++ b/batik-test-old/src/test/java/org/apache/batik/test/xml/JUnitRunnerTestCase.java
@@ -92,6 +92,11 @@ public class JUnitRunnerTestCase {
}
private static void addTests(Test test, List<Test[]> tests) {
+ if (System.getProperty("os.name").startsWith("Windows")) {
+ EXCLUDE = new ArrayList<>(EXCLUDE);
+ EXCLUDE.add("PerformanceTestValidator");
+ EXCLUDE.add("PerformanceTestSanity");
+ }
if (test instanceof DefaultTestSuite) {
for (Test child : ((DefaultTestSuite) test).getChildrenTests()) {
if (!EXCLUDE.contains(getId(test))) {
diff --git a/batik-test/src/main/java/org/apache/batik/test/PerformanceTest.java b/batik-test/src/main/java/org/apache/batik/test/PerformanceTest.java
index 070893763..4d27faec1 100644
--- a/batik-test/src/main/java/org/apache/batik/test/PerformanceTest.java
+++ b/batik-test/src/main/java/org/apache/batik/test/PerformanceTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.batik.test;
+import java.util.Arrays;
import java.util.Vector;
/**
@@ -74,7 +75,9 @@ public abstract class PerformanceTest extends AbstractTest {
/**
* Force implementations to only implement <code>runOp</code>
* and other performance specific methods.
+ * @return the results of AbstractTest's run method
*/
+ @Override
public final TestReport run() {
return super.run();
}
@@ -82,8 +85,10 @@ public abstract class PerformanceTest extends AbstractTest {
/**
* Force implementations to only implement <code>runOp</code>
* and other performance specific methods.
+ * @return false always, indicating failure
*/
- public final boolean runImplBasic() throws Exception {
+ @Override
+ public final boolean runImplBasic() {
// Should never be called for a PerformanceTest
return false;
}
@@ -95,18 +100,21 @@ public abstract class PerformanceTest extends AbstractTest {
* or not the score is within the allowed deviation of the
* reference score.
*
+ * @return the test report
+ * @throws java.lang.Exception if an error occurred
* @see #runRef
* @see #runOp
*/
+ @Override
public final TestReport runImpl() throws Exception {
int iter = 50;
- double refUnit = 0;
- long refStart = 0;
- long refEnd = 0;
- long opEnd = 0;
- long opStart = 0;
- double opLength = 0;
+ double refUnit;
+ long refStart;
+ long refEnd;
+ long opEnd;
+ long opStart;
+ double opLength;
// Run once to remove class load time from timing.
runRef();
@@ -114,8 +122,9 @@ public abstract class PerformanceTest extends AbstractTest {
// System.gc();
double[] scores = new double[iter];
-
- for (int i=0; i<iter; i++) {
+ // Count bad scores so it doesn't get stuck forever
+ int badScores = 0;
+ for (int i=0; i<iter; ) {
if ( i%2 == 0) {
refStart = System.currentTimeMillis();
runRef();
@@ -133,9 +142,18 @@ public abstract class PerformanceTest extends AbstractTest {
refUnit = refEnd - opEnd;
opLength = opEnd - opStart;
}
+ // Only accept finite and non-zero scores
+ if (opLength > 0.0 && refUnit > 0.0) {
+ scores[i++] = opLength / refUnit;
+ System.err.print(".");
+ } else {
+ System.err.print("!");
+ if (++badScores > iter) {
+ // Too many bad scores
+ throw new IllegalStateException("Unable to obtain reliable timings");
- scores[i] = opLength / refUnit;
- System.err.println(".");
+ }
+ }
// System.err.println(">>>>>>>> scores[" + i + "] = " + scores[i] + " (" + refUnit + " / " + opLength + ")");
System.gc();
}
@@ -143,7 +161,7 @@ public abstract class PerformanceTest extends AbstractTest {
System.err.println();
// Now, sort the scores
- sort(scores);
+ Arrays.sort(scores);
// Compute the mean score based on the scores, not accounting
// for the lowest and highest scores
@@ -184,22 +202,6 @@ public abstract class PerformanceTest extends AbstractTest {
}
}
- protected void sort(double[] a) throws Exception {
- for (int i = a.length - 1; i>=0; i--) {
- boolean swapped = false;
- for (int j = 0; j<i; j++) {
- if (a[j] > a[j+1]) {
- double d = a[j];
- a[j] = a[j+1];
- a[j+1] = d;
- swapped = true;
- }
- }
- if (!swapped)
- return;
- }
- }
-
/**
* Runs the reference operation.
* By default, this runs the same BufferedImage drawing
@@ -220,6 +222,7 @@ public abstract class PerformanceTest extends AbstractTest {
/**
* Runs the tested operation
+ * @throws java.lang.Exception if an error occurred
*/
protected abstract void runOp() throws Exception;
}
diff --git a/batik-util/src/test/resources/org/apache/batik/util/.gitattributes b/batik-util/src/test/resources/org/apache/batik/util/.gitattributes
new file mode 100644
index 000000000..625449502
--- /dev/null
+++ b/batik-util/src/test/resources/org/apache/batik/util/.gitattributes
@@ -0,0 +1 @@
+* -text
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org