Do not encode the server port in the test file (#15535)
* Do not encode the server port in the test file * revert formatting * add back ignore * add a default value to serverPort * address comments
This commit is contained in:
committed by
GitHub
parent
c640b19167
commit
50190d2810
@@ -293,6 +293,7 @@ class _FlutterPlatform extends PlatformPlugin {
|
||||
startPaused: startPaused,
|
||||
bundlePath: _getBundlePath(finalizers, ourTestCount),
|
||||
observatoryPort: explicitObservatoryPort,
|
||||
serverPort: server.port,
|
||||
);
|
||||
subprocessActive = true;
|
||||
finalizers.add(() async {
|
||||
@@ -511,7 +512,7 @@ class _FlutterPlatform extends PlatformPlugin {
|
||||
listenerFile.createSync();
|
||||
listenerFile.writeAsStringSync(_generateTestMain(
|
||||
testUrl: fs.path.toUri(fs.path.absolute(testPath)).toString(),
|
||||
encodedWebsocketUrl: Uri.encodeComponent(_getWebSocketUrl(server))
|
||||
encodedWebsocketUrl: Uri.encodeComponent(_getWebSocketUrl()),
|
||||
));
|
||||
return listenerFile.path;
|
||||
}
|
||||
@@ -550,10 +551,10 @@ class _FlutterPlatform extends PlatformPlugin {
|
||||
return tempBundleDirectory.path;
|
||||
}
|
||||
|
||||
String _getWebSocketUrl(HttpServer server) {
|
||||
String _getWebSocketUrl() {
|
||||
return host.type == InternetAddressType.IP_V4
|
||||
? 'ws://${host.address}:${server.port}'
|
||||
: 'ws://[${host.address}]:${server.port}';
|
||||
? 'ws://${host.address}'
|
||||
: 'ws://[${host.address}]';
|
||||
}
|
||||
|
||||
String _generateTestMain({
|
||||
@@ -562,7 +563,7 @@ class _FlutterPlatform extends PlatformPlugin {
|
||||
}) {
|
||||
return '''
|
||||
import 'dart:convert';
|
||||
import 'dart:io'; // ignore: dart_io_import
|
||||
import 'dart:io'; // ignore: dart_io_import
|
||||
|
||||
// We import this library first in order to trigger an import error for
|
||||
// package:test (rather than package:stream_channel) when the developer forgets
|
||||
@@ -576,7 +577,8 @@ import '$testUrl' as test;
|
||||
|
||||
void main() {
|
||||
print('$_kStartTimeoutTimerMessage');
|
||||
String server = Uri.decodeComponent('$encodedWebsocketUrl');
|
||||
String serverPort = Platform.environment['SERVER_PORT'];
|
||||
String server = Uri.decodeComponent('$encodedWebsocketUrl:\$serverPort');
|
||||
StreamChannel channel = serializeSuite(() {
|
||||
catchIsolateErrors();
|
||||
return test.main;
|
||||
@@ -621,6 +623,7 @@ void main() {
|
||||
bool enableObservatory: false,
|
||||
bool startPaused: false,
|
||||
int observatoryPort,
|
||||
int serverPort,
|
||||
}) {
|
||||
assert(executable != null); // Please provide the path to the shell in the SKY_SHELL environment variable.
|
||||
assert(!startPaused || enableObservatory);
|
||||
@@ -660,6 +663,7 @@ void main() {
|
||||
final Map<String, String> environment = <String, String>{
|
||||
'FLUTTER_TEST': 'true',
|
||||
'FONTCONFIG_FILE': _fontConfigFile.path,
|
||||
'SERVER_PORT': serverPort.toString(),
|
||||
};
|
||||
return processManager.start(command, environment: environment);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user