From 6957eabe2cd145aeb5f16a025f25b516ac012845 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 2 May 2017 10:32:00 -0700 Subject: [PATCH] tweak the doctor check for host compatibility (#9720) --- packages/flutter_tools/lib/src/doctor.dart | 42 ++++++++-------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/packages/flutter_tools/lib/src/doctor.dart b/packages/flutter_tools/lib/src/doctor.dart index ba28a7be883..f02ba25c74d 100644 --- a/packages/flutter_tools/lib/src/doctor.dart +++ b/packages/flutter_tools/lib/src/doctor.dart @@ -44,7 +44,6 @@ class Doctor { if (_validators == null) { _validators = []; _validators.add(new _FlutterValidator()); - _validators.add(new _HostExecutableValidator()); if (_androidWorkflow.appliesToHostPlatform) _validators.add(_androidWorkflow); @@ -213,39 +212,26 @@ class _FlutterValidator extends DoctorValidator { )); messages.add(new ValidationMessage('Engine revision ${version.engineRevisionShort}')); messages.add(new ValidationMessage('Tools Dart version ${version.dartSdkVersion}')); + final String genSnapshotPath = + artifacts.getArtifactPath(Artifact.genSnapshot); + + // Check that the binaries we downloaded for this platform actually run on it. + if (!_genSnapshotRuns(genSnapshotPath)) { + messages.add(new ValidationMessage.error('Downloaded executables cannot execute ' + 'on host (see https://github.com/flutter/flutter/issues/6207 for more information)')); + } return new ValidationResult(valid, messages, statusInfo: 'on ${os.name}, channel ${version.channel}'); } } -class _HostExecutableValidator extends DoctorValidator { - _HostExecutableValidator() : super('Host Executable Compatibility'); - - bool _genSnapshotRuns(String genSnapshotPath) { - final int kExpectedExitCode = 255; - try { - return processManager.runSync([genSnapshotPath]).exitCode == kExpectedExitCode; - } catch (error) { - return false; - } - } - - @override - Future validate() async { - final String genSnapshotPath = - artifacts.getArtifactPath(Artifact.genSnapshot); - final List messages = []; - final bool hostExecutablesRun = _genSnapshotRuns(genSnapshotPath); - final ValidationType valid = hostExecutablesRun ? ValidationType.installed : ValidationType.missing; - - if (hostExecutablesRun) { - messages.add(new ValidationMessage('Downloaded executables execute on host')); - } else { - messages.add(new ValidationMessage.error( - 'Downloaded executables cannot execute on host. See https://github.com/flutter/flutter/issues/6207 for more information')); - } - return new ValidationResult(valid, messages); +bool _genSnapshotRuns(String genSnapshotPath) { + final int kExpectedExitCode = 255; + try { + return processManager.runSync([genSnapshotPath]).exitCode == kExpectedExitCode; + } catch (error) { + return false; } }