Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion forge-core/src/main/java/forge/CardStorageReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,11 @@ private void executeLoadTask(final Collection<CardRules> result, final List<Call
result.addAll(c.call());
}
}
} catch (InterruptedException | ExecutionException e) {
} catch (InterruptedException e) {
// Propagate so callers don't cache a partially-loaded card set as if it were complete.
Thread.currentThread().interrupt();
throw new RuntimeException(e);
} catch (ExecutionException e) {
e.printStackTrace();
} catch (final Exception e) { // this clause comes from non-threaded branch
throw new RuntimeException(e);
Expand Down
27 changes: 17 additions & 10 deletions forge-gui-desktop/src/test/java/forge/ai/AITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,26 @@
import forge.localinstance.properties.ForgePreferences.FPref;
import forge.model.FModel;

import org.testng.annotations.BeforeMethod;

public class AITest {
private static boolean initialized = false;

// One-time card DB load must run outside any @Test(timeOut) window, or a timeout interrupt mid-load corrupts the shared StaticData cache.
@BeforeMethod
public void initializeModel() {
if (initialized) {
return;
}
GuiBase.setInterface(new GuiDesktop());
FModel.initialize(null, preferences -> {
preferences.setPref(FPref.LOAD_CARD_SCRIPTS_LAZILY, false);
preferences.setPref(FPref.UI_LANGUAGE, "en-US");
return null;
});
initialized = true;
}

public Game resetGame() {
// need to be done after FModel.initialize, or the Localizer isn't loaded yet
List<RegisteredPlayer> players = Lists.newArrayList();
Expand All @@ -49,16 +66,6 @@ public Game resetGame() {
}

protected Game initAndCreateGame() {
if (!initialized) {
GuiBase.setInterface(new GuiDesktop());
FModel.initialize(null, preferences -> {
preferences.setPref(FPref.LOAD_CARD_SCRIPTS_LAZILY, false);
preferences.setPref(FPref.UI_LANGUAGE, "en-US");
return null;
});
initialized = true;
}

return resetGame();
}

Expand Down
Loading