Skip to content

Commit

Permalink
[http_client_conformance_tests] Updates to support wasm compilation (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
kevmoo authored Dec 2, 2023
1 parent 5dd5140 commit c8536e4
Show file tree
Hide file tree
Showing 40 changed files with 84 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ import 'dart:io';

import 'package:dart_style/dart_style.dart';

const vm = '''// Generated by generate_server_wrappers.dart. Do not edit.
const _export = '''export 'server_queue_helpers.dart'
show StreamQueueOfNullableObjectExtension;''';

const _vm = '''// Generated by generate_server_wrappers.dart. Do not edit.
import 'package:stream_channel/stream_channel.dart';
import '<server_file_placeholder>';
$_export
/// Starts the redirect test HTTP server in the same process.
Future<StreamChannel<Object?>> startServer() async {
final controller = StreamChannelController<Object?>(sync: true);
Expand All @@ -24,11 +29,13 @@ Future<StreamChannel<Object?>> startServer() async {
}
''';

const web = '''// Generated by generate_server_wrappers.dart. Do not edit.
const _web = '''// Generated by generate_server_wrappers.dart. Do not edit.
import 'package:stream_channel/stream_channel.dart';
import 'package:test/test.dart';
$_export
/// Starts the redirect test HTTP server out-of-process.
Future<StreamChannel<Object?>> startServer() async => spawnHybridUri(Uri(
scheme: 'package',
Expand All @@ -41,11 +48,11 @@ void main() async {

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

final webPath = file.path.replaceAll('_server.dart', '_server_web.dart');
File(webPath).writeAsStringSync(formatter.format(web.replaceAll(
File(webPath).writeAsStringSync(formatter.format(_web.replaceAll(
'<server_file_placeholder>', file.uri.pathSegments.last)));
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void testClose(Client Function() clientFactory) {
setUpAll(() async {
httpServerChannel = await startServer();
httpServerQueue = StreamQueue(httpServerChannel.stream);
host = 'localhost:${await httpServerQueue.next}';
host = 'localhost:${await httpServerQueue.nextAsInt}';
});
tearDownAll(() => httpServerChannel.sink.add(null));

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void testCompressedResponseBody(Client client) async {
setUpAll(() async {
httpServerChannel = await startServer();
httpServerQueue = StreamQueue(httpServerChannel.stream);
host = 'localhost:${await httpServerQueue.next}';
host = 'localhost:${await httpServerQueue.nextAsInt}';
});
tearDownAll(() => httpServerChannel.sink.add(null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void testIsolate(Client Function() clientFactory,
setUpAll(() async {
httpServerChannel = await startServer();
httpServerQueue = StreamQueue(httpServerChannel.stream);
host = 'localhost:${await httpServerQueue.next}';
host = 'localhost:${await httpServerQueue.nextAsInt}';
});
tearDownAll(() => httpServerChannel.sink.add(null));

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void testMultipleClients(Client Function() clientFactory) async {
setUpAll(() async {
httpServerChannel = await startServer();
httpServerQueue = StreamQueue(httpServerChannel.stream);
host = 'localhost:${await httpServerQueue.next}';
host = 'localhost:${await httpServerQueue.nextAsInt}';
});
tearDownAll(() => httpServerChannel.sink.add(null));

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void testRedirect(Client client, {bool redirectAlwaysAllowed = false}) async {
setUpAll(() async {
httpServerChannel = await startServer();
httpServerQueue = StreamQueue(httpServerChannel.stream);
host = 'localhost:${await httpServerQueue.next}';
host = 'localhost:${await httpServerQueue.nextAsInt}';
});
tearDownAll(() => httpServerChannel.sink.add(null));

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void testRequestBodyStreamed(Client client,
setUp(() async {
httpServerChannel = await startServer();
httpServerQueue = StreamQueue(httpServerChannel.stream);
host = 'localhost:${await httpServerQueue.next}';
host = 'localhost:${await httpServerQueue.nextAsInt}';
});
tearDown(() => httpServerChannel.sink.add(null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void testRequestBody(Client client) {
setUp(() async {
httpServerChannel = await startServer();
httpServerQueue = StreamQueue(httpServerChannel.stream);
host = 'localhost:${await httpServerQueue.next}';
host = 'localhost:${await httpServerQueue.nextAsInt}';
});
tearDown(() => httpServerChannel.sink.add(null));

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void testRequestHeaders(Client client) async {
setUpAll(() async {
httpServerChannel = await startServer();
httpServerQueue = StreamQueue(httpServerChannel.stream);
host = 'localhost:${await httpServerQueue.next}';
host = 'localhost:${await httpServerQueue.nextAsInt}';
});
tearDownAll(() => httpServerChannel.sink.add(null));

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:stream_channel/stream_channel.dart';
import 'package:test/test.dart';

import 'request_methods_server_vm.dart'
if (dart.library.html) 'request_methods_server_web.dart';
if (dart.library.js_interop) 'request_methods_server_web.dart';

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

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void testResponseBodyStreamed(Client client,
setUpAll(() async {
httpServerChannel = await startServer();
httpServerQueue = StreamQueue(httpServerChannel.stream);
host = 'localhost:${await httpServerQueue.next}';
host = 'localhost:${await httpServerQueue.nextAsInt}';
});
tearDownAll(() => httpServerChannel.sink.add(null));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void testResponseBody(Client client,
setUpAll(() async {
httpServerChannel = await startServer();
httpServerQueue = StreamQueue(httpServerChannel.stream);
host = 'localhost:${await httpServerQueue.next}';
host = 'localhost:${await httpServerQueue.nextAsInt}';
});
tearDownAll(() => httpServerChannel.sink.add(null));

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void testResponseHeaders(Client client) async {
setUp(() async {
httpServerChannel = await startServer();
httpServerQueue = StreamQueue(httpServerChannel.stream);
host = 'localhost:${await httpServerQueue.next}';
host = 'localhost:${await httpServerQueue.nextAsInt}';
});

test('single header', () async {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void testResponseStatusLine(Client client) async {
setUp(() async {
httpServerChannel = await startServer();
httpServerQueue = StreamQueue(httpServerChannel.stream);
host = 'localhost:${await httpServerQueue.next}';
host = 'localhost:${await httpServerQueue.nextAsInt}';
});

test('complete', () async {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void testServerErrors(Client client, {bool redirectAlwaysAllowed = false}) {
setUpAll(() async {
httpServerChannel = await startServer();
httpServerQueue = StreamQueue(httpServerChannel.stream);
host = 'localhost:${await httpServerQueue.next}';
host = 'localhost:${await httpServerQueue.nextAsInt}';
});
tearDownAll(() => httpServerChannel.sink.add(null));

Expand Down
Loading

0 comments on commit c8536e4

Please sign in to comment.