From 5ed233c0db216f471a96067281914621f40b342c Mon Sep 17 00:00:00 2001 From: James Procter Date: Wed, 20 Sep 2023 15:14:05 +0100 Subject: [PATCH] JAL-4217 - try to invokeAndWait on Desktop.closeAll() to avoid Jmol redraw blocking close --- test/jalview/bin/CommandsTest.java | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/test/jalview/bin/CommandsTest.java b/test/jalview/bin/CommandsTest.java index 4d10c31..8dae8f3 100644 --- a/test/jalview/bin/CommandsTest.java +++ b/test/jalview/bin/CommandsTest.java @@ -2,11 +2,14 @@ package jalview.bin; import java.io.File; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.nio.file.Files; import java.util.Date; import java.util.HashSet; import java.util.Set; +import javax.swing.SwingUtilities; + import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; @@ -46,9 +49,26 @@ public class CommandsTest } @AfterMethod(alwaysRun = true) - public void tearDown() + public void tearDown() { - Desktop.closeDesktop(); + try + { + // occasionally we are blocked by Jmol redraws + SwingUtilities.invokeAndWait(new Runnable() + { + + @Override + public void run() + { + Desktop.closeDesktop(); + } + }); + } catch (Exception foo) + { + System.err.println("Failed during teardown with exception"); + foo.printStackTrace(); + } + } public static void callJalviewMain(String[] args) -- 1.7.10.2