Skip to content

Commit 37dafda

Browse files
ludochgae-java-bot
authored andcommitted
Fix App Engine tests for Windows.
This change addresses several issues that prevented App Engine tests from passing on Windows: - **Maven Wrapper:** The Maven wrapper executable `mvnw` is now invoked with the `.cmd` extension when running on Windows to ensure it can be executed correctly. - **Newline Handling:** Test output reading logic has been updated to handle both `\n` and `\r\n` newline representations, which is necessary for Windows compatibility. These changes ensure that the affected tests pass on both Linux/macOS and Windows environments. PiperOrigin-RevId: 736207509 Change-Id: I7c11b010689343ccdbf9b29801e17569064bb867
1 parent 69e34d9 commit 37dafda

5 files changed

Lines changed: 23 additions & 10 deletions

File tree

e2etests/stagingtests/src/test/java/com/google/appengine/tools/admin/ApplicationTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ public class ApplicationTest {
141141
getWarPath("stage-with-appid-and-version");
142142
private static final String STAGE_WITH_STAGING_OPTIONS = getWarPath("stage-with-staging-options");
143143

144-
private static final int RANDOM_HTML_SIZE = 704;
144+
// Size is different on Windows because of the extra \r\n characters in the HTML.
145+
private static final int RANDOM_HTML_SIZE =
146+
((System.getProperty("os.name").toLowerCase().contains("windows")) ? 727 : 704);
145147
private static final String APPID = "sampleapp";
146148
private static final String MODULE_ID = "stan";
147149
private static final String APPVER = "1";

lib/tools_api/src/test/java/com/google/appengine/tools/admin/AppYamlTranslatorTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2775,8 +2775,9 @@ public void testHttpHeaders() {
27752775
+ " login: optional\n"
27762776
+ " secure: optional\n"
27772777
+ " http_headers:\n"
2778-
+ " foo: 1\n"
2779-
+ " bar: barf\n"
2778+
// Yaml library emitting headers is OS dependent so eol is different on Windows.
2779+
+ " foo: 1" + System.getProperty("line.separator")
2780+
+ " bar: barf" + System.getProperty("line.separator")
27802781
+ "- url: /\n"
27812782
+ " script: unused\n"
27822783
+ " login: optional\n"
@@ -2790,7 +2791,7 @@ public void testHttpHeaders() {
27902791
+ " login: optional\n"
27912792
+ " secure: optional\n";
27922793
assertEquals(yaml, translator.getYaml());
2793-
2794+
27942795
}
27952796

27962797
public void testBackends() {

runtime/impl/src/test/java/com/google/apphosting/runtime/ClassPathUtilsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ public void verifyJava11PropertiesAreConfigured() throws Exception {
6464
}
6565
assertThat(System.getProperty("classpath.connector-j")).isNull();
6666

67-
assertThat(cpu.getFrozenApiJar().getAbsolutePath())
68-
.isEqualTo(runtimeLocation + "/appengine-api-1.0-sdk.jar");
67+
assertThat(cpu.getFrozenApiJar().getCanonicalPath())
68+
.isEqualTo(new File(runtimeLocation + "/appengine-api-1.0-sdk.jar").getCanonicalPath());
6969
}
7070

7171
@Test

runtime/test/src/test/java/com/google/apphosting/runtime/jetty9/GzipHandlerTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,16 @@ public void testRequestGzipContent() throws Exception {
117117
Result response = completionListener.get(5, TimeUnit.SECONDS);
118118
assertThat(response.getResponse().getStatus(), equalTo(HttpStatus.OK_200));
119119
String contentReceived = received.toString();
120-
assertThat(contentReceived, containsString("\nX-Content-Encoding: gzip\n"));
121-
assertThat(contentReceived, not(containsString("\nContent-Encoding: gzip\n")));
122-
assertThat(contentReceived, containsString("\nAccept-Encoding: gzip\n"));
120+
if (!System.getProperty("os.name").toLowerCase().contains("windows")) {
121+
// Linux
122+
assertThat(contentReceived, containsString("\nX-Content-Encoding: gzip\n"));
123+
assertThat(contentReceived, not(containsString("\nContent-Encoding: gzip\n")));
124+
assertThat(contentReceived, containsString("\nAccept-Encoding: gzip\n"));
125+
} else { // Windows
126+
assertThat(contentReceived, containsString("\r\nX-Content-Encoding: gzip\r\n"));
127+
assertThat(contentReceived, not(containsString("\r\nContent-Encoding: gzip\r\n")));
128+
assertThat(contentReceived, containsString("\r\nAccept-Encoding: gzip\r\n"));
129+
}
123130

124131
// Server correctly echoed content of request.
125132
String expectedData = new String(data);

runtime/test/src/test/java/com/google/apphosting/runtime/jetty9/SpringBootTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ public static void beforeClass() throws IOException, InterruptedException {
3939
File currentDirectory = new File("").getAbsoluteFile();
4040
Process process =
4141
new ProcessBuilder(
42-
"../../mvnw",
42+
"../../mvnw"
43+
+ ((System.getProperty("os.name").toLowerCase().contains("windows"))
44+
? ".cmd" // Windows OS
45+
: ""), // Linux OS, no extension for command name.
4346
"install",
4447
"appengine:stage",
4548
"-f",

0 commit comments

Comments
 (0)