diff --git a/dev/devicelab/bin/tasks/plugin_lint_mac.dart b/dev/devicelab/bin/tasks/plugin_lint_mac.dart index 79015aa39245..f4a8f0faa857 100644 --- a/dev/devicelab/bin/tasks/plugin_lint_mac.dart +++ b/dev/devicelab/bin/tasks/plugin_lint_mac.dart @@ -46,12 +46,9 @@ Future main() async { ); final String macosintegrationTestPodspec = path.join(integrationTestPackage, 'integration_test_macos', 'macos', 'integration_test_macos.podspec'); - await exec( - 'pod', + await _tryMacOSLint( + macosintegrationTestPodspec, [ - 'lib', - 'lint', - macosintegrationTestPodspec, '--verbose', // TODO(cyanglaz): remove allow-warnings when https://github.com/flutter/flutter/issues/125812 is fixed. // https://github.com/flutter/flutter/issues/125812 @@ -164,12 +161,9 @@ Future main() async { final String macOSPodspecPath = path.join(swiftPluginPath, 'macos', '$swiftPluginName.podspec'); await inDirectory(tempDir, () async { - await exec( - 'pod', + await _tryMacOSLint( + macOSPodspecPath, [ - 'lib', - 'lint', - macOSPodspecPath, '--allow-warnings', '--verbose', ], @@ -179,12 +173,9 @@ Future main() async { section('Lint Swift macOS podspec plugin as library'); await inDirectory(tempDir, () async { - await exec( - 'pod', + await _tryMacOSLint( + macOSPodspecPath, [ - 'lib', - 'lint', - macOSPodspecPath, '--allow-warnings', '--use-libraries', '--verbose', @@ -533,3 +524,32 @@ void _validateMacOSPodfile(String appPath) { 'macos', )); } + +Future _tryMacOSLint( + String podspecPath, + List extraArguments, +) async { + final StringBuffer lintStdout = StringBuffer(); + try { + await eval( + 'pod', + [ + 'lib', + 'lint', + podspecPath, + ...extraArguments, + ], + stdout: lintStdout, + ); + } on BuildFailedError { + // Temporarily ignore errors due to DT_TOOLCHAIN_DIR if it's the only error. + // This error was introduced with Xcode 15. Fix was made in Cocoapods, but + // is not in an official release yet. + // TODO(vashworth): Stop ignoring when https://github.com/flutter/flutter/issues/133584 is complete. + final String lintResult = lintStdout.toString(); + if (!(lintResult.contains('error: DT_TOOLCHAIN_DIR cannot be used to evaluate') && + lintResult.contains('did not pass validation, due to 1 error'))) { + rethrow; + } + } +} diff --git a/dev/devicelab/lib/framework/utils.dart b/dev/devicelab/lib/framework/utils.dart index 8b97890ac2ca..40b5820c21ea 100644 --- a/dev/devicelab/lib/framework/utils.dart +++ b/dev/devicelab/lib/framework/utils.dart @@ -430,11 +430,12 @@ Future eval( Map? environment, bool canFail = false, // as in, whether failures are ok. False means that they are fatal. String? workingDirectory, + StringBuffer? stdout, // if not null, the stdout will be written here StringBuffer? stderr, // if not null, the stderr will be written here bool printStdout = true, bool printStderr = true, }) async { - final StringBuffer output = StringBuffer(); + final StringBuffer output = stdout ?? StringBuffer(); await _execute( executable, arguments,