( session: SessionState, flags?: CommandFlags, )
| 35 | } |
| 36 | |
| 37 | export function listSessionSelectorConflicts( |
| 38 | session: SessionState, |
| 39 | flags?: CommandFlags, |
| 40 | ): SessionSelectorConflict[] { |
| 41 | if (!flags) return []; |
| 42 | |
| 43 | const mismatches: SessionSelectorConflict[] = []; |
| 44 | const device = session.device; |
| 45 | |
| 46 | const normalizedPlatform = flags.platform; |
| 47 | if (normalizedPlatform && !matchesPlatformSelector(device, normalizedPlatform)) { |
| 48 | mismatches.push({ key: 'platform', value: flags.platform! }); |
| 49 | } |
| 50 | if (flags.target && flags.target !== (device.target ?? 'mobile')) { |
| 51 | mismatches.push({ key: 'target', value: flags.target }); |
| 52 | } |
| 53 | |
| 54 | if (flags.udid && (!isIosFamily(device) || flags.udid !== device.id)) { |
| 55 | mismatches.push({ key: 'udid', value: flags.udid }); |
| 56 | } |
| 57 | |
| 58 | if (flags.serial && (device.platform !== 'android' || flags.serial !== device.id)) { |
| 59 | mismatches.push({ key: 'serial', value: flags.serial }); |
| 60 | } |
| 61 | |
| 62 | if (flags.device && flags.device.trim().toLowerCase() !== device.name.trim().toLowerCase()) { |
| 63 | mismatches.push({ key: 'device', value: flags.device }); |
| 64 | } |
| 65 | |
| 66 | if (flags.iosSimulatorDeviceSet) { |
| 67 | const requestedSetPath = flags.iosSimulatorDeviceSet.trim(); |
| 68 | const sessionSetPath = device.simulatorSetPath?.trim(); |
| 69 | if ( |
| 70 | !isIosFamily(device) || |
| 71 | device.kind !== 'simulator' || |
| 72 | requestedSetPath !== sessionSetPath |
| 73 | ) { |
| 74 | mismatches.push({ key: 'iosSimulatorDeviceSet', value: flags.iosSimulatorDeviceSet }); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | if (flags.androidDeviceAllowlist) { |
| 79 | const allowlist = parseSerialAllowlist(flags.androidDeviceAllowlist); |
| 80 | if (device.platform !== 'android' || !allowlist.has(device.id)) { |
| 81 | mismatches.push({ key: 'androidDeviceAllowlist', value: flags.androidDeviceAllowlist }); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | return mismatches; |
| 86 | } |
| 87 | |
| 88 | export function formatSessionSelectorConflict(conflict: SessionSelectorConflict): string { |
| 89 | return `${flagNameForConflictKey(conflict.key)}=${conflict.value}`; |
no test coverage detected