Source: jsurf-alggeo Version: 0.4.1+ds-3 Severity: normal X-Debbugs-Cc: vladimir.pe...@canonical.com
Dear Maintainer, The package fails make-TestJSurf test due to the race condition de.mfo.jsurf.test.TestJSurf creates a SwingWorker, waits 100 milliseconds, attempts to cancel rendering tasks in stopDrawingMethod() and then asserts that time after swing worker creation has not exceeded 200 msec. This is a flaky assertion that depends on the host machine's performance. See related log [1]. Would it be possible to consider a patch that retries stopDrawing() and asserts that the rendering was interrupted instead? Thank you for considering the patch! [1] https://ci.debian.net/data/autopkgtest/unstable/armel/j/jsurf- alggeo/31633915/log.gz
diff --git a/src/test/java/de/mfo/jsurf/test/TestJSurf.java b/src/test/java/de/mfo/jsurf/test/TestJSurf.java index 4f83c0f..8b93a3f 100644 --- a/src/test/java/de/mfo/jsurf/test/TestJSurf.java +++ b/src/test/java/de/mfo/jsurf/test/TestJSurf.java @@ -8,6 +8,10 @@ import de.mfo.jsurf.algebra.*; import de.mfo.jsurf.parser.*; import de.mfo.jsurf.util.FileFormat; import java.util.Properties; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + import javax.swing.SwingWorker; public class TestJSurf @@ -27,6 +31,8 @@ public class TestJSurf class BackgroundRenderer extends SwingWorker< Void, Void > { + public boolean interrupted = false; + @Override public Void doInBackground() { try { @@ -35,6 +41,7 @@ public class TestJSurf catch( RenderingInterruptedException rie ) { System.out.println( "Rendering interrupted" ); + interrupted = true; } return null; } @@ -45,16 +52,23 @@ public class TestJSurf br.execute(); long t = System.currentTimeMillis(); - Thread.sleep( 100 ); - System.out.println( "Attempting to stop rendering" ); - asr.stopDrawing(); + for (int i = 0; i < 100; ) { + try + { + asr.stopDrawing(); + br.get(100, TimeUnit.MILLISECONDS); + break; + } + catch (InterruptedException e) {} + catch (ExecutionException e) {} + catch (TimeoutException e) {} + } - br.get(); t = System.currentTimeMillis() - t; System.out.println( "Render method finished after " + t + "ms" ); - Assert.assertTrue( "stopDrawing must interrupt and stop the rendering process", t < 200 ); + Assert.assertTrue( "stopDrawing must interrupt and stop the rendering process", br.interrupted ); } @Test