Fix the output of the CDN test. (#148730)

This test was outputting the "success" string multiple times, which is probably causing the harness to kill the app halfway through its cycle. I suspect this is causing some of the flakiness we've seen of this test. Instead, we should just output the string at the very end of the test, right before the app is done.
This commit is contained in:
Jackson Gardner
2024-05-21 11:07:23 -07:00
committed by GitHub
parent fe9e485bde
commit 31fc593724
5 changed files with 31 additions and 28 deletions

View File

@@ -35,14 +35,14 @@ Future<void> main() async {
output.writeln('--- TEST FAILED ---');
}
print(output);
web.window.fetch(
await web.window.fetch(
'/test-result'.toJS,
web.RequestInit(
method: 'POST',
body: '$output'.toJS,
)
);
).toDart;
print(output);
}
bool _errorMessageFormattedCorrectly(String errorMessage) {

View File

@@ -9,7 +9,7 @@ import 'dart:js_interop';
import 'package:web/web.dart' as web;
// Verify that web applications can be run in sound mode.
void main() {
void main() async {
const bool isWeak = <int?>[] is List<int>;
String output;
if (isWeak) {
@@ -17,12 +17,12 @@ void main() {
} else {
output = '--- TEST SUCCEEDED ---';
}
print(output);
web.window.fetch(
await web.window.fetch(
'/test-result'.toJS,
web.RequestInit(
method: 'POST',
body: output.toJS,
)
);
).toDart;
print(output);
}

View File

@@ -66,7 +66,7 @@ const List<StackFrame> expectedDebugStackFrames = <StackFrame>[
/// Tests that we do not crash while parsing Web stack traces.
///
/// This test is run in debug, profile, and release modes.
void main() {
void main() async {
final StringBuffer output = StringBuffer();
try {
try {
@@ -97,14 +97,14 @@ void main() {
output.writeln(unexpectedStackTrace);
output.writeln('--- TEST FAILED ---');
}
print(output);
web.window.fetch(
await web.window.fetch(
'/test-result'.toJS,
web.RequestInit(
method: 'POST',
body: '$output'.toJS,
)
);
).toDart;
print(output);
}
@noInline

View File

@@ -12,17 +12,16 @@ Future<void> main() async {
String.fromEnvironment('test.valueB');
if (combined == 'Example,AValue') {
output.write('--- TEST SUCCEEDED ---');
print('--- TEST SUCCEEDED ---');
} else {
output.write('--- TEST FAILED ---');
print('--- TEST FAILED ---');
}
web.window.fetch(
await web.window.fetch(
'/test-result'.toJS,
web.RequestInit(
method: 'POST',
body: '$output'.toJS,
)
);
).toDart;
print(output);
}

View File

@@ -6,12 +6,19 @@ import 'dart:js_interop';
import 'package:web/web.dart' as web;
// Attempt to load CanvasKit resources hosted on gstatic.
Future<void> main() async {
if (await testFetchResources()) {
print('--- TEST SUCCEEDED ---');
} else {
print('--- TEST FAILED ---');
}
}
// Attempt to load CanvasKit resources hosted on gstatic.
Future<bool> testFetchResources() async {
const String engineVersion = String.fromEnvironment('TEST_FLUTTER_ENGINE_VERSION');
if (engineVersion.isEmpty) {
print('--- TEST FAILED ---');
return;
return false;
}
try {
final web.Response response = await web.window.fetch(
@@ -20,14 +27,12 @@ Future<void> main() async {
method: 'GET',
),
).toDart;
if (response.ok) {
print('--- TEST SUCCEEDED ---');
} else {
print('--- TEST FAILED ---');
if (!response.ok) {
return false;
}
} catch (err) {
print(err);
print('--- TEST FAILED ---');
return false;
}
try {
final web.Response response = await web.window.fetch(
@@ -36,13 +41,12 @@ Future<void> main() async {
method: 'GET',
)
).toDart;
if (response.ok) {
print('--- TEST SUCCEEDED ---');
} else {
print('--- TEST FAILED ---');
if (!response.ok) {
return false;
}
} catch (err) {
print(err);
print('--- TEST FAILED ---');
return false;
}
return true;
}