Improve Windows symlink instructions (#67029)

When the developer doesn't have permission to create symlinks, we
display specific instructions, but they were only correct for recent
versions of Windows 10. This improves them by:
- Giving the correct instructions for older versions.
- For recent versions, adds a command that will deep-link into the
  settings application so that developers don't have to figure out
  where/how to enable developer mode.

Fixes https://github.com/flutter/flutter/issues/66973
This commit is contained in:
stuartmorgan
2020-10-06 08:32:54 -07:00
committed by GitHub
parent 8ee2b2f1d1
commit be6a368801
2 changed files with 63 additions and 6 deletions

View File

@@ -7,6 +7,8 @@ import 'dart:convert';
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/time.dart';
import 'package:flutter_tools/src/base/utils.dart';
import 'package:flutter_tools/src/features.dart';
@@ -1414,6 +1416,38 @@ flutter:
});
});
testWithoutContext('Symlink failures give developer mode instructions on recent versions of Windows', () async {
final Platform platform = FakePlatform(operatingSystem: 'windows');
final MockOperatingSystemUtils os = MockOperatingSystemUtils();
when(os.name).thenReturn('Microsoft Windows [Version 10.0.14972.1]');
const FileSystemException e = FileSystemException('', '', OSError('', 1314));
expect(() => handleSymlinkException(e, platform: platform, os: os),
throwsToolExit(message: 'start ms-settings:developers'));
});
testWithoutContext('Symlink failures instruct developers to run as administrator on older versions of Windows', () async {
final Platform platform = FakePlatform(operatingSystem: 'windows');
final MockOperatingSystemUtils os = MockOperatingSystemUtils();
when(os.name).thenReturn('Microsoft Windows [Version 10.0.14393]');
const FileSystemException e = FileSystemException('', '', OSError('', 1314));
expect(() => handleSymlinkException(e, platform: platform, os: os),
throwsToolExit(message: 'administrator'));
});
testWithoutContext('Symlink failures only give instructions for specific errors', () async {
final Platform platform = FakePlatform(operatingSystem: 'windows');
final MockOperatingSystemUtils os = MockOperatingSystemUtils();
when(os.name).thenReturn('Microsoft Windows [Version 10.0.14393]');
const FileSystemException e = FileSystemException('', '', OSError('', 999));
expect(() => handleSymlinkException(e, platform: platform, os: os), returnsNormally);
});
});
}
@@ -1426,3 +1460,4 @@ class MockXcodeProjectInterpreter extends Mock implements XcodeProjectInterprete
class MockWebProject extends Mock implements WebProject {}
class MockWindowsProject extends Mock implements WindowsProject {}
class MockLinuxProject extends Mock implements LinuxProject {}
class MockOperatingSystemUtils extends Mock implements OperatingSystemUtils {}