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 {
String get flutterBinariesLinuxRepairCommands =>
'On Debian/Ubuntu/Mint: sudo apt-get install lib32stdc++6\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
String get noIdeStatusInfo => 'No supported IDEs installed';
......
......@@ -50,7 +50,7 @@ class _DefaultDoctorValidatorsProvider implements DoctorValidatorsProvider {
List<DoctorValidator> get validators {
if (_validators == null) {
_validators = <DoctorValidator>[];
_validators.add(_FlutterValidator());
_validators.add(FlutterValidator());
if (androidWorkflow.appliesToHostPlatform)
_validators.add(GroupedValidator(<DoctorValidator>[androidValidator, androidLicenseValidator]));
......@@ -438,8 +438,8 @@ class ValidationMessage {
String toString() => message;
}
class _FlutterValidator extends DoctorValidator {
_FlutterValidator() : super('Flutter');
class FlutterValidator extends DoctorValidator {
FlutterValidator() : super('Flutter');
@override
Future<ValidationResult> validate() async {
......
......@@ -4,10 +4,17 @@
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/io.dart';
import 'package:flutter_tools/src/base/platform.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/globals.dart';
import 'package:flutter_tools/src/proxy_validator.dart';
import 'package:flutter_tools/src/vscode/vscode.dart';
import 'package:flutter_tools/src/vscode/vscode_validator.dart';
......@@ -21,6 +28,12 @@ final Map<Type, Generator> noColorTerminalOverride = <Type, Generator>{
};
void main() {
MockProcessManager mockProcessManager;
setUp(() {
mockProcessManager = MockProcessManager();
});
group('doctor', () {
testUsingContext('intellij validator', () async {
const String installPath = '/path/to/intelliJ';
......@@ -290,6 +303,29 @@ void main() {
'! Doctor found issues in 4 categories.\n'
));
}, 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 {
......@@ -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
/// merging ValidationTypes (installed, missing, partial).
class FakeSmallGroupDoctor extends Doctor {
......@@ -717,3 +762,5 @@ class VsCodeValidatorTestTargets extends VsCodeValidator {
static final String validExtensions = fs.path.join('test', 'data', 'vscode', 'extensions');
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