Skip to content

Commit c8536e4

Browse files
authored
[http_client_conformance_tests] Updates to support wasm compilation (#1064)
With wasm, the hybrid logic decodes JSON numbers as double This fix adds in a helper to make sure we get `int` when desired See #1066
1 parent 5dd5140 commit c8536e4

40 files changed

+84
-19
lines changed

pkgs/http_client_conformance_tests/bin/generate_server_wrappers.dart

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ import 'dart:io';
1010

1111
import 'package:dart_style/dart_style.dart';
1212

13-
const vm = '''// Generated by generate_server_wrappers.dart. Do not edit.
13+
const _export = '''export 'server_queue_helpers.dart'
14+
show StreamQueueOfNullableObjectExtension;''';
15+
16+
const _vm = '''// Generated by generate_server_wrappers.dart. Do not edit.
1417
1518
import 'package:stream_channel/stream_channel.dart';
1619
1720
import '<server_file_placeholder>';
1821
22+
$_export
23+
1924
/// Starts the redirect test HTTP server in the same process.
2025
Future<StreamChannel<Object?>> startServer() async {
2126
final controller = StreamChannelController<Object?>(sync: true);
@@ -24,11 +29,13 @@ Future<StreamChannel<Object?>> startServer() async {
2429
}
2530
''';
2631

27-
const web = '''// Generated by generate_server_wrappers.dart. Do not edit.
32+
const _web = '''// Generated by generate_server_wrappers.dart. Do not edit.
2833
2934
import 'package:stream_channel/stream_channel.dart';
3035
import 'package:test/test.dart';
3136
37+
$_export
38+
3239
/// Starts the redirect test HTTP server out-of-process.
3340
Future<StreamChannel<Object?>> startServer() async => spawnHybridUri(Uri(
3441
scheme: 'package',
@@ -41,11 +48,11 @@ void main() async {
4148

4249
files.where((file) => file.path.endsWith('_server.dart')).forEach((file) {
4350
final vmPath = file.path.replaceAll('_server.dart', '_server_vm.dart');
44-
File(vmPath).writeAsStringSync(formatter.format(vm.replaceAll(
51+
File(vmPath).writeAsStringSync(formatter.format(_vm.replaceAll(
4552
'<server_file_placeholder>', file.uri.pathSegments.last)));
4653

4754
final webPath = file.path.replaceAll('_server.dart', '_server_web.dart');
48-
File(webPath).writeAsStringSync(formatter.format(web.replaceAll(
55+
File(webPath).writeAsStringSync(formatter.format(_web.replaceAll(
4956
'<server_file_placeholder>', file.uri.pathSegments.last)));
5057
});
5158
}

pkgs/http_client_conformance_tests/lib/src/close_tests.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void testClose(Client Function() clientFactory) {
2020
setUpAll(() async {
2121
httpServerChannel = await startServer();
2222
httpServerQueue = StreamQueue(httpServerChannel.stream);
23-
host = 'localhost:${await httpServerQueue.next}';
23+
host = 'localhost:${await httpServerQueue.nextAsInt}';
2424
});
2525
tearDownAll(() => httpServerChannel.sink.add(null));
2626

pkgs/http_client_conformance_tests/lib/src/compressed_response_body_server_vm.dart

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkgs/http_client_conformance_tests/lib/src/compressed_response_body_server_web.dart

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkgs/http_client_conformance_tests/lib/src/compressed_response_body_tests.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void testCompressedResponseBody(Client client) async {
3232
setUpAll(() async {
3333
httpServerChannel = await startServer();
3434
httpServerQueue = StreamQueue(httpServerChannel.stream);
35-
host = 'localhost:${await httpServerQueue.next}';
35+
host = 'localhost:${await httpServerQueue.nextAsInt}';
3636
});
3737
tearDownAll(() => httpServerChannel.sink.add(null));
3838

pkgs/http_client_conformance_tests/lib/src/isolate_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void testIsolate(Client Function() clientFactory,
3131
setUpAll(() async {
3232
httpServerChannel = await startServer();
3333
httpServerQueue = StreamQueue(httpServerChannel.stream);
34-
host = 'localhost:${await httpServerQueue.next}';
34+
host = 'localhost:${await httpServerQueue.nextAsInt}';
3535
});
3636
tearDownAll(() => httpServerChannel.sink.add(null));
3737

pkgs/http_client_conformance_tests/lib/src/multiple_clients_server_vm.dart

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkgs/http_client_conformance_tests/lib/src/multiple_clients_server_web.dart

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkgs/http_client_conformance_tests/lib/src/multiple_clients_tests.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void testMultipleClients(Client Function() clientFactory) async {
2121
setUpAll(() async {
2222
httpServerChannel = await startServer();
2323
httpServerQueue = StreamQueue(httpServerChannel.stream);
24-
host = 'localhost:${await httpServerQueue.next}';
24+
host = 'localhost:${await httpServerQueue.nextAsInt}';
2525
});
2626
tearDownAll(() => httpServerChannel.sink.add(null));
2727

pkgs/http_client_conformance_tests/lib/src/redirect_server_vm.dart

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)