Unverified Commit 7634a0ec authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

[flutter_tool,doctor] Fix and test gen_snapshot failure message (#27253)

parent 327e3eff
...@@ -19,7 +19,7 @@ class UserMessages { ...@@ -19,7 +19,7 @@ class UserMessages {
String get flutterBinariesLinuxRepairCommands => String get flutterBinariesLinuxRepairCommands =>
'On Debian/Ubuntu/Mint: sudo apt-get install lib32stdc++6\n' 'On Debian/Ubuntu/Mint: sudo apt-get install lib32stdc++6\n'
'On Fedora: dnf install libstdc++.i686\n' 'On Fedora: dnf install libstdc++.i686\n'
'On Arch: pacman -S lib32-libstdc++5'; 'On Arch: pacman -S lib32-libstdc++5 (you need to enable multilib: https://wiki.archlinux.org/index.php/Official_repositories#multilib)';
// Messages used in NoIdeValidator // Messages used in NoIdeValidator
String get noIdeStatusInfo => 'No supported IDEs installed'; String get noIdeStatusInfo => 'No supported IDEs installed';
......
...@@ -50,7 +50,7 @@ class _DefaultDoctorValidatorsProvider implements DoctorValidatorsProvider { ...@@ -50,7 +50,7 @@ class _DefaultDoctorValidatorsProvider implements DoctorValidatorsProvider {
List<DoctorValidator> get validators { List<DoctorValidator> get validators {
if (_validators == null) { if (_validators == null) {
_validators = <DoctorValidator>[]; _validators = <DoctorValidator>[];
_validators.add(_FlutterValidator()); _validators.add(FlutterValidator());
if (androidWorkflow.appliesToHostPlatform) if (androidWorkflow.appliesToHostPlatform)
_validators.add(GroupedValidator(<DoctorValidator>[androidValidator, androidLicenseValidator])); _validators.add(GroupedValidator(<DoctorValidator>[androidValidator, androidLicenseValidator]));
...@@ -438,8 +438,8 @@ class ValidationMessage { ...@@ -438,8 +438,8 @@ class ValidationMessage {
String toString() => message; String toString() => message;
} }
class _FlutterValidator extends DoctorValidator { class FlutterValidator extends DoctorValidator {
_FlutterValidator() : super('Flutter'); FlutterValidator() : super('Flutter');
@override @override
Future<ValidationResult> validate() async { Future<ValidationResult> validate() async {
......
...@@ -4,10 +4,17 @@ ...@@ -4,10 +4,17 @@
import 'dart:async'; import 'dart:async';
import 'package:mockito/mockito.dart';
import 'package:process/process.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/base/user_messages.dart';
import 'package:flutter_tools/src/doctor.dart'; import 'package:flutter_tools/src/doctor.dart';
import 'package:flutter_tools/src/globals.dart';
import 'package:flutter_tools/src/proxy_validator.dart'; import 'package:flutter_tools/src/proxy_validator.dart';
import 'package:flutter_tools/src/vscode/vscode.dart'; import 'package:flutter_tools/src/vscode/vscode.dart';
import 'package:flutter_tools/src/vscode/vscode_validator.dart'; import 'package:flutter_tools/src/vscode/vscode_validator.dart';
...@@ -21,6 +28,12 @@ final Map<Type, Generator> noColorTerminalOverride = <Type, Generator>{ ...@@ -21,6 +28,12 @@ final Map<Type, Generator> noColorTerminalOverride = <Type, Generator>{
}; };
void main() { void main() {
MockProcessManager mockProcessManager;
setUp(() {
mockProcessManager = MockProcessManager();
});
group('doctor', () { group('doctor', () {
testUsingContext('intellij validator', () async { testUsingContext('intellij validator', () async {
const String installPath = '/path/to/intelliJ'; const String installPath = '/path/to/intelliJ';
...@@ -290,6 +303,29 @@ void main() { ...@@ -290,6 +303,29 @@ void main() {
'! Doctor found issues in 4 categories.\n' '! Doctor found issues in 4 categories.\n'
)); ));
}, overrides: noColorTerminalOverride); }, overrides: noColorTerminalOverride);
testUsingContext('gen_snapshot does not work', () async {
when(mockProcessManager.runSync(
<String>[artifacts.getArtifactPath(Artifact.genSnapshot)],
workingDirectory: anyNamed('workingDirectory'),
environment: anyNamed('environment'),
)).thenReturn(ProcessResult(101, 1, '', ''));
expect(await FlutterValidatorDoctor().diagnose(verbose: false), isTrue);
final List<String> statusLines = testLogger.statusText.split('\n');
for (String msg in userMessages.flutterBinariesDoNotRun.split('\n')) {
expect(statusLines, contains(contains(msg)));
}
if (platform.isLinux) {
for (String msg in userMessages.flutterBinariesLinuxRepairCommands.split('\n')) {
expect(statusLines, contains(contains(msg)));
}
}
}, overrides: <Type, Generator>{
OutputPreferences: () => OutputPreferences(wrapText: false),
ProcessManager: () => mockProcessManager,
Platform: _kNoColorOutputPlatform,
});
}); });
testUsingContext('validate non-verbose output wrapping', () async { testUsingContext('validate non-verbose output wrapping', () async {
...@@ -687,6 +723,15 @@ class FakeGroupedDoctorWithStatus extends Doctor { ...@@ -687,6 +723,15 @@ class FakeGroupedDoctorWithStatus extends Doctor {
} }
} }
class FlutterValidatorDoctor extends Doctor {
List<DoctorValidator> _validators;
@override
List<DoctorValidator> get validators {
_validators ??= <DoctorValidator>[FlutterValidator()];
return _validators;
}
}
/// A doctor that takes any two validators. Used to check behavior when /// A doctor that takes any two validators. Used to check behavior when
/// merging ValidationTypes (installed, missing, partial). /// merging ValidationTypes (installed, missing, partial).
class FakeSmallGroupDoctor extends Doctor { class FakeSmallGroupDoctor extends Doctor {
...@@ -717,3 +762,5 @@ class VsCodeValidatorTestTargets extends VsCodeValidator { ...@@ -717,3 +762,5 @@ class VsCodeValidatorTestTargets extends VsCodeValidator {
static final String validExtensions = fs.path.join('test', 'data', 'vscode', 'extensions'); static final String validExtensions = fs.path.join('test', 'data', 'vscode', 'extensions');
static final String missingExtensions = fs.path.join('test', 'data', 'vscode', 'notExtensions'); static final String missingExtensions = fs.path.join('test', 'data', 'vscode', 'notExtensions');
} }
class MockProcessManager extends Mock implements ProcessManager {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment