mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Ensure that the output path used by perf_tests_test matches the path used by perf_tests if the FLUTTER_TEST_OUTPUTS_DIR variable is set (#153888)
A recent change to the flutter_drone recipe is setting FLUTTER_TEST_OUTPUTS_DIR in the environment (see https://flutter.googlesource.com/recipes/+/b111cd3ef2297e66905cc48c2cfedce0cf1ba46f) If FLUTTER_TEST_OUTPUTS_DIR is set, then perf_tests will use an output path based on that variable. perf_tests_test needs to use the same logic when looking for the expected output file.
This commit is contained in:
parent
a57eb8fefc
commit
203a19e82f
@ -21,7 +21,7 @@ import '../framework/utils.dart';
|
|||||||
/// Must match flutter_driver/lib/src/common.dart.
|
/// Must match flutter_driver/lib/src/common.dart.
|
||||||
///
|
///
|
||||||
/// Redefined here to avoid taking a dependency on flutter_driver.
|
/// Redefined here to avoid taking a dependency on flutter_driver.
|
||||||
String _testOutputDirectory(String testDirectory) {
|
String testOutputDirectory(String testDirectory) {
|
||||||
return Platform.environment['FLUTTER_TEST_OUTPUTS_DIR'] ?? '$testDirectory/build';
|
return Platform.environment['FLUTTER_TEST_OUTPUTS_DIR'] ?? '$testDirectory/build';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,7 +484,7 @@ TaskFunction createsScrollSmoothnessPerfTest() {
|
|||||||
deviceId,
|
deviceId,
|
||||||
]);
|
]);
|
||||||
final Map<String, dynamic> data = json.decode(
|
final Map<String, dynamic> data = json.decode(
|
||||||
file('${_testOutputDirectory(testDirectory)}/scroll_smoothness_test.json').readAsStringSync(),
|
file('${testOutputDirectory(testDirectory)}/scroll_smoothness_test.json').readAsStringSync(),
|
||||||
) as Map<String, dynamic>;
|
) as Map<String, dynamic>;
|
||||||
|
|
||||||
final Map<String, dynamic> result = <String, dynamic>{};
|
final Map<String, dynamic> result = <String, dynamic>{};
|
||||||
@ -535,7 +535,7 @@ TaskFunction createFramePolicyIntegrationTest() {
|
|||||||
deviceId,
|
deviceId,
|
||||||
]);
|
]);
|
||||||
final Map<String, dynamic> data = json.decode(
|
final Map<String, dynamic> data = json.decode(
|
||||||
file('${_testOutputDirectory(testDirectory)}/frame_policy_event_delay.json').readAsStringSync(),
|
file('${testOutputDirectory(testDirectory)}/frame_policy_event_delay.json').readAsStringSync(),
|
||||||
) as Map<String, dynamic>;
|
) as Map<String, dynamic>;
|
||||||
final Map<String, dynamic> fullLiveData = data['fullyLive'] as Map<String, dynamic>;
|
final Map<String, dynamic> fullLiveData = data['fullyLive'] as Map<String, dynamic>;
|
||||||
final Map<String, dynamic> benchmarkLiveData = data['benchmarkLive'] as Map<String, dynamic>;
|
final Map<String, dynamic> benchmarkLiveData = data['benchmarkLive'] as Map<String, dynamic>;
|
||||||
@ -1025,7 +1025,7 @@ class StartupTest {
|
|||||||
timer.cancel();
|
timer.cancel();
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
final Map<String, dynamic> data = json.decode(
|
final Map<String, dynamic> data = json.decode(
|
||||||
file('${_testOutputDirectory(testDirectory)}/start_up_info.json').readAsStringSync(),
|
file('${testOutputDirectory(testDirectory)}/start_up_info.json').readAsStringSync(),
|
||||||
) as Map<String, dynamic>;
|
) as Map<String, dynamic>;
|
||||||
results.add(data);
|
results.add(data);
|
||||||
} else {
|
} else {
|
||||||
@ -1418,7 +1418,7 @@ class PerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Map<String, dynamic> data = json.decode(
|
final Map<String, dynamic> data = json.decode(
|
||||||
file('${_testOutputDirectory(testDirectory)}/$resultFilename.json').readAsStringSync(),
|
file('${testOutputDirectory(testDirectory)}/$resultFilename.json').readAsStringSync(),
|
||||||
) as Map<String, dynamic>;
|
) as Map<String, dynamic>;
|
||||||
|
|
||||||
if (data['frame_count'] as int < 5) {
|
if (data['frame_count'] as int < 5) {
|
||||||
@ -1451,7 +1451,7 @@ class PerfTest {
|
|||||||
data,
|
data,
|
||||||
detailFiles: <String>[
|
detailFiles: <String>[
|
||||||
if (saveTraceFile)
|
if (saveTraceFile)
|
||||||
'${_testOutputDirectory(testDirectory)}/$traceFilename.json',
|
'${testOutputDirectory(testDirectory)}/$traceFilename.json',
|
||||||
],
|
],
|
||||||
benchmarkScoreKeys: benchmarkScoreKeys ?? <String>[
|
benchmarkScoreKeys: benchmarkScoreKeys ?? <String>[
|
||||||
..._kCommonScoreKeys,
|
..._kCommonScoreKeys,
|
||||||
|
@ -16,9 +16,11 @@ void main() {
|
|||||||
late Directory testDirectory;
|
late Directory testDirectory;
|
||||||
late File testTarget;
|
late File testTarget;
|
||||||
late Device device;
|
late Device device;
|
||||||
|
late String perfTestOutputPath;
|
||||||
|
|
||||||
setUp(() async {
|
setUp(() async {
|
||||||
testDirectory = Directory.systemTemp.createTempSync('test_dir');
|
testDirectory = Directory.systemTemp.createTempSync('test_dir');
|
||||||
|
perfTestOutputPath = testOutputDirectory(testDirectory.absolute.path);
|
||||||
testTarget = File('${testDirectory.absolute.path}/test_file')..createSync();
|
testTarget = File('${testDirectory.absolute.path}/test_file')..createSync();
|
||||||
device = const FakeDevice(deviceId: 'fakeDeviceId');
|
device = const FakeDevice(deviceId: 'fakeDeviceId');
|
||||||
deviceOperatingSystem = DeviceOperatingSystem.fake;
|
deviceOperatingSystem = DeviceOperatingSystem.fake;
|
||||||
@ -64,7 +66,7 @@ void main() {
|
|||||||
};
|
};
|
||||||
const String resultFileName = 'fake_result';
|
const String resultFileName = 'fake_result';
|
||||||
void driveCallback(List<String> arguments) {
|
void driveCallback(List<String> arguments) {
|
||||||
final File resultFile = File('${testDirectory.absolute.path}/build/$resultFileName.json')..createSync(recursive: true);
|
final File resultFile = File('$perfTestOutputPath/$resultFileName.json')..createSync(recursive: true);
|
||||||
resultFile.writeAsStringSync(json.encode(fakeData));
|
resultFile.writeAsStringSync(json.encode(fakeData));
|
||||||
}
|
}
|
||||||
final PerfTest perfTest = PerfTest(testDirectory.absolute.path, testTarget.absolute.path, 'test_file', resultFilename: resultFileName, device: device, flutterDriveCallback: driveCallback);
|
final PerfTest perfTest = PerfTest(testDirectory.absolute.path, testTarget.absolute.path, 'test_file', resultFilename: resultFileName, device: device, flutterDriveCallback: driveCallback);
|
||||||
@ -117,7 +119,7 @@ void main() {
|
|||||||
};
|
};
|
||||||
const String resultFileName = 'fake_result';
|
const String resultFileName = 'fake_result';
|
||||||
void driveCallback(List<String> arguments) {
|
void driveCallback(List<String> arguments) {
|
||||||
final File resultFile = File('${testDirectory.absolute.path}/build/$resultFileName.json')..createSync(recursive: true);
|
final File resultFile = File('$perfTestOutputPath/$resultFileName.json')..createSync(recursive: true);
|
||||||
resultFile.writeAsStringSync(json.encode(fakeData));
|
resultFile.writeAsStringSync(json.encode(fakeData));
|
||||||
}
|
}
|
||||||
final PerfTest perfTest = PerfTest(testDirectory.absolute.path, testTarget.absolute.path, 'test_file', resultFilename: resultFileName, device: device, flutterDriveCallback: driveCallback);
|
final PerfTest perfTest = PerfTest(testDirectory.absolute.path, testTarget.absolute.path, 'test_file', resultFilename: resultFileName, device: device, flutterDriveCallback: driveCallback);
|
||||||
|
Loading…
Reference in New Issue
Block a user