Unverified Commit 7d5f3928 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Cache location of Java binary in devicelab tests (#80172)

parent 23404dfa
...@@ -501,16 +501,22 @@ Future<int> dart(List<String> args) => exec(dartBin, <String>['--disable-dart-de ...@@ -501,16 +501,22 @@ Future<int> dart(List<String> args) => exec(dartBin, <String>['--disable-dart-de
/// Returns a future that completes with a path suitable for JAVA_HOME /// Returns a future that completes with a path suitable for JAVA_HOME
/// or with null, if Java cannot be found. /// or with null, if Java cannot be found.
Future<String> findJavaHome() async { Future<String> findJavaHome() async {
final Iterable<String> hits = grep( if (_javaHome == null) {
'Java binary at: ', final Iterable<String> hits = grep(
from: await evalFlutter('doctor', options: <String>['-v']), 'Java binary at: ',
); from: await evalFlutter('doctor', options: <String>['-v']),
if (hits.isEmpty) );
return null; if (hits.isEmpty)
final String javaBinary = hits.first.split(': ').last; return null;
// javaBinary == /some/path/to/java/home/bin/java final String javaBinary = hits.first
return path.dirname(path.dirname(javaBinary)); .split(': ')
.last;
// javaBinary == /some/path/to/java/home/bin/java
_javaHome = path.dirname(path.dirname(javaBinary));
}
return _javaHome;
} }
String _javaHome;
Future<T> inDirectory<T>(dynamic directory, Future<T> Function() action) async { Future<T> inDirectory<T>(dynamic directory, Future<T> Function() action) async {
final String previousCwd = cwd; final String previousCwd = cwd;
......
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