Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test bundling on physical iOS devices #1303

Merged
merged 11 commits into from
May 23, 2023
3 changes: 0 additions & 3 deletions packages/patrol/ios/Classes/PatrolIntegrationTestRunner.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
@import Foundation;
@import ObjectiveC.runtime;

// This file is a one giant macro to make the setup as easy as possible for the developer.
// To edit it:
// 1. Remove the trailing backslashes: $ sed 's/\\$//' ios/Classes/PatrolIntegrationTestRunner.h
Expand Down
1 change: 0 additions & 1 deletion packages/patrol_cli/lib/src/commands/doctor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class DoctorCommand extends PatrolCommand {
void _printIosSpecifics() {
_checkIfToolInstalled('xcodebuild');
_checkIfToolInstalled('ideviceinstaller', 'brew install ideviceinstaller');
_checkIfToolInstalled('ios-deploy', 'brew install ios-deploy');
}

void _checkIfToolInstalled(String tool, [String? hint]) {
Expand Down
84 changes: 0 additions & 84 deletions packages/patrol_cli/lib/src/ios/ios_deploy.dart

This file was deleted.

21 changes: 8 additions & 13 deletions packages/patrol_cli/lib/src/ios/ios_test_backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import 'package:patrol_cli/src/base/logger.dart';
import 'package:patrol_cli/src/base/process.dart';
import 'package:patrol_cli/src/crossplatform/app_options.dart';
import 'package:patrol_cli/src/devices.dart';
import 'package:patrol_cli/src/ios/ios_deploy.dart';
import 'package:process/process.dart';

enum BuildMode {
Expand Down Expand Up @@ -48,12 +47,10 @@ class IOSTestBackend {
IOSTestBackend({
required ProcessManager processManager,
required FileSystem fs,
required IOSDeploy iosDeploy,
required DisposeScope parentDisposeScope,
required Logger logger,
}) : _processManager = processManager,
_fs = fs,
_iosDeploy = iosDeploy,
_disposeScope = DisposeScope(),
_logger = logger {
_disposeScope.disposedBy(parentDisposeScope);
Expand All @@ -63,7 +60,6 @@ class IOSTestBackend {

final ProcessManager _processManager;
final FileSystem _fs;
final IOSDeploy _iosDeploy;
final DisposeScope _disposeScope;
final Logger _logger;

Expand All @@ -76,6 +72,14 @@ class IOSTestBackend {

Process process;

final isRealDevice = !options.simulator;
final isReleaseMode = options.flutter.buildMode == BuildMode.release;
if (isRealDevice && !isReleaseMode) {
throwToolExit(
'Running on physical iOS devices is possible only in release mode',
);
}

// flutter build ios --config-only

var flutterBuildKilled = false;
Expand Down Expand Up @@ -140,12 +144,6 @@ class IOSTestBackend {
final subject = '${options.description} on ${device.description}';
final task = _logger.task('Running $subject');

Process? iosDeployProcess;
Copy link
Contributor Author

@bartekpacia bartekpacia May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:

Calling XCUIApplication.launch() with the debugger attached causes really nasty crashes.

if (device.real) {
_logger.detail('Executing on physical iOS device using ios-deploy...');
iosDeployProcess = await _iosDeploy.installAndLaunch(device.id);
}

final sdkVersion = await getSdkVersion(real: device.real);
final process = await _processManager.start(
options.testWithoutBuildingInvocation(
Expand All @@ -164,9 +162,6 @@ class IOSTestBackend {
process.listenStdErr((l) => _logger.err('\t$l')).disposedBy(scope);

final exitCode = await process.exitCode;
// Tests have finished now, kill the app under test
iosDeployProcess?.stdin.writeln('kill');
iosDeployProcess?.kill(); // kill it with fire

if (exitCode == 0) {
task.complete('Completed executing $subject');
Expand Down
7 changes: 0 additions & 7 deletions packages/patrol_cli/lib/src/runner/patrol_command_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import 'package:patrol_cli/src/commands/update.dart';
import 'package:patrol_cli/src/crossplatform/flutter_tool.dart';
import 'package:patrol_cli/src/dart_defines_reader.dart';
import 'package:patrol_cli/src/devices.dart';
import 'package:patrol_cli/src/ios/ios_deploy.dart';
import 'package:patrol_cli/src/ios/ios_test_backend.dart';
import 'package:patrol_cli/src/pubspec_reader.dart';
import 'package:patrol_cli/src/test_bundler.dart';
Expand Down Expand Up @@ -106,12 +105,6 @@ class PatrolCommandRunner extends CompletionCommandRunner<int> {
final iosTestBackend = IOSTestBackend(
processManager: _processManager,
fs: _fs,
iosDeploy: IOSDeploy(
processManager: _processManager,
parentDisposeScope: _disposeScope,
fs: _fs,
logger: _logger,
),
parentDisposeScope: _disposeScope,
logger: _logger,
);
Expand Down
4 changes: 0 additions & 4 deletions packages/patrol_cli/test/ios/ios_test_backend_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:file/memory.dart';
import 'package:meta/meta.dart';
import 'package:mocktail/mocktail.dart';
import 'package:patrol_cli/src/base/logger.dart';
import 'package:patrol_cli/src/ios/ios_deploy.dart';
import 'package:patrol_cli/src/ios/ios_test_backend.dart';
import 'package:process/process.dart';
import 'package:test/test.dart';
Expand Down Expand Up @@ -56,7 +55,6 @@ void main() {
iosTestBackend = IOSTestBackend(
processManager: FakeProcessManager(),
fs: fs,
iosDeploy: FakeIOSDeploy(),
parentDisposeScope: DisposeScope(),
logger: FakeLogger(),
);
Expand Down Expand Up @@ -169,8 +167,6 @@ void main() {

class FakeProcessManager extends Fake implements ProcessManager {}

class FakeIOSDeploy extends Fake implements IOSDeploy {}

class FakeLogger extends Fake implements Logger {
@override
void detail(String? message) {}
Expand Down