Skip to content

Commit

Permalink
Fix test bundling on physical iOS devices (#1303)
Browse files Browse the repository at this point in the history
* delete unnecessary imports from PatrolIntegrationTestRunner.h

* do not use ios-deploy for physical iOS devices

* accept automatic pbxproj migration automatically run by Xcode

* delete `IosDeploy` - we do not need to attach with the debugger now

* guard against building for physical iOS devices in non-release mode

* update changelog
  • Loading branch information
bartekpacia authored May 23, 2023
1 parent c2da5d8 commit dea5a9c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 112 deletions.
5 changes: 5 additions & 0 deletions packages/patrol/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Unreleased

- Fix test bundling not working on physical iOS devices (works only with `patrol
test --release`) (#1303)

## 2.0.0-dev.1

- Backport changes from `master` (#1293)
Expand Down
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;
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

0 comments on commit dea5a9c

Please sign in to comment.