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.

pkgs/http_client_conformance_tests/lib/src/redirect_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/redirect_tests.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void testRedirect(Client client, {bool redirectAlwaysAllowed = false}) async {
2323
setUpAll(() async {
2424
httpServerChannel = await startServer();
2525
httpServerQueue = StreamQueue(httpServerChannel.stream);
26-
host = 'localhost:${await httpServerQueue.next}';
26+
host = 'localhost:${await httpServerQueue.nextAsInt}';
2727
});
2828
tearDownAll(() => httpServerChannel.sink.add(null));
2929

pkgs/http_client_conformance_tests/lib/src/request_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/request_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/request_body_streamed_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/request_body_streamed_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/request_body_streamed_tests.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void testRequestBodyStreamed(Client client,
2929
setUp(() async {
3030
httpServerChannel = await startServer();
3131
httpServerQueue = StreamQueue(httpServerChannel.stream);
32-
host = 'localhost:${await httpServerQueue.next}';
32+
host = 'localhost:${await httpServerQueue.nextAsInt}';
3333
});
3434
tearDown(() => httpServerChannel.sink.add(null));
3535

pkgs/http_client_conformance_tests/lib/src/request_body_tests.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void testRequestBody(Client client) {
4747
setUp(() async {
4848
httpServerChannel = await startServer();
4949
httpServerQueue = StreamQueue(httpServerChannel.stream);
50-
host = 'localhost:${await httpServerQueue.next}';
50+
host = 'localhost:${await httpServerQueue.nextAsInt}';
5151
});
5252
tearDown(() => httpServerChannel.sink.add(null));
5353

pkgs/http_client_conformance_tests/lib/src/request_headers_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/request_headers_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/request_headers_tests.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void testRequestHeaders(Client client) async {
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/request_methods_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/request_methods_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/request_methods_tests.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:stream_channel/stream_channel.dart';
88
import 'package:test/test.dart';
99

1010
import 'request_methods_server_vm.dart'
11-
if (dart.library.html) 'request_methods_server_web.dart';
11+
if (dart.library.js_interop) 'request_methods_server_web.dart';
1212

1313
/// Tests that the [Client] correctly sends HTTP request methods
1414
/// (e.g. GET, HEAD).
@@ -25,7 +25,7 @@ void testRequestMethods(Client client,
2525
setUpAll(() async {
2626
httpServerChannel = await startServer();
2727
httpServerQueue = StreamQueue(httpServerChannel.stream);
28-
host = 'localhost:${await httpServerQueue.next}';
28+
host = 'localhost:${await httpServerQueue.nextAsInt}';
2929
});
3030
tearDownAll(() => httpServerChannel.sink.add(null));
3131

pkgs/http_client_conformance_tests/lib/src/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/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/response_body_streamed_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/response_body_streamed_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/response_body_streamed_test.dart

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

pkgs/http_client_conformance_tests/lib/src/response_body_tests.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void testResponseBody(Client client,
2626
setUpAll(() async {
2727
httpServerChannel = await startServer();
2828
httpServerQueue = StreamQueue(httpServerChannel.stream);
29-
host = 'localhost:${await httpServerQueue.next}';
29+
host = 'localhost:${await httpServerQueue.nextAsInt}';
3030
});
3131
tearDownAll(() => httpServerChannel.sink.add(null));
3232

pkgs/http_client_conformance_tests/lib/src/response_headers_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/response_headers_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/response_headers_tests.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void testResponseHeaders(Client client) async {
2020
setUp(() async {
2121
httpServerChannel = await startServer();
2222
httpServerQueue = StreamQueue(httpServerChannel.stream);
23-
host = 'localhost:${await httpServerQueue.next}';
23+
host = 'localhost:${await httpServerQueue.nextAsInt}';
2424
});
2525

2626
test('single header', () async {

pkgs/http_client_conformance_tests/lib/src/response_status_line_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/response_status_line_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/response_status_line_tests.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void testResponseStatusLine(Client client) async {
2323
setUp(() async {
2424
httpServerChannel = await startServer();
2525
httpServerQueue = StreamQueue(httpServerChannel.stream);
26-
host = 'localhost:${await httpServerQueue.next}';
26+
host = 'localhost:${await httpServerQueue.nextAsInt}';
2727
});
2828

2929
test('complete', () async {

pkgs/http_client_conformance_tests/lib/src/server_errors_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/server_errors_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/server_errors_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void testServerErrors(Client client, {bool redirectAlwaysAllowed = false}) {
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

0 commit comments

Comments
 (0)