|
64 | 64 | end |
65 | 65 | end |
66 | 66 |
|
| 67 | + describe '#delete_unused_runtimes' do |
| 68 | + it 'skips missing needed runtimes when deleting unused runtimes' do |
| 69 | + # GIVEN: A mix of needed runtimes where one runtime is still missing |
| 70 | + needed_runtime = instance_double(RequiredRuntime) |
| 71 | + missing_runtime = instance_double(RequiredRuntime) |
| 72 | + |
| 73 | + matched_simctl_runtime = instance_double(Runtime, identifier: 'com.apple.CoreSimulator.SimRuntime.iOS-18-0') |
| 74 | + unused_simctl_runtime = instance_double(Runtime, identifier: 'com.apple.CoreSimulator.SimRuntime.iOS-17-0') |
| 75 | + installed_unused_runtime = instance_double(RuntimeWithState, runtime_identifier: 'com.apple.CoreSimulator.SimRuntime.iOS-17-0', identifier: 'runtime-17') |
| 76 | + |
| 77 | + allow(shell_helper).to receive(:simctl_runtimes).with(no_args).and_return([matched_simctl_runtime, unused_simctl_runtime]) |
| 78 | + allow(shell_helper).to receive(:installed_runtimes_with_state).with(no_args).and_return([installed_unused_runtime]) |
| 79 | + allow(shell_helper).to receive(:installed_runtimes_with_state).with(retry_count: 3, retry_delay: 60) |
| 80 | + allow(shell_helper).to receive(:simctl_delete_runtime) |
| 81 | + allow(shell_helper).to receive(:stop_core_simulator_services) |
| 82 | + allow(shell_helper).to receive(:simctl_runtimes).with(force: true) |
| 83 | + allow(shell_helper).to receive(:simctl_devices_for_runtimes).with(force: true) |
| 84 | + |
| 85 | + allow(sut).to receive(:simctl_runtime_matching_needed_runtime?).with(needed_runtime).and_return(matched_simctl_runtime) |
| 86 | + allow(sut).to receive(:simctl_runtime_matching_needed_runtime?).with(missing_runtime).and_return(nil) |
| 87 | + |
| 88 | + # WHEN: Deleting unused runtimes |
| 89 | + expect { sut.delete_unused_runtimes([needed_runtime, missing_runtime]) }.not_to raise_error |
| 90 | + |
| 91 | + # THEN: It should still delete real unused runtimes and not crash on missing matches |
| 92 | + expect(shell_helper).to have_received(:simctl_delete_runtime).with(identifier: 'runtime-17') |
| 93 | + end |
| 94 | + end |
| 95 | + |
67 | 96 | describe '#missing_runtimes' do |
68 | 97 | it 'returns runtimes that are not available' do |
69 | 98 | # GIVEN: Needed runtimes with one missing |
|
0 commit comments