Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AppReproducersTest#timezonesBakedIn #287

Merged
merged 1 commit into from
Sep 26, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,15 @@
public class AppReproducersTest {

private static final Logger LOGGER = Logger.getLogger(AppReproducersTest.class.getName());
private static final String LOCALEINCLUDES_SWITCH_REPLACEMENT_1_MANDREL_PRE_24_2_0 = "-J-Duser.country=CA";
private static final String LOCALEINCLUDES_SWITCH_REPLACEMENT_2_MANDREL_PRE_24_2_0 = "-J-Duser.language=fr";
private static final String LOCALEINCLUDES_SWITCH_REPLACEMENT_1_MANDREL_POST_24_2_0 = "-H:IncludeLocales=fr-CA";
private static final String LOCALEINCLUDES_SWITCH_REPLACEMENT_2_MANDREL_POST_24_2_0 = "";
private static final String EXTRA_TZONES_OPTS = "-Duser.language=fr";

public static final String BASE_DIR = getBaseDir();
public static final String LOCALEINCLUDES_TOKEN_1 = "<TZ_INCLUDE_TOKEN_1>";
public static final String LOCALEINCLUDES_TOKEN_2 = "<TZ_INCLUDE_TOKEN_2>";

@Test
@Tag("randomNumbers")
Expand Down Expand Up @@ -702,10 +709,25 @@ public void timezonesBakedIn(TestInfo testInfo) throws IOException, InterruptedE
// Build
processLog = Path.of(appDir.getAbsolutePath(), "logs", "build-and-run.log").toFile();

builderRoutine(app, report, cn, mn, appDir, processLog);
Map<String, String> switches = null;
final boolean inContainer = app.runtimeContainer != ContainerNames.NONE;
if (UsedVersion.getVersion(inContainer).compareTo(Version.create(24, 2, 0)) >= 0) {
// Locale inclusion for Mandrel 24.2 ignores -Duser.language and -Duser.country settings
// at build time.
switches = Map.of(LOCALEINCLUDES_TOKEN_1, LOCALEINCLUDES_SWITCH_REPLACEMENT_1_MANDREL_POST_24_2_0,
LOCALEINCLUDES_TOKEN_2, LOCALEINCLUDES_SWITCH_REPLACEMENT_2_MANDREL_POST_24_2_0);
} else {
switches = Map.of(LOCALEINCLUDES_TOKEN_1, LOCALEINCLUDES_SWITCH_REPLACEMENT_1_MANDREL_PRE_24_2_0,
LOCALEINCLUDES_TOKEN_2, LOCALEINCLUDES_SWITCH_REPLACEMENT_2_MANDREL_PRE_24_2_0);
}
builderRoutine(0, app.buildAndRunCmds.cmds.length - 1, app, report, cn, mn, appDir, processLog, null, switches);

LOGGER.info("Running...");
List<String> cmd = getRunCommand(app.buildAndRunCmds.cmds[app.buildAndRunCmds.cmds.length - 1]);
if (UsedVersion.getVersion(inContainer).compareTo(Version.create(24, 2, 0)) >= 0) {
// Mandrel 24.2 needs the desired language set at runtime
cmd.add(EXTRA_TZONES_OPTS);
}
process = runCommand(cmd, appDir, processLog, app);
assertNotNull(process, "The test application failed to run. Check " + getLogsDir(cn, mn) + File.separator + processLog.getName());
process.waitFor(5, TimeUnit.SECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.io.File;

import static org.graalvm.tests.integration.AppReproducersTest.BASE_DIR;
import static org.graalvm.tests.integration.AppReproducersTest.LOCALEINCLUDES_TOKEN_1;
import static org.graalvm.tests.integration.AppReproducersTest.LOCALEINCLUDES_TOKEN_2;
import static org.graalvm.tests.integration.JFRTest.JFR_FLIGHT_RECORDER_HOTSPOT_TOKEN;
import static org.graalvm.tests.integration.JFRTest.JFR_MONITORING_SWITCH_TOKEN;
import static org.graalvm.tests.integration.PerfCheckTest.FINAL_NAME_TOKEN;
Expand Down Expand Up @@ -191,7 +193,7 @@ public enum BuildAndRunCmds {
}),
TIMEZONES(new String[][]{
new String[]{"mvn", "package"},
new String[]{"native-image", "-J-Duser.country=CA", "-J-Duser.language=fr", "-jar", "target/timezones.jar", "target/timezones"},
new String[]{"native-image", LOCALEINCLUDES_TOKEN_1, LOCALEINCLUDES_TOKEN_2, "-jar", "target/timezones.jar", "target/timezones"},
new String[]{IS_THIS_WINDOWS ? "target\\timezones.exe" : "./target/timezones"}
}),
CALENDARS(new String[][]{
Expand Down
Loading