@@ -27,6 +27,8 @@ const String _androidIntegrationTestFilter =
2727 '-Pandroid.testInstrumentationRunnerArguments.'
2828 'notAnnotation=io.flutter.plugins.DartIntegrationTest' ;
2929
30+ const String _simulatorDeviceId = '1E76A0FD-38AC-4537-A989-EA639D7D012A' ;
31+
3032final Map <String , dynamic > _kDeviceListMap = < String , dynamic > {
3133 'runtimes' : < Map <String , dynamic >> [
3234 < String , dynamic > {
@@ -137,6 +139,7 @@ void main() {
137139 String platform, {
138140 String ? destination,
139141 List <String > extraFlags = const < String > [],
142+ bool treatWarningsAsErrors = true ,
140143 }) {
141144 return ProcessCall (
142145 'xcrun' ,
@@ -152,7 +155,7 @@ void main() {
152155 'Debug' ,
153156 if (destination != null ) ...< String > ['-destination' , destination],
154157 ...extraFlags,
155- 'GCC_TREAT_WARNINGS_AS_ERRORS=YES' ,
158+ if (treatWarningsAsErrors) 'GCC_TREAT_WARNINGS_AS_ERRORS=YES' ,
156159 ],
157160 package.path);
158161 }
@@ -349,7 +352,7 @@ void main() {
349352 null ),
350353 getTargetCheckCall (pluginExampleDirectory, 'ios' ),
351354 getRunTestCall (pluginExampleDirectory, 'ios' ,
352- destination: 'id=1E76A0FD-38AC-4537-A989-EA639D7D012A ' ),
355+ destination: 'id=$ _simulatorDeviceId ' ),
353356 ]));
354357 });
355358 });
@@ -1450,6 +1453,98 @@ public class FlutterActivityTest {
14501453 getTargetCheckCall (pluginExampleDirectory, 'macos' ),
14511454 ]));
14521455 });
1456+
1457+ test ('Xcode warnings exceptions list' , () async {
1458+ final RepositoryPackage plugin = createFakePlugin ('plugin' , packagesDir,
1459+ platformSupport: < String , PlatformDetails > {
1460+ platformIOS: const PlatformDetails (PlatformSupport .inline)
1461+ });
1462+
1463+ final Directory pluginExampleDirectory = getExampleDir (plugin);
1464+
1465+ processRunner.mockProcessesForExecutable['xcrun' ] = < FakeProcessInfo > [
1466+ FakeProcessInfo (MockProcess (stdout: jsonEncode (_kDeviceListMap)),
1467+ < String > ['simctl' , 'list' ]),
1468+ getMockXcodebuildListProcess (
1469+ < String > ['RunnerTests' , 'RunnerUITests' ]),
1470+ ];
1471+
1472+ await runCapturingPrint (runner, < String > [
1473+ 'native-test' ,
1474+ '--ios' ,
1475+ '--xcode-warnings-exceptions=plugin'
1476+ ]);
1477+
1478+ expect (
1479+ processRunner.recordedCalls,
1480+ contains (
1481+ getRunTestCall (pluginExampleDirectory, 'ios' ,
1482+ destination: 'id=$_simulatorDeviceId ' ,
1483+ treatWarningsAsErrors: false ),
1484+ ));
1485+ });
1486+
1487+ test ('Xcode warnings exceptions file' , () async {
1488+ final File configFile = packagesDir.childFile ('exceptions.yaml' );
1489+ await configFile.writeAsString ('- plugin' );
1490+ final RepositoryPackage plugin = createFakePlugin ('plugin' , packagesDir,
1491+ platformSupport: < String , PlatformDetails > {
1492+ platformIOS: const PlatformDetails (PlatformSupport .inline)
1493+ });
1494+
1495+ final Directory pluginExampleDirectory = getExampleDir (plugin);
1496+
1497+ processRunner.mockProcessesForExecutable['xcrun' ] = < FakeProcessInfo > [
1498+ FakeProcessInfo (MockProcess (stdout: jsonEncode (_kDeviceListMap)),
1499+ < String > ['simctl' , 'list' ]),
1500+ getMockXcodebuildListProcess (
1501+ < String > ['RunnerTests' , 'RunnerUITests' ]),
1502+ ];
1503+
1504+ await runCapturingPrint (runner, < String > [
1505+ 'native-test' ,
1506+ '--ios' ,
1507+ '--xcode-warnings-exceptions=${configFile .path }'
1508+ ]);
1509+
1510+ expect (
1511+ processRunner.recordedCalls,
1512+ contains (
1513+ getRunTestCall (pluginExampleDirectory, 'ios' ,
1514+ destination: 'id=$_simulatorDeviceId ' ,
1515+ treatWarningsAsErrors: false ),
1516+ ));
1517+ });
1518+
1519+ test ('treat warnings as errors if plugin not on exceptions list' ,
1520+ () async {
1521+ final RepositoryPackage plugin = createFakePlugin ('plugin' , packagesDir,
1522+ platformSupport: < String , PlatformDetails > {
1523+ platformIOS: const PlatformDetails (PlatformSupport .inline)
1524+ });
1525+
1526+ final Directory pluginExampleDirectory = getExampleDir (plugin);
1527+
1528+ processRunner.mockProcessesForExecutable['xcrun' ] = < FakeProcessInfo > [
1529+ FakeProcessInfo (MockProcess (stdout: jsonEncode (_kDeviceListMap)),
1530+ < String > ['simctl' , 'list' ]),
1531+ getMockXcodebuildListProcess (
1532+ < String > ['RunnerTests' , 'RunnerUITests' ]),
1533+ ];
1534+
1535+ await runCapturingPrint (runner, < String > [
1536+ 'native-test' ,
1537+ '--ios' ,
1538+ '--xcode-warnings-exceptions=foo,bar'
1539+ ]);
1540+
1541+ expect (
1542+ processRunner.recordedCalls,
1543+ contains (
1544+ getRunTestCall (pluginExampleDirectory, 'ios' ,
1545+ destination: 'id=$_simulatorDeviceId ' ),
1546+ ));
1547+ });
14531548 });
14541549
14551550 group ('multiplatform' , () {
0 commit comments