1// Copyright 2014 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import 'package:file/file.dart';
6import 'package:file/local.dart';
7import 'package:meta/meta.dart';
8import 'package:platform/platform.dart';
9
10/// The current host machine running the tests.
11HostAgent get hostAgent =>
12 HostAgent(platform: const LocalPlatform(), fileSystem: const LocalFileSystem());
13
14/// Host machine running the tests.
15class HostAgent {
16 HostAgent({required Platform platform, required FileSystem fileSystem})
17 : _platform = platform,
18 _fileSystem = fileSystem;
19
20 final Platform _platform;
21 final FileSystem _fileSystem;
22
23 /// Creates a directory to dump file artifacts.
24 Directory? get dumpDirectory {
25 if (_dumpDirectory == null) {
26 // Set in LUCI recipe.
27 final String? directoryPath = _platform.environment['FLUTTER_LOGS_DIR'];
28 if (directoryPath != null) {
29 _dumpDirectory = _fileSystem.directory(directoryPath)..createSync(recursive: true);
30 print('Found FLUTTER_LOGS_DIR dump directory ${_dumpDirectory?.path}');
31 }
32 }
33 return _dumpDirectory;
34 }
35
36 static Directory? _dumpDirectory;
37
38 @visibleForTesting
39 void resetDumpDirectory() {
40 _dumpDirectory = null;
41 }
42}
43