Unverified Commit f4f33fd1 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Dump logs on failing devicelab test to recipe artifact location (#74378)

parent 12016e41
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter_devicelab/framework/framework.dart'; import 'package:flutter_devicelab/framework/framework.dart';
import 'package:flutter_devicelab/framework/host_agent.dart';
import 'package:flutter_devicelab/framework/ios.dart'; import 'package:flutter_devicelab/framework/ios.dart';
import 'package:flutter_devicelab/framework/task_result.dart'; import 'package:flutter_devicelab/framework/task_result.dart';
import 'package:flutter_devicelab/framework/utils.dart'; import 'package:flutter_devicelab/framework/utils.dart';
...@@ -292,6 +293,8 @@ Future<void> main() async { ...@@ -292,6 +293,8 @@ Future<void> main() async {
section('Run platform unit tests'); section('Run platform unit tests');
await testWithNewIOSSimulator('TestAdd2AppSim', (String deviceId) { await testWithNewIOSSimulator('TestAdd2AppSim', (String deviceId) {
simulatorDeviceId = deviceId; simulatorDeviceId = deviceId;
final String resultBundlePath = path.join(hostAgent.dumpDirectory.path, 'module_test_ios-objc-${DateTime.now().toLocal().toIso8601String()}');
return inDirectory(objectiveCHostApp, () => return inDirectory(objectiveCHostApp, () =>
exec( exec(
'xcodebuild', 'xcodebuild',
...@@ -304,6 +307,8 @@ Future<void> main() async { ...@@ -304,6 +307,8 @@ Future<void> main() async {
'Debug', 'Debug',
'-destination', '-destination',
'id=$deviceId', 'id=$deviceId',
'-resultBundlePath',
resultBundlePath,
'test', 'test',
'CODE_SIGNING_ALLOWED=NO', 'CODE_SIGNING_ALLOWED=NO',
'CODE_SIGNING_REQUIRED=NO', 'CODE_SIGNING_REQUIRED=NO',
......
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:file/file.dart';
import 'package:file/local.dart';
import 'package:meta/meta.dart';
import 'package:platform/platform.dart';
/// The current host machine running the tests.
HostAgent get hostAgent => HostAgent(platform: const LocalPlatform(), fileSystem: const LocalFileSystem());
/// Host machine running the tests.
class HostAgent {
HostAgent({@required Platform platform, @required FileSystem fileSystem})
: _platform = platform,
_fileSystem = fileSystem;
final Platform _platform;
final FileSystem _fileSystem;
/// Creates a directory to dump file artifacts.
Directory get dumpDirectory {
if (_dumpDirectory == null) {
// Set in LUCI recipe.
final String directoryPath = _platform.environment['FLUTTER_LOGS_DIR'];
if (directoryPath == null) {
_dumpDirectory = _fileSystem.systemTempDirectory.createTempSync('flutter_test_logs.');
print('Created tmp dump directory ${_dumpDirectory.path}');
} else {
_dumpDirectory = _fileSystem.directory(directoryPath)..createSync(recursive: true);
print('Found FLUTTER_LOGS_DIR dump directory ${_dumpDirectory.path}');
}
}
return _dumpDirectory;
}
static Directory _dumpDirectory;
@visibleForTesting
void resetDumpDirectory() {
_dumpDirectory = null;
}
}
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_devicelab/framework/host_agent.dart';
import 'package:platform/platform.dart';
import 'common.dart';
void main() {
FileSystem fs;
setUp(() {
fs = MemoryFileSystem();
hostAgent.resetDumpDirectory();
});
tearDown(() {
hostAgent.resetDumpDirectory();
});
group('dump directory', () {
test('set by environment', () async {
final Directory environmentDir = fs.directory(fs.path.join('home', 'logs'));
final FakePlatform fakePlatform = FakePlatform(
environment: <String, String>{'FLUTTER_LOGS_DIR': environmentDir.path},
operatingSystem: 'windows',
);
final HostAgent agent = HostAgent(platform: fakePlatform, fileSystem: fs);
expect(agent.dumpDirectory.existsSync(), isTrue);
expect(agent.dumpDirectory.path, environmentDir.path);
});
test('not set by environment', () async {
final FakePlatform fakePlatform = FakePlatform(environment: <String, String>{}, operatingSystem: 'windows');
final HostAgent agent = HostAgent(platform: fakePlatform, fileSystem: fs);
expect(agent.dumpDirectory.existsSync(), isTrue);
});
test('is the same between host agent instances', () async {
final FakePlatform fakePlatform = FakePlatform(environment: <String, String>{}, operatingSystem: 'windows');
final HostAgent agent1 = HostAgent(platform: fakePlatform, fileSystem: fs);
final HostAgent agent2 = HostAgent(platform: fakePlatform, fileSystem: fs);
expect(agent1.dumpDirectory.path, agent2.dumpDirectory.path);
});
});
}
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