Skip to content

Commit

Permalink
Do not show resource summary on reload
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Jan 14, 2025
1 parent 96d5a14 commit e13235a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,16 @@ protected static final Object runPrimitive(final int primCode, final Object rcvr
return ((Primitive4) PrimitiveNodeFactory.getOrCreateIndexed(primCode, 5)).execute(null, rcvr, arg1, arg2, arg3, arg4);
}

protected static final SqueakImage loadImageContext(final String imagePath) {
protected record TestImageSpec(String imagePath, boolean showResourceSummary) {
}

protected static final SqueakImage loadImageContext(final TestImageSpec spec) {
assert context == null && image == null;
final Builder contextBuilder = Context.newBuilder();
contextBuilder.allowAllAccess(true);
contextBuilder.option(SqueakLanguageConfig.ID + "." + SqueakLanguageOptions.IMAGE_PATH, imagePath);
contextBuilder.option(SqueakLanguageConfig.ID + "." + SqueakLanguageOptions.IMAGE_PATH, spec.imagePath);
contextBuilder.option(SqueakLanguageConfig.ID + "." + SqueakLanguageOptions.HEADLESS, "true");
contextBuilder.option(SqueakLanguageConfig.ID + "." + SqueakLanguageOptions.RESOURCE_SUMMARY, "true");
contextBuilder.option(SqueakLanguageConfig.ID + "." + SqueakLanguageOptions.RESOURCE_SUMMARY, Boolean.toString(spec.showResourceSummary));
contextBuilder.option(SqueakLanguageConfig.ID + "." + SqueakLanguageOptions.TESTING, "true");
final String logLevel = System.getProperty("log.level");
if (logLevel != null) {
Expand All @@ -109,7 +112,7 @@ protected static final SqueakImage loadImageContext(final String imagePath) {
context.enter();
try {
image = SqueakImageContext.getSlow();
if (Files.exists(Paths.get(imagePath))) {
if (Files.exists(Paths.get(spec.imagePath))) {
image.ensureLoaded();
}
return image.getSqueakImage(); // Pretend image has been loaded.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract class AbstractSqueakTestCaseWithDummyImage extends AbstractSquea
@BeforeClass
public static void setUpSqueakImageContext() {
SqueakImageContext.initializeBeforeLoadingImage();
loadImageContext("fake.image");
loadImageContext(new TestImageSpec("fake.image", false));
final Object[] dummySpecialObjects = new Object[100];
final ArrayObject dummySpecialSelectors = createDummySpecialSelectors();
dummySpecialObjects[SPECIAL_OBJECT.SPECIAL_SELECTORS] = dummySpecialSelectors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public static void setUp() {
}

public static void loadTestImage() {
loadTestImage(true);
loadTestImage(true, true);
}

private static void loadTestImage(final boolean retry) {
private static void loadTestImage(final boolean retry, final boolean showResourceSummary) {
executor = Executors.newSingleThreadExecutor();
final String imagePath = getPathToTestImage();
try {
runWithTimeout(imagePath, AbstractSqueakTestCase::loadImageContext, TEST_IMAGE_LOAD_TIMEOUT_SECONDS);
runWithTimeout(new TestImageSpec(imagePath, showResourceSummary), AbstractSqueakTestCase::loadImageContext, TEST_IMAGE_LOAD_TIMEOUT_SECONDS);
println("Test image loaded from " + imagePath + "...");
patchImageForTesting();
} catch (final InterruptedException e) {
Expand Down Expand Up @@ -95,7 +95,7 @@ public static void cleanUp() {

protected static void reloadImage() {
cleanUp();
loadTestImage(false);
loadTestImage(false, false);
}

private static void patchImageForTesting() {
Expand Down

0 comments on commit e13235a

Please sign in to comment.