Unverified Commit 50190d28 authored by Keerti Parthasarathy's avatar Keerti Parthasarathy Committed by GitHub

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
parent c640b191
...@@ -293,6 +293,7 @@ class _FlutterPlatform extends PlatformPlugin { ...@@ -293,6 +293,7 @@ class _FlutterPlatform extends PlatformPlugin {
startPaused: startPaused, startPaused: startPaused,
bundlePath: _getBundlePath(finalizers, ourTestCount), bundlePath: _getBundlePath(finalizers, ourTestCount),
observatoryPort: explicitObservatoryPort, observatoryPort: explicitObservatoryPort,
serverPort: server.port,
); );
subprocessActive = true; subprocessActive = true;
finalizers.add(() async { finalizers.add(() async {
...@@ -511,7 +512,7 @@ class _FlutterPlatform extends PlatformPlugin { ...@@ -511,7 +512,7 @@ class _FlutterPlatform extends PlatformPlugin {
listenerFile.createSync(); listenerFile.createSync();
listenerFile.writeAsStringSync(_generateTestMain( listenerFile.writeAsStringSync(_generateTestMain(
testUrl: fs.path.toUri(fs.path.absolute(testPath)).toString(), testUrl: fs.path.toUri(fs.path.absolute(testPath)).toString(),
encodedWebsocketUrl: Uri.encodeComponent(_getWebSocketUrl(server)) encodedWebsocketUrl: Uri.encodeComponent(_getWebSocketUrl()),
)); ));
return listenerFile.path; return listenerFile.path;
} }
...@@ -550,10 +551,10 @@ class _FlutterPlatform extends PlatformPlugin { ...@@ -550,10 +551,10 @@ class _FlutterPlatform extends PlatformPlugin {
return tempBundleDirectory.path; return tempBundleDirectory.path;
} }
String _getWebSocketUrl(HttpServer server) { String _getWebSocketUrl() {
return host.type == InternetAddressType.IP_V4 return host.type == InternetAddressType.IP_V4
? 'ws://${host.address}:${server.port}' ? 'ws://${host.address}'
: 'ws://[${host.address}]:${server.port}'; : 'ws://[${host.address}]';
} }
String _generateTestMain({ String _generateTestMain({
...@@ -576,7 +577,8 @@ import '$testUrl' as test; ...@@ -576,7 +577,8 @@ import '$testUrl' as test;
void main() { void main() {
print('$_kStartTimeoutTimerMessage'); print('$_kStartTimeoutTimerMessage');
String server = Uri.decodeComponent('$encodedWebsocketUrl'); String serverPort = Platform.environment['SERVER_PORT'];
String server = Uri.decodeComponent('$encodedWebsocketUrl:\$serverPort');
StreamChannel channel = serializeSuite(() { StreamChannel channel = serializeSuite(() {
catchIsolateErrors(); catchIsolateErrors();
return test.main; return test.main;
...@@ -621,6 +623,7 @@ void main() { ...@@ -621,6 +623,7 @@ void main() {
bool enableObservatory: false, bool enableObservatory: false,
bool startPaused: false, bool startPaused: false,
int observatoryPort, int observatoryPort,
int serverPort,
}) { }) {
assert(executable != null); // Please provide the path to the shell in the SKY_SHELL environment variable. assert(executable != null); // Please provide the path to the shell in the SKY_SHELL environment variable.
assert(!startPaused || enableObservatory); assert(!startPaused || enableObservatory);
...@@ -660,6 +663,7 @@ void main() { ...@@ -660,6 +663,7 @@ void main() {
final Map<String, String> environment = <String, String>{ final Map<String, String> environment = <String, String>{
'FLUTTER_TEST': 'true', 'FLUTTER_TEST': 'true',
'FONTCONFIG_FILE': _fontConfigFile.path, 'FONTCONFIG_FILE': _fontConfigFile.path,
'SERVER_PORT': serverPort.toString(),
}; };
return processManager.start(command, environment: environment); return processManager.start(command, environment: environment);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment