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 { ...@@ -380,7 +380,11 @@ class AndroidSdk {
/// was marked as obsolete in 3.6. /// was marked as obsolete in 3.6.
String get sdkManagerPath { String get sdkManagerPath {
final File cmdlineTool = globals.fs.file( 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()) { if (cmdlineTool.existsSync()) {
return cmdlineTool.path; return cmdlineTool.path;
......
...@@ -8,6 +8,7 @@ import 'package:flutter_tools/src/base/file_system.dart'; ...@@ -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/base/io.dart' show ProcessResult;
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
import 'package:platform/platform.dart';
import 'package:process/process.dart'; import 'package:process/process.dart';
import '../../src/common.dart'; import '../../src/common.dart';
...@@ -59,7 +60,7 @@ void main() { ...@@ -59,7 +60,7 @@ void main() {
ProcessManager: () => FakeProcessManager.any(), ProcessManager: () => FakeProcessManager.any(),
}); });
testUsingContext('returns sdkmanager path under cmdline tools', () { testUsingContext('returns sdkmanager path under cmdline tools on Linux/macOS', () {
sdkDir = MockAndroidSdk.createSdkDirectory(); sdkDir = MockAndroidSdk.createSdkDirectory();
globals.config.setValue('android-sdk', sdkDir.path); globals.config.setValue('android-sdk', sdkDir.path);
...@@ -72,6 +73,24 @@ void main() { ...@@ -72,6 +73,24 @@ void main() {
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FileSystem: () => fs, FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(), 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', () { 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