Unverified Commit 98e43bc6 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] ensure the tool can find SDK manager on windows (#54133)

parent 727552e5
......@@ -380,7 +380,11 @@ class AndroidSdk {
/// was marked as obsolete in 3.6.
String get sdkManagerPath {
final File cmdlineTool = globals.fs.file(
globals.fs.path.join(directory, 'cmdline-tools', 'latest', 'bin', 'sdkmanager')
globals.fs.path.join(directory, 'cmdline-tools', 'latest', 'bin',
globals.platform.isWindows
? 'sdkmanager.bat'
: 'sdkmanager'
),
);
if (cmdlineTool.existsSync()) {
return cmdlineTool.path;
......
......@@ -8,6 +8,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart' show ProcessResult;
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart';
import 'package:platform/platform.dart';
import 'package:process/process.dart';
import '../../src/common.dart';
......@@ -59,7 +60,7 @@ void main() {
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('returns sdkmanager path under cmdline tools', () {
testUsingContext('returns sdkmanager path under cmdline tools on Linux/macOS', () {
sdkDir = MockAndroidSdk.createSdkDirectory();
globals.config.setValue('android-sdk', sdkDir.path);
......@@ -72,6 +73,24 @@ void main() {
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
Platform: () => FakePlatform(operatingSystem: 'linux'),
});
testUsingContext('returns sdkmanager.bat path under cmdline tools for windows', () {
sdkDir = MockAndroidSdk.createSdkDirectory();
globals.config.setValue('android-sdk', sdkDir.path);
final AndroidSdk sdk = AndroidSdk.locateAndroidSdk();
globals.fs.file(
globals.fs.path.join(sdk.directory, 'cmdline-tools', 'latest', 'bin', 'sdkmanager.bat')
).createSync(recursive: true);
expect(sdk.sdkManagerPath,
globals.fs.path.join(sdk.directory, 'cmdline-tools', 'latest', 'bin', 'sdkmanager.bat'));
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
Platform: () => FakePlatform(operatingSystem: 'windows'),
});
testUsingContext('returns sdkmanager path under tools if cmdline doesnt exist', () {
......
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