[flutter_tools] do not error doctor on missing vs code extension (#66780)
In cases where the VSCode plugins are not located, display links to where they can be downloaded but do not surface an error.
This commit is contained in:
@@ -188,7 +188,7 @@ void main() {
|
||||
|
||||
testUsingContext('vs code validator when extension missing', () async {
|
||||
final ValidationResult result = await VsCodeValidatorTestTargets.installedWithoutExtension.validate();
|
||||
expect(result.type, ValidationType.partial);
|
||||
expect(result.type, ValidationType.installed);
|
||||
expect(result.statusInfo, 'version 1.2.3');
|
||||
expect(result.messages, hasLength(2));
|
||||
|
||||
@@ -198,8 +198,9 @@ void main() {
|
||||
|
||||
message = result.messages
|
||||
.firstWhere((ValidationMessage m) => m.message.startsWith('Flutter '));
|
||||
expect(message.message, startsWith('Flutter extension not installed'));
|
||||
expect(message.isError, isTrue);
|
||||
expect(message.message, startsWith('Flutter extension can be installed from'));
|
||||
expect(message.contextUrl, 'https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter');
|
||||
expect(message.isError, false);
|
||||
}, overrides: noColorTerminalOverride);
|
||||
|
||||
group('device validator', () {
|
||||
@@ -1221,7 +1222,7 @@ class FakeSmallGroupDoctor extends Doctor {
|
||||
|
||||
class VsCodeValidatorTestTargets extends VsCodeValidator {
|
||||
VsCodeValidatorTestTargets._(String installDirectory, String extensionDirectory, {String edition})
|
||||
: super(VsCode.fromDirectory(installDirectory, extensionDirectory, edition: edition));
|
||||
: super(VsCode.fromDirectory(installDirectory, extensionDirectory, edition: edition, fileSystem: globals.fs));
|
||||
|
||||
static VsCodeValidatorTestTargets get installedWithExtension =>
|
||||
VsCodeValidatorTestTargets._(validInstall, validExtensions);
|
||||
|
||||
@@ -2,31 +2,22 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/version.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/vscode/vscode.dart';
|
||||
|
||||
import '../../src/common.dart';
|
||||
import '../../src/context.dart';
|
||||
|
||||
void main() {
|
||||
testUsingContext('VsCode.fromDirectory does not crash when packages.json is malformed', () {
|
||||
final BufferLogger bufferLogger = globals.logger as BufferLogger;
|
||||
testWithoutContext('VsCode.fromDirectory does not crash when packages.json is malformed', () {
|
||||
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
||||
// Create invalid JSON file.
|
||||
globals.fs.file(globals.fs.path.join('', 'resources', 'app', 'package.json'))
|
||||
fileSystem.file(fileSystem.path.join('', 'resources', 'app', 'package.json'))
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('{');
|
||||
|
||||
final VsCode vsCode = VsCode.fromDirectory('', '');
|
||||
final VsCode vsCode = VsCode.fromDirectory('', '', fileSystem: fileSystem);
|
||||
|
||||
expect(vsCode.version, Version.unknown);
|
||||
expect(bufferLogger.traceText, contains('Error parsing VSCode'));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user