Unverified Commit 46a742f0 authored by Andrew Kolos's avatar Andrew Kolos Committed by GitHub

add test for setting JAVA_HOME and PATH when invoking `sdkmanager --licenses` (#127344)

#126086 inadvertently fixed https://github.com/flutter/flutter/issues/124776

This follow-up PR gets the fix under test.
parent 6e1caadc
...@@ -6,6 +6,7 @@ import 'package:file/memory.dart'; ...@@ -6,6 +6,7 @@ import 'package:file/memory.dart';
import 'package:flutter_tools/src/android/android_sdk.dart'; import 'package:flutter_tools/src/android/android_sdk.dart';
import 'package:flutter_tools/src/android/android_studio.dart'; import 'package:flutter_tools/src/android/android_studio.dart';
import 'package:flutter_tools/src/android/android_workflow.dart'; import 'package:flutter_tools/src/android/android_workflow.dart';
import 'package:flutter_tools/src/android/java.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
...@@ -209,6 +210,35 @@ All SDK package licenses accepted. ...@@ -209,6 +210,35 @@ All SDK package licenses accepted.
expect(result, LicensesAccepted.all); expect(result, LicensesAccepted.all);
}); });
testWithoutContext('licensesAccepted sets environment for finding java', () async {
final Java java = FakeJava();
sdk.sdkManagerPath = '/foo/bar/sdkmanager';
processManager.addCommand(
FakeCommand(
command: <String>[sdk.sdkManagerPath!, '--licenses'],
stdout: 'All SDK package licenses accepted.',
environment: <String, String>{
'JAVA_HOME': java.javaHome!,
'PATH': fileSystem.path.join(java.javaHome!, 'bin'),
}
)
);
final AndroidLicenseValidator licenseValidator = AndroidLicenseValidator(
java: java,
androidSdk: sdk,
fileSystem: fileSystem,
processManager: processManager,
platform: FakePlatform(environment: <String, String>{'HOME': '/home/me'}),
stdio: stdio,
logger: BufferLogger.test(),
userMessages: UserMessages(),
androidStudio: FakeAndroidStudio(),
);
final LicensesAccepted licenseStatus = await licenseValidator.licensesAccepted;
expect(licenseStatus, LicensesAccepted.all);
});
testWithoutContext('licensesAccepted works for some licenses accepted', () async { testWithoutContext('licensesAccepted works for some licenses accepted', () async {
sdk.sdkManagerPath = '/foo/bar/sdkmanager'; sdk.sdkManagerPath = '/foo/bar/sdkmanager';
const String output = ''' const String output = '''
......
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