Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -14,20 +14,13 @@ void main() {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
final TaskResult aResult = TaskResult.fromJson(<String, dynamic>{
|
||||
'success': true,
|
||||
'data': <String, dynamic>{
|
||||
'i': i,
|
||||
'j': 10 * i,
|
||||
'not_a_metric': 'something',
|
||||
},
|
||||
'data': <String, dynamic>{'i': i, 'j': 10 * i, 'not_a_metric': 'something'},
|
||||
'benchmarkScoreKeys': <String>['i', 'j'],
|
||||
});
|
||||
ab.addAResult(aResult);
|
||||
final TaskResult bResult = TaskResult.fromJson(<String, dynamic>{
|
||||
'success': true,
|
||||
'data': <String, dynamic>{
|
||||
'i': i + 1,
|
||||
'k': 10 * i + 1,
|
||||
},
|
||||
'data': <String, dynamic>{'i': i + 1, 'k': 10 * i + 1},
|
||||
'benchmarkScoreKeys': <String>['i', 'k'],
|
||||
});
|
||||
ab.addBResult(bResult);
|
||||
@@ -47,10 +40,11 @@ void main() {
|
||||
' B:\t1.00\t11.00\t21.00\t31.00\t41.00\t\n',
|
||||
);
|
||||
expect(
|
||||
ab.printSummary(),
|
||||
'Score\tAverage A (noise)\tAverage B (noise)\tSpeed-up\n'
|
||||
'i\t2.00 (70.71%)\t3.00 (47.14%)\t0.67x\t\n'
|
||||
'j\t20.00 (70.71%)\t\t\n'
|
||||
'k\t\t21.00 (67.34%)\t\n');
|
||||
ab.printSummary(),
|
||||
'Score\tAverage A (noise)\tAverage B (noise)\tSpeed-up\n'
|
||||
'i\t2.00 (70.71%)\t3.00 (47.14%)\t0.67x\t\n'
|
||||
'j\t20.00 (70.71%)\t\t\n'
|
||||
'k\t\t21.00 (67.34%)\t\n',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -31,7 +31,18 @@ void main() {
|
||||
final AndroidDevice androidDevice = device as AndroidDevice;
|
||||
expect(await androidDevice.isArm64(), isTrue);
|
||||
expectLog(<CommandArgs>[
|
||||
cmd(command: 'getprop', arguments: <String>['ro.bootimage.build.fingerprint', ';', 'getprop', 'ro.build.version.release', ';', 'getprop', 'ro.build.version.sdk']),
|
||||
cmd(
|
||||
command: 'getprop',
|
||||
arguments: <String>[
|
||||
'ro.bootimage.build.fingerprint',
|
||||
';',
|
||||
'getprop',
|
||||
'ro.build.version.release',
|
||||
';',
|
||||
'getprop',
|
||||
'ro.build.version.sdk',
|
||||
],
|
||||
),
|
||||
cmd(command: 'getprop', arguments: <String>['ro.product.cpu.abi']),
|
||||
]);
|
||||
});
|
||||
@@ -61,7 +72,18 @@ void main() {
|
||||
test('sends power event', () async {
|
||||
await device.togglePower();
|
||||
expectLog(<CommandArgs>[
|
||||
cmd(command: 'getprop', arguments: <String>['ro.bootimage.build.fingerprint', ';', 'getprop', 'ro.build.version.release', ';', 'getprop', 'ro.build.version.sdk']),
|
||||
cmd(
|
||||
command: 'getprop',
|
||||
arguments: <String>[
|
||||
'ro.bootimage.build.fingerprint',
|
||||
';',
|
||||
'getprop',
|
||||
'ro.build.version.release',
|
||||
';',
|
||||
'getprop',
|
||||
'ro.build.version.sdk',
|
||||
],
|
||||
),
|
||||
cmd(command: 'input', arguments: <String>['keyevent', '26']),
|
||||
]);
|
||||
});
|
||||
@@ -72,7 +94,18 @@ void main() {
|
||||
FakeDevice.pretendAwake();
|
||||
await device.wakeUp();
|
||||
expectLog(<CommandArgs>[
|
||||
cmd(command: 'getprop', arguments: <String>['ro.bootimage.build.fingerprint', ';', 'getprop', 'ro.build.version.release', ';', 'getprop', 'ro.build.version.sdk']),
|
||||
cmd(
|
||||
command: 'getprop',
|
||||
arguments: <String>[
|
||||
'ro.bootimage.build.fingerprint',
|
||||
';',
|
||||
'getprop',
|
||||
'ro.build.version.release',
|
||||
';',
|
||||
'getprop',
|
||||
'ro.build.version.sdk',
|
||||
],
|
||||
),
|
||||
cmd(command: 'dumpsys', arguments: <String>['power']),
|
||||
]);
|
||||
});
|
||||
@@ -81,7 +114,18 @@ void main() {
|
||||
FakeDevice.pretendAsleep();
|
||||
await device.wakeUp();
|
||||
expectLog(<CommandArgs>[
|
||||
cmd(command: 'getprop', arguments: <String>['ro.bootimage.build.fingerprint', ';', 'getprop', 'ro.build.version.release', ';', 'getprop', 'ro.build.version.sdk']),
|
||||
cmd(
|
||||
command: 'getprop',
|
||||
arguments: <String>[
|
||||
'ro.bootimage.build.fingerprint',
|
||||
';',
|
||||
'getprop',
|
||||
'ro.build.version.release',
|
||||
';',
|
||||
'getprop',
|
||||
'ro.build.version.sdk',
|
||||
],
|
||||
),
|
||||
cmd(command: 'dumpsys', arguments: <String>['power']),
|
||||
cmd(command: 'input', arguments: <String>['keyevent', '26']),
|
||||
]);
|
||||
@@ -93,7 +137,18 @@ void main() {
|
||||
FakeDevice.pretendAsleep();
|
||||
await device.sendToSleep();
|
||||
expectLog(<CommandArgs>[
|
||||
cmd(command: 'getprop', arguments: <String>['ro.bootimage.build.fingerprint', ';', 'getprop', 'ro.build.version.release', ';', 'getprop', 'ro.build.version.sdk']),
|
||||
cmd(
|
||||
command: 'getprop',
|
||||
arguments: <String>[
|
||||
'ro.bootimage.build.fingerprint',
|
||||
';',
|
||||
'getprop',
|
||||
'ro.build.version.release',
|
||||
';',
|
||||
'getprop',
|
||||
'ro.build.version.sdk',
|
||||
],
|
||||
),
|
||||
cmd(command: 'dumpsys', arguments: <String>['power']),
|
||||
]);
|
||||
});
|
||||
@@ -102,7 +157,18 @@ void main() {
|
||||
FakeDevice.pretendAwake();
|
||||
await device.sendToSleep();
|
||||
expectLog(<CommandArgs>[
|
||||
cmd(command: 'getprop', arguments: <String>['ro.bootimage.build.fingerprint', ';', 'getprop', 'ro.build.version.release', ';', 'getprop', 'ro.build.version.sdk']),
|
||||
cmd(
|
||||
command: 'getprop',
|
||||
arguments: <String>[
|
||||
'ro.bootimage.build.fingerprint',
|
||||
';',
|
||||
'getprop',
|
||||
'ro.build.version.release',
|
||||
';',
|
||||
'getprop',
|
||||
'ro.build.version.sdk',
|
||||
],
|
||||
),
|
||||
cmd(command: 'dumpsys', arguments: <String>['power']),
|
||||
cmd(command: 'input', arguments: <String>['keyevent', '26']),
|
||||
]);
|
||||
@@ -114,7 +180,18 @@ void main() {
|
||||
FakeDevice.pretendAwake();
|
||||
await device.unlock();
|
||||
expectLog(<CommandArgs>[
|
||||
cmd(command: 'getprop', arguments: <String>['ro.bootimage.build.fingerprint', ';', 'getprop', 'ro.build.version.release', ';', 'getprop', 'ro.build.version.sdk']),
|
||||
cmd(
|
||||
command: 'getprop',
|
||||
arguments: <String>[
|
||||
'ro.bootimage.build.fingerprint',
|
||||
';',
|
||||
'getprop',
|
||||
'ro.build.version.release',
|
||||
';',
|
||||
'getprop',
|
||||
'ro.build.version.sdk',
|
||||
],
|
||||
),
|
||||
cmd(command: 'dumpsys', arguments: <String>['power']),
|
||||
cmd(command: 'input', arguments: <String>['keyevent', '82']),
|
||||
]);
|
||||
@@ -136,21 +213,16 @@ void main() {
|
||||
FakeDevice.output = '1';
|
||||
await device.awaitDevice();
|
||||
expectLog(<CommandArgs>[
|
||||
cmd(command: 'adb', environment: <String, String>{
|
||||
FakeDevice.canFailKey: 'false'
|
||||
}, arguments: <String>[
|
||||
'-s',
|
||||
device.deviceId,
|
||||
'wait-for-device',
|
||||
]),
|
||||
cmd(command: 'adb', environment: <String, String>{
|
||||
FakeDevice.canFailKey: 'false',
|
||||
}, arguments: <String>[
|
||||
'-s',
|
||||
device.deviceId,
|
||||
'shell',
|
||||
'getprop sys.boot_completed',
|
||||
])
|
||||
cmd(
|
||||
command: 'adb',
|
||||
environment: <String, String>{FakeDevice.canFailKey: 'false'},
|
||||
arguments: <String>['-s', device.deviceId, 'wait-for-device'],
|
||||
),
|
||||
cmd(
|
||||
command: 'adb',
|
||||
environment: <String, String>{FakeDevice.canFailKey: 'false'},
|
||||
arguments: <String>['-s', device.deviceId, 'shell', 'getprop sys.boot_completed'],
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -158,13 +230,11 @@ void main() {
|
||||
FakeDevice.resetLog();
|
||||
await device.reboot();
|
||||
expectLog(<CommandArgs>[
|
||||
cmd(command: 'adb', environment: <String, String>{
|
||||
FakeDevice.canFailKey: 'false'
|
||||
}, arguments: <String>[
|
||||
'-s',
|
||||
device.deviceId,
|
||||
'reboot',
|
||||
]),
|
||||
cmd(
|
||||
command: 'adb',
|
||||
environment: <String, String>{FakeDevice.canFailKey: 'false'},
|
||||
arguments: <String>['-s', device.deviceId, 'reboot'],
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -172,14 +242,11 @@ void main() {
|
||||
FakeDevice.resetLog();
|
||||
await device.clearLogs();
|
||||
expectLog(<CommandArgs>[
|
||||
cmd(command: 'adb', environment: <String, String>{
|
||||
FakeDevice.canFailKey: 'true'
|
||||
}, arguments: <String>[
|
||||
'-s',
|
||||
device.deviceId,
|
||||
'logcat',
|
||||
'-c',
|
||||
]),
|
||||
cmd(
|
||||
command: 'adb',
|
||||
environment: <String, String>{FakeDevice.canFailKey: 'true'},
|
||||
arguments: <String>['-s', device.deviceId, 'logcat', '-c'],
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -187,14 +254,11 @@ void main() {
|
||||
FakeDevice.resetLog();
|
||||
await device.startLoggingToSink(IOSink(_MemoryIOSink()));
|
||||
expectLog(<CommandArgs>[
|
||||
cmd(command: 'adb', environment: <String, String>{
|
||||
FakeDevice.canFailKey: 'true'
|
||||
}, arguments: <String>[
|
||||
'-s',
|
||||
device.deviceId,
|
||||
'logcat',
|
||||
'--clear',
|
||||
]),
|
||||
cmd(
|
||||
command: 'adb',
|
||||
environment: <String, String>{FakeDevice.canFailKey: 'true'},
|
||||
arguments: <String>['-s', device.deviceId, 'logcat', '--clear'],
|
||||
),
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -210,33 +274,30 @@ CommandArgs cmd({
|
||||
List<String>? arguments,
|
||||
Map<String, String>? environment,
|
||||
}) {
|
||||
return CommandArgs(
|
||||
command: command,
|
||||
arguments: arguments,
|
||||
environment: environment,
|
||||
);
|
||||
return CommandArgs(command: command, arguments: arguments, environment: environment);
|
||||
}
|
||||
|
||||
@immutable
|
||||
class CommandArgs {
|
||||
const CommandArgs({ required this.command, this.arguments, this.environment });
|
||||
const CommandArgs({required this.command, this.arguments, this.environment});
|
||||
|
||||
final String command;
|
||||
final List<String>? arguments;
|
||||
final Map<String, String>? environment;
|
||||
|
||||
@override
|
||||
String toString() => 'CommandArgs(command: $command, arguments: $arguments, environment: $environment)';
|
||||
String toString() =>
|
||||
'CommandArgs(command: $command, arguments: $arguments, environment: $environment)';
|
||||
|
||||
@override
|
||||
bool operator==(Object other) {
|
||||
bool operator ==(Object other) {
|
||||
if (other.runtimeType != CommandArgs) {
|
||||
return false;
|
||||
}
|
||||
return other is CommandArgs
|
||||
&& other.command == command
|
||||
&& const ListEquality<String>().equals(other.arguments, arguments)
|
||||
&& const MapEquality<String, String>().equals(other.environment, environment);
|
||||
return other is CommandArgs &&
|
||||
other.command == command &&
|
||||
const ListEquality<String>().equals(other.arguments, arguments) &&
|
||||
const MapEquality<String, String>().equals(other.environment, environment);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -288,37 +349,43 @@ class FakeDevice extends AndroidDevice {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> adb(List<String> arguments,
|
||||
{Map<String, String>? environment,
|
||||
bool silent = false,
|
||||
bool canFail = false}) async {
|
||||
environment ??= <String, String>{};
|
||||
commandLog.add(CommandArgs(
|
||||
command: 'adb',
|
||||
// ignore: prefer_spread_collections
|
||||
arguments: <String>['-s', deviceId]..addAll(arguments),
|
||||
environment: environment..putIfAbsent('canFail', () => '$canFail'),
|
||||
));
|
||||
Future<String> adb(
|
||||
List<String> arguments, {
|
||||
Map<String, String>? environment,
|
||||
bool silent = false,
|
||||
bool canFail = false,
|
||||
}) async {
|
||||
environment ??= <String, String>{};
|
||||
commandLog.add(
|
||||
CommandArgs(
|
||||
command: 'adb',
|
||||
// ignore: prefer_spread_collections
|
||||
arguments: <String>['-s', deviceId]..addAll(arguments),
|
||||
environment: environment..putIfAbsent('canFail', () => '$canFail'),
|
||||
),
|
||||
);
|
||||
return output;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> shellEval(String command, List<String> arguments, { Map<String, String>? environment, bool silent = false }) async {
|
||||
commandLog.add(CommandArgs(
|
||||
command: command,
|
||||
arguments: arguments,
|
||||
environment: environment,
|
||||
));
|
||||
Future<String> shellEval(
|
||||
String command,
|
||||
List<String> arguments, {
|
||||
Map<String, String>? environment,
|
||||
bool silent = false,
|
||||
}) async {
|
||||
commandLog.add(CommandArgs(command: command, arguments: arguments, environment: environment));
|
||||
return output;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> shellExec(String command, List<String> arguments, { Map<String, String>? environment, bool silent = false }) async {
|
||||
commandLog.add(CommandArgs(
|
||||
command: command,
|
||||
arguments: arguments,
|
||||
environment: environment,
|
||||
));
|
||||
Future<void> shellExec(
|
||||
String command,
|
||||
List<String> arguments, {
|
||||
Map<String, String>? environment,
|
||||
bool silent = false,
|
||||
}) async {
|
||||
commandLog.add(CommandArgs(command: command, arguments: arguments, environment: environment));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,14 +17,16 @@ import 'common.dart';
|
||||
|
||||
void main() {
|
||||
late ProcessResult processResult;
|
||||
ProcessResult runSyncStub(String executable, List<String> args,
|
||||
{Map<String, String>? environment,
|
||||
bool includeParentEnvironment = true,
|
||||
bool runInShell = false,
|
||||
Encoding? stderrEncoding,
|
||||
Encoding? stdoutEncoding,
|
||||
String? workingDirectory}) =>
|
||||
processResult;
|
||||
ProcessResult runSyncStub(
|
||||
String executable,
|
||||
List<String> args, {
|
||||
Map<String, String>? environment,
|
||||
bool includeParentEnvironment = true,
|
||||
bool runInShell = false,
|
||||
Encoding? stderrEncoding,
|
||||
Encoding? stdoutEncoding,
|
||||
String? workingDirectory,
|
||||
}) => processResult;
|
||||
|
||||
// Expected test values.
|
||||
const String commitSha = 'a4952838bf288a81d8ea11edfd4b4cd649fa94cc';
|
||||
@@ -72,18 +74,11 @@ void main() {
|
||||
processResult = ProcessResult(1, 0, commitSha, '');
|
||||
final TaskResult result = TaskResult.fromJson(<String, dynamic>{
|
||||
'success': true,
|
||||
'data': <String, dynamic>{
|
||||
'i': 0,
|
||||
'j': 0,
|
||||
'not_a_metric': 'something',
|
||||
},
|
||||
'data': <String, dynamic>{'i': 0, 'j': 0, 'not_a_metric': 'something'},
|
||||
'benchmarkScoreKeys': <String>['i', 'j'],
|
||||
});
|
||||
|
||||
cocoon = Cocoon(
|
||||
fs: fs,
|
||||
processRunSync: runSyncStub,
|
||||
);
|
||||
cocoon = Cocoon(fs: fs, processRunSync: runSyncStub);
|
||||
|
||||
const String resultsPath = 'results.json';
|
||||
await cocoon.writeTaskResultToFile(
|
||||
@@ -94,7 +89,8 @@ void main() {
|
||||
);
|
||||
|
||||
final String resultJson = fs.file(resultsPath).readAsStringSync();
|
||||
const String expectedJson = '{'
|
||||
const String expectedJson =
|
||||
'{'
|
||||
'"CommitBranch":"master",'
|
||||
'"CommitSha":"$commitSha",'
|
||||
'"BuilderName":"builderAbc",'
|
||||
@@ -113,7 +109,10 @@ void main() {
|
||||
return Response('{}', 200);
|
||||
}
|
||||
|
||||
return Response('Expected: $uploadMetricsRequestWithSpaces\nReceived: ${request.body}', 500);
|
||||
return Response(
|
||||
'Expected: $uploadMetricsRequestWithSpaces\nReceived: ${request.body}',
|
||||
500,
|
||||
);
|
||||
});
|
||||
cocoon = Cocoon(
|
||||
fs: fs,
|
||||
@@ -124,7 +123,8 @@ void main() {
|
||||
);
|
||||
|
||||
const String resultsPath = 'results.json';
|
||||
const String updateTaskJson = '{'
|
||||
const String updateTaskJson =
|
||||
'{'
|
||||
'"CommitBranch":"master",'
|
||||
'"CommitSha":"$commitSha",'
|
||||
'"BuilderName":"builder a b c",' //ignore: missing_whitespace_between_adjacent_strings
|
||||
@@ -146,7 +146,8 @@ void main() {
|
||||
);
|
||||
|
||||
const String resultsPath = 'results.json';
|
||||
const String updateTaskJson = '{'
|
||||
const String updateTaskJson =
|
||||
'{'
|
||||
'"CommitBranch":"master",'
|
||||
'"CommitSha":"$commitSha",'
|
||||
'"BuilderName":"builderAbc",'
|
||||
@@ -178,7 +179,8 @@ void main() {
|
||||
);
|
||||
|
||||
const String resultsPath = 'results.json';
|
||||
const String updateTaskJson = '{'
|
||||
const String updateTaskJson =
|
||||
'{'
|
||||
'"CommitBranch":"master",'
|
||||
'"CommitSha":"$commitSha",'
|
||||
'"BuilderName":"builderAbc",'
|
||||
@@ -213,7 +215,8 @@ void main() {
|
||||
);
|
||||
|
||||
const String resultsPath = 'results.json';
|
||||
const String updateTaskJson = '{'
|
||||
const String updateTaskJson =
|
||||
'{'
|
||||
'"CommitBranch":"master",'
|
||||
'"CommitSha":"$commitSha",'
|
||||
'"BuilderName":"builderAbc",'
|
||||
@@ -248,7 +251,8 @@ void main() {
|
||||
);
|
||||
|
||||
const String resultsPath = 'results.json';
|
||||
const String updateTaskJson = '{'
|
||||
const String updateTaskJson =
|
||||
'{'
|
||||
'"CommitBranch":"master",'
|
||||
'"CommitSha":"$commitSha",'
|
||||
'"BuilderName":"builderAbc",'
|
||||
@@ -280,7 +284,8 @@ void main() {
|
||||
);
|
||||
|
||||
const String resultsPath = 'results.json';
|
||||
const String updateTaskJson = '{'
|
||||
const String updateTaskJson =
|
||||
'{'
|
||||
'"CommitBranch":"master",'
|
||||
'"CommitSha":"$commitSha",'
|
||||
'"BuilderName":"builderAbc",'
|
||||
@@ -288,7 +293,10 @@ void main() {
|
||||
'"ResultData":{"i":0.0,"j":0.0,"not_a_metric":"something"},'
|
||||
'"BenchmarkScoreKeys":["i","j"]}';
|
||||
fs.file(resultsPath).writeAsStringSync(updateTaskJson);
|
||||
expect(() => cocoon.sendTaskStatus(resultsPath: resultsPath), throwsA(isA<ClientException>()));
|
||||
expect(
|
||||
() => cocoon.sendTaskStatus(resultsPath: resultsPath),
|
||||
throwsA(isA<ClientException>()),
|
||||
);
|
||||
});
|
||||
|
||||
test('throws client exception on non-200 responses', () async {
|
||||
@@ -302,7 +310,8 @@ void main() {
|
||||
);
|
||||
|
||||
const String resultsPath = 'results.json';
|
||||
const String updateTaskJson = '{'
|
||||
const String updateTaskJson =
|
||||
'{'
|
||||
'"CommitBranch":"master",'
|
||||
'"CommitSha":"$commitSha",'
|
||||
'"BuilderName":"builderAbc",'
|
||||
@@ -310,7 +319,10 @@ void main() {
|
||||
'"ResultData":{"i":0.0,"j":0.0,"not_a_metric":"something"},'
|
||||
'"BenchmarkScoreKeys":["i","j"]}';
|
||||
fs.file(resultsPath).writeAsStringSync(updateTaskJson);
|
||||
expect(() => cocoon.sendTaskStatus(resultsPath: resultsPath), throwsA(isA<ClientException>()));
|
||||
expect(
|
||||
() => cocoon.sendTaskStatus(resultsPath: resultsPath),
|
||||
throwsA(isA<ClientException>()),
|
||||
);
|
||||
});
|
||||
|
||||
test('does not upload results on non-supported branches', () async {
|
||||
@@ -325,7 +337,8 @@ void main() {
|
||||
);
|
||||
|
||||
const String resultsPath = 'results.json';
|
||||
const String updateTaskJson = '{'
|
||||
const String updateTaskJson =
|
||||
'{'
|
||||
'"CommitBranch":"stable",'
|
||||
'"CommitSha":"$commitSha",'
|
||||
'"BuilderName":"builderAbc",'
|
||||
@@ -350,7 +363,8 @@ void main() {
|
||||
);
|
||||
|
||||
const String resultsPath = 'results.json';
|
||||
const String updateTaskJson = '{'
|
||||
const String updateTaskJson =
|
||||
'{'
|
||||
'"CommitBranch":"master",'
|
||||
'"CommitSha":"$commitSha",'
|
||||
'"BuilderName":"builderAbc",'
|
||||
@@ -374,19 +388,28 @@ void main() {
|
||||
});
|
||||
|
||||
test('reads token from service account file', () {
|
||||
final AuthenticatedCocoonClient client = AuthenticatedCocoonClient(serviceAccountTokenPath, filesystem: fs);
|
||||
final AuthenticatedCocoonClient client = AuthenticatedCocoonClient(
|
||||
serviceAccountTokenPath,
|
||||
filesystem: fs,
|
||||
);
|
||||
expect(client.serviceAccountToken, serviceAccountToken);
|
||||
});
|
||||
|
||||
test('reads token from service account file with whitespace', () {
|
||||
final File serviceAccountFile = fs.file(serviceAccountTokenPath)..createSync();
|
||||
serviceAccountFile.writeAsStringSync('$serviceAccountToken \n');
|
||||
final AuthenticatedCocoonClient client = AuthenticatedCocoonClient(serviceAccountTokenPath, filesystem: fs);
|
||||
final AuthenticatedCocoonClient client = AuthenticatedCocoonClient(
|
||||
serviceAccountTokenPath,
|
||||
filesystem: fs,
|
||||
);
|
||||
expect(client.serviceAccountToken, serviceAccountToken);
|
||||
});
|
||||
|
||||
test('throws error when service account file not found', () {
|
||||
final AuthenticatedCocoonClient client = AuthenticatedCocoonClient('idontexist', filesystem: fs);
|
||||
final AuthenticatedCocoonClient client = AuthenticatedCocoonClient(
|
||||
'idontexist',
|
||||
filesystem: fs,
|
||||
);
|
||||
expect(() => client.serviceAccountToken, throwsA(isA<FileSystemException>()));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,14 +10,11 @@ import 'browser_test_json_samples.dart';
|
||||
void main() {
|
||||
group('BlinkTraceEvent works with Chrome 89+', () {
|
||||
// Used to test 'false' results
|
||||
final BlinkTraceEvent unrelatedPhX =
|
||||
BlinkTraceEvent.fromJson(unrelatedPhXJson);
|
||||
final BlinkTraceEvent anotherUnrelated =
|
||||
BlinkTraceEvent.fromJson(anotherUnrelatedJson);
|
||||
final BlinkTraceEvent unrelatedPhX = BlinkTraceEvent.fromJson(unrelatedPhXJson);
|
||||
final BlinkTraceEvent anotherUnrelated = BlinkTraceEvent.fromJson(anotherUnrelatedJson);
|
||||
|
||||
test('isBeginFrame', () {
|
||||
final BlinkTraceEvent event =
|
||||
BlinkTraceEvent.fromJson(beginMainFrameJson_89plus);
|
||||
final BlinkTraceEvent event = BlinkTraceEvent.fromJson(beginMainFrameJson_89plus);
|
||||
|
||||
expect(event.isBeginFrame, isTrue);
|
||||
expect(unrelatedPhX.isBeginFrame, isFalse);
|
||||
@@ -25,8 +22,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('isUpdateAllLifecyclePhases', () {
|
||||
final BlinkTraceEvent event =
|
||||
BlinkTraceEvent.fromJson(updateLifecycleJson_89plus);
|
||||
final BlinkTraceEvent event = BlinkTraceEvent.fromJson(updateLifecycleJson_89plus);
|
||||
|
||||
expect(event.isUpdateAllLifecyclePhases, isTrue);
|
||||
expect(unrelatedPhX.isUpdateAllLifecyclePhases, isFalse);
|
||||
@@ -34,8 +30,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('isBeginMeasuredFrame', () {
|
||||
final BlinkTraceEvent event =
|
||||
BlinkTraceEvent.fromJson(beginMeasuredFrameJson_89plus);
|
||||
final BlinkTraceEvent event = BlinkTraceEvent.fromJson(beginMeasuredFrameJson_89plus);
|
||||
|
||||
expect(event.isBeginMeasuredFrame, isTrue);
|
||||
expect(unrelatedPhX.isBeginMeasuredFrame, isFalse);
|
||||
@@ -43,8 +38,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('isEndMeasuredFrame', () {
|
||||
final BlinkTraceEvent event =
|
||||
BlinkTraceEvent.fromJson(endMeasuredFrameJson_89plus);
|
||||
final BlinkTraceEvent event = BlinkTraceEvent.fromJson(endMeasuredFrameJson_89plus);
|
||||
|
||||
expect(event.isEndMeasuredFrame, isTrue);
|
||||
expect(unrelatedPhX.isEndMeasuredFrame, isFalse);
|
||||
|
||||
@@ -8,7 +8,8 @@ import 'dart:convert' show jsonDecode;
|
||||
// integration tests of this package that dumped all the data as captured.
|
||||
|
||||
/// To test isBeginFrame. (Sampled from Chrome 89+)
|
||||
final Map<String, Object?> beginMainFrameJson_89plus = jsonDecode('''
|
||||
final Map<String, Object?> beginMainFrameJson_89plus =
|
||||
jsonDecode('''
|
||||
{
|
||||
"args": {
|
||||
"frameTime": 2338687248768
|
||||
@@ -23,10 +24,12 @@ final Map<String, Object?> beginMainFrameJson_89plus = jsonDecode('''
|
||||
"ts": 2338687258440,
|
||||
"tts": 375499
|
||||
}
|
||||
''') as Map<String, Object?>;
|
||||
''')
|
||||
as Map<String, Object?>;
|
||||
|
||||
/// To test isUpdateAllLifecyclePhases. (Sampled from Chrome 89+)
|
||||
final Map<String, Object?> updateLifecycleJson_89plus = jsonDecode('''
|
||||
final Map<String, Object?> updateLifecycleJson_89plus =
|
||||
jsonDecode('''
|
||||
{
|
||||
"args": {},
|
||||
"cat": "blink",
|
||||
@@ -39,10 +42,12 @@ final Map<String, Object?> updateLifecycleJson_89plus = jsonDecode('''
|
||||
"ts": 2338687265284,
|
||||
"tts": 375900
|
||||
}
|
||||
''') as Map<String, Object?>;
|
||||
''')
|
||||
as Map<String, Object?>;
|
||||
|
||||
/// To test isBeginMeasuredFrame. (Sampled from Chrome 89+)
|
||||
final Map<String, Object?> beginMeasuredFrameJson_89plus = jsonDecode('''
|
||||
final Map<String, Object?> beginMeasuredFrameJson_89plus =
|
||||
jsonDecode('''
|
||||
{
|
||||
"args": {},
|
||||
"cat": "blink.user_timing",
|
||||
@@ -54,10 +59,12 @@ final Map<String, Object?> beginMeasuredFrameJson_89plus = jsonDecode('''
|
||||
"tid": 1,
|
||||
"ts": 2338687265932
|
||||
}
|
||||
''') as Map<String, Object?>;
|
||||
''')
|
||||
as Map<String, Object?>;
|
||||
|
||||
/// To test isEndMeasuredFrame. (Sampled from Chrome 89+)
|
||||
final Map<String, Object?> endMeasuredFrameJson_89plus = jsonDecode('''
|
||||
final Map<String, Object?> endMeasuredFrameJson_89plus =
|
||||
jsonDecode('''
|
||||
{
|
||||
"args": {},
|
||||
"cat": "blink.user_timing",
|
||||
@@ -69,10 +76,12 @@ final Map<String, Object?> endMeasuredFrameJson_89plus = jsonDecode('''
|
||||
"tid": 1,
|
||||
"ts": 2338687440485
|
||||
}
|
||||
''') as Map<String, Object?>;
|
||||
''')
|
||||
as Map<String, Object?>;
|
||||
|
||||
/// An unrelated data frame to test negative cases.
|
||||
final Map<String, Object?> unrelatedPhXJson = jsonDecode('''
|
||||
final Map<String, Object?> unrelatedPhXJson =
|
||||
jsonDecode('''
|
||||
{
|
||||
"args": {},
|
||||
"cat": "blink,rail",
|
||||
@@ -85,10 +94,12 @@ final Map<String, Object?> unrelatedPhXJson = jsonDecode('''
|
||||
"ts": 2338691143317,
|
||||
"tts": 1685405
|
||||
}
|
||||
''') as Map<String, Object?>;
|
||||
''')
|
||||
as Map<String, Object?>;
|
||||
|
||||
/// Another unrelated data frame to test negative cases.
|
||||
final Map<String, Object?> anotherUnrelatedJson = jsonDecode('''
|
||||
final Map<String, Object?> anotherUnrelatedJson =
|
||||
jsonDecode('''
|
||||
{
|
||||
"args": {
|
||||
"sort_index": -1
|
||||
@@ -100,4 +111,5 @@ final Map<String, Object?> anotherUnrelatedJson = jsonDecode('''
|
||||
"tid": 1,
|
||||
"ts": 2338692906482
|
||||
}
|
||||
''') as Map<String, Object?>;
|
||||
''')
|
||||
as Map<String, Object?>;
|
||||
|
||||
@@ -34,7 +34,10 @@ void main() {
|
||||
});
|
||||
|
||||
test('not set by environment', () async {
|
||||
final FakePlatform fakePlatform = FakePlatform(environment: <String, String>{}, operatingSystem: 'windows');
|
||||
final FakePlatform fakePlatform = FakePlatform(
|
||||
environment: <String, String>{},
|
||||
operatingSystem: 'windows',
|
||||
);
|
||||
final HostAgent agent = HostAgent(platform: fakePlatform, fileSystem: fs);
|
||||
|
||||
expect(agent.dumpDirectory, null);
|
||||
|
||||
@@ -29,12 +29,8 @@ void main() {
|
||||
'CommitBranch': 'master',
|
||||
'CommitSha': 'abc',
|
||||
'BuilderName': 'Linux test',
|
||||
'ResultData': <String, dynamic>{
|
||||
'average_frame_build_time_millis': 0.4550425531914895,
|
||||
},
|
||||
'BenchmarkScoreKeys': <String>[
|
||||
'average_frame_build_time_millis',
|
||||
],
|
||||
'ResultData': <String, dynamic>{'average_frame_build_time_millis': 0.4550425531914895},
|
||||
'BenchmarkScoreKeys': <String>['average_frame_build_time_millis'],
|
||||
};
|
||||
final List<MetricPoint> metricPoints = parse(results, <String, String>{}, 'test');
|
||||
|
||||
@@ -170,7 +166,11 @@ void main() {
|
||||
});
|
||||
|
||||
test('with device host and arch tags', () async {
|
||||
final Map<String, dynamic> tags = <String, dynamic>{'device_type': 'ab-c', 'host_type': 'de-f', 'arch': 'm1'};
|
||||
final Map<String, dynamic> tags = <String, dynamic>{
|
||||
'device_type': 'ab-c',
|
||||
'host_type': 'de-f',
|
||||
'arch': 'm1',
|
||||
};
|
||||
final String fileName = metricFileName('test', tags);
|
||||
expect(fileName, 'test_m1_def_abc');
|
||||
});
|
||||
|
||||
@@ -12,7 +12,6 @@ import 'package:flutter_devicelab/tasks/perf_tests.dart';
|
||||
import 'common.dart';
|
||||
|
||||
void main() {
|
||||
|
||||
late Directory testDirectory;
|
||||
late File testTarget;
|
||||
late Device device;
|
||||
@@ -66,69 +65,90 @@ void main() {
|
||||
};
|
||||
const String resultFileName = 'fake_result';
|
||||
void driveCallback(List<String> arguments) {
|
||||
final File resultFile = File('$perfTestOutputPath/$resultFileName.json')..createSync(recursive: true);
|
||||
final File resultFile = File('$perfTestOutputPath/$resultFileName.json')
|
||||
..createSync(recursive: true);
|
||||
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,
|
||||
);
|
||||
final TaskResult result = await perfTest.run();
|
||||
expect(result.data!['frame_count'], 5);
|
||||
});
|
||||
|
||||
test('runs perf tests, successfully parse refresh rate percentage key-values from data`', () async {
|
||||
final Map<String, dynamic> fakeData = <String, dynamic>{
|
||||
'frame_count': 5,
|
||||
'average_frame_build_time_millis': 0.1,
|
||||
'worst_frame_build_time_millis': 0.1,
|
||||
'90th_percentile_frame_build_time_millis': 0.1,
|
||||
'99th_percentile_frame_build_time_millis': 0.1,
|
||||
'average_frame_rasterizer_time_millis': 0.1,
|
||||
'worst_frame_rasterizer_time_millis': 0.1,
|
||||
'90th_percentile_frame_rasterizer_time_millis': 0.1,
|
||||
'99th_percentile_frame_rasterizer_time_millis': 0.1,
|
||||
'average_layer_cache_count': 1,
|
||||
'90th_percentile_layer_cache_count': 1,
|
||||
'99th_percentile_layer_cache_count': 1,
|
||||
'worst_layer_cache_count': 1,
|
||||
'average_layer_cache_memory': 1,
|
||||
'90th_percentile_layer_cache_memory': 1,
|
||||
'99th_percentile_layer_cache_memory': 1,
|
||||
'worst_layer_cache_memory': 1,
|
||||
'average_picture_cache_count': 1,
|
||||
'90th_percentile_picture_cache_count': 1,
|
||||
'99th_percentile_picture_cache_count': 1,
|
||||
'worst_picture_cache_count': 1,
|
||||
'average_picture_cache_memory': 1,
|
||||
'90th_percentile_picture_cache_memory': 1,
|
||||
'99th_percentile_picture_cache_memory': 1,
|
||||
'worst_picture_cache_memory': 1,
|
||||
'total_ui_gc_time': 1,
|
||||
'new_gen_gc_count': 1,
|
||||
'old_gen_gc_count': 1,
|
||||
'average_vsync_transitions_missed': 1,
|
||||
'90th_percentile_vsync_transitions_missed': 1,
|
||||
'99th_percentile_vsync_transitions_missed': 1,
|
||||
'30hz_frame_percentage': 0.1,
|
||||
'60hz_frame_percentage': 0.2,
|
||||
'80hz_frame_percentage': 0.3,
|
||||
'90hz_frame_percentage': 0.4,
|
||||
'120hz_frame_percentage': 0.6,
|
||||
'illegal_refresh_rate_frame_count': 10,
|
||||
'average_frame_request_pending_latency': 0.1,
|
||||
'90th_percentile_frame_request_pending_latency': 0.1,
|
||||
'99th_percentile_frame_request_pending_latency': 0.1,
|
||||
};
|
||||
const String resultFileName = 'fake_result';
|
||||
void driveCallback(List<String> arguments) {
|
||||
final File resultFile = File('$perfTestOutputPath/$resultFileName.json')..createSync(recursive: true);
|
||||
resultFile.writeAsStringSync(json.encode(fakeData));
|
||||
}
|
||||
final PerfTest perfTest = PerfTest(testDirectory.absolute.path, testTarget.absolute.path, 'test_file', resultFilename: resultFileName, device: device, flutterDriveCallback: driveCallback);
|
||||
final TaskResult result = await perfTest.run();
|
||||
expect(result.data!['30hz_frame_percentage'], 0.1);
|
||||
expect(result.data!['60hz_frame_percentage'], 0.2);
|
||||
expect(result.data!['80hz_frame_percentage'], 0.3);
|
||||
expect(result.data!['90hz_frame_percentage'], 0.4);
|
||||
expect(result.data!['120hz_frame_percentage'], 0.6);
|
||||
expect(result.data!['illegal_refresh_rate_frame_count'], 10);
|
||||
});
|
||||
test(
|
||||
'runs perf tests, successfully parse refresh rate percentage key-values from data`',
|
||||
() async {
|
||||
final Map<String, dynamic> fakeData = <String, dynamic>{
|
||||
'frame_count': 5,
|
||||
'average_frame_build_time_millis': 0.1,
|
||||
'worst_frame_build_time_millis': 0.1,
|
||||
'90th_percentile_frame_build_time_millis': 0.1,
|
||||
'99th_percentile_frame_build_time_millis': 0.1,
|
||||
'average_frame_rasterizer_time_millis': 0.1,
|
||||
'worst_frame_rasterizer_time_millis': 0.1,
|
||||
'90th_percentile_frame_rasterizer_time_millis': 0.1,
|
||||
'99th_percentile_frame_rasterizer_time_millis': 0.1,
|
||||
'average_layer_cache_count': 1,
|
||||
'90th_percentile_layer_cache_count': 1,
|
||||
'99th_percentile_layer_cache_count': 1,
|
||||
'worst_layer_cache_count': 1,
|
||||
'average_layer_cache_memory': 1,
|
||||
'90th_percentile_layer_cache_memory': 1,
|
||||
'99th_percentile_layer_cache_memory': 1,
|
||||
'worst_layer_cache_memory': 1,
|
||||
'average_picture_cache_count': 1,
|
||||
'90th_percentile_picture_cache_count': 1,
|
||||
'99th_percentile_picture_cache_count': 1,
|
||||
'worst_picture_cache_count': 1,
|
||||
'average_picture_cache_memory': 1,
|
||||
'90th_percentile_picture_cache_memory': 1,
|
||||
'99th_percentile_picture_cache_memory': 1,
|
||||
'worst_picture_cache_memory': 1,
|
||||
'total_ui_gc_time': 1,
|
||||
'new_gen_gc_count': 1,
|
||||
'old_gen_gc_count': 1,
|
||||
'average_vsync_transitions_missed': 1,
|
||||
'90th_percentile_vsync_transitions_missed': 1,
|
||||
'99th_percentile_vsync_transitions_missed': 1,
|
||||
'30hz_frame_percentage': 0.1,
|
||||
'60hz_frame_percentage': 0.2,
|
||||
'80hz_frame_percentage': 0.3,
|
||||
'90hz_frame_percentage': 0.4,
|
||||
'120hz_frame_percentage': 0.6,
|
||||
'illegal_refresh_rate_frame_count': 10,
|
||||
'average_frame_request_pending_latency': 0.1,
|
||||
'90th_percentile_frame_request_pending_latency': 0.1,
|
||||
'99th_percentile_frame_request_pending_latency': 0.1,
|
||||
};
|
||||
const String resultFileName = 'fake_result';
|
||||
void driveCallback(List<String> arguments) {
|
||||
final File resultFile = File('$perfTestOutputPath/$resultFileName.json')
|
||||
..createSync(recursive: true);
|
||||
resultFile.writeAsStringSync(json.encode(fakeData));
|
||||
}
|
||||
|
||||
final PerfTest perfTest = PerfTest(
|
||||
testDirectory.absolute.path,
|
||||
testTarget.absolute.path,
|
||||
'test_file',
|
||||
resultFilename: resultFileName,
|
||||
device: device,
|
||||
flutterDriveCallback: driveCallback,
|
||||
);
|
||||
final TaskResult result = await perfTest.run();
|
||||
expect(result.data!['30hz_frame_percentage'], 0.1);
|
||||
expect(result.data!['60hz_frame_percentage'], 0.2);
|
||||
expect(result.data!['80hz_frame_percentage'], 0.3);
|
||||
expect(result.data!['90hz_frame_percentage'], 0.4);
|
||||
expect(result.data!['120hz_frame_percentage'], 0.6);
|
||||
expect(result.data!['illegal_refresh_rate_frame_count'], 10);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,13 +14,16 @@ import 'common.dart';
|
||||
void main() {
|
||||
const ProcessManager processManager = LocalProcessManager();
|
||||
final String dart = path.absolute(
|
||||
path.join('..', '..', 'bin', 'cache', 'dart-sdk', 'bin', 'dart'));
|
||||
path.join('..', '..', 'bin', 'cache', 'dart-sdk', 'bin', 'dart'),
|
||||
);
|
||||
|
||||
group('run.dart script', () {
|
||||
// The tasks here refer to files in ../bin/tasks/*.dart
|
||||
|
||||
Future<ProcessResult> runScript(List<String> taskNames,
|
||||
[List<String> otherArgs = const <String>[]]) async {
|
||||
Future<ProcessResult> runScript(
|
||||
List<String> taskNames, [
|
||||
List<String> otherArgs = const <String>[],
|
||||
]) async {
|
||||
final ProcessResult scriptProcess = processManager.runSync(<String>[
|
||||
dart,
|
||||
'bin/run.dart',
|
||||
@@ -32,10 +35,10 @@ void main() {
|
||||
}
|
||||
|
||||
Future<void> expectScriptResult(
|
||||
List<String> taskNames,
|
||||
int expectedExitCode,
|
||||
{String? deviceId}
|
||||
) async {
|
||||
List<String> taskNames,
|
||||
int expectedExitCode, {
|
||||
String? deviceId,
|
||||
}) async {
|
||||
final ProcessResult result = await runScript(taskNames, <String>[
|
||||
if (deviceId != null) ...<String>['-d', deviceId],
|
||||
]);
|
||||
@@ -43,17 +46,17 @@ void main() {
|
||||
result.exitCode,
|
||||
expectedExitCode,
|
||||
reason:
|
||||
'[ stderr from test process ]\n'
|
||||
'\n'
|
||||
'${result.stderr}\n'
|
||||
'\n'
|
||||
'[ end of stderr ]\n'
|
||||
'\n'
|
||||
'[ stdout from test process ]\n'
|
||||
'\n'
|
||||
'${result.stdout}\n'
|
||||
'\n'
|
||||
'[ end of stdout ]',
|
||||
'[ stderr from test process ]\n'
|
||||
'\n'
|
||||
'${result.stderr}\n'
|
||||
'\n'
|
||||
'[ end of stderr ]\n'
|
||||
'\n'
|
||||
'[ stdout from test process ]\n'
|
||||
'\n'
|
||||
'${result.stdout}\n'
|
||||
'\n'
|
||||
'[ end of stdout ]',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -73,62 +76,69 @@ void main() {
|
||||
await expectScriptResult(<String>['smoke_test_failure'], 1);
|
||||
});
|
||||
|
||||
test('prints a message after a few seconds when failing to connect (this test takes >10s)', () async {
|
||||
final Process process = await processManager.start(<String>[
|
||||
dart,
|
||||
'bin/run.dart',
|
||||
'--no-terminate-stray-dart-processes',
|
||||
'-t', 'smoke_test_setup_failure',
|
||||
]);
|
||||
test(
|
||||
'prints a message after a few seconds when failing to connect (this test takes >10s)',
|
||||
() async {
|
||||
final Process process = await processManager.start(<String>[
|
||||
dart,
|
||||
'bin/run.dart',
|
||||
'--no-terminate-stray-dart-processes',
|
||||
'-t',
|
||||
'smoke_test_setup_failure',
|
||||
]);
|
||||
|
||||
// If this test fails, the reason is usually buried in stderr.
|
||||
final Stream<String> stderr = process.stderr.transform(utf8.decoder);
|
||||
stderr.listen(printOnFailure);
|
||||
// If this test fails, the reason is usually buried in stderr.
|
||||
final Stream<String> stderr = process.stderr.transform(utf8.decoder);
|
||||
stderr.listen(printOnFailure);
|
||||
|
||||
final Stream<String> stdout = process.stdout.transform(utf8.decoder);
|
||||
await expectLater(
|
||||
stdout,
|
||||
emitsThrough(contains('VM service still not ready. It is possible the target has failed')),
|
||||
);
|
||||
expect(process.kill(), isTrue);
|
||||
}, timeout: const Timeout(Duration(seconds: 45))); // Standard 30 is flaky because this is a long running test, https://github.com/flutter/flutter/issues/156456
|
||||
final Stream<String> stdout = process.stdout.transform(utf8.decoder);
|
||||
await expectLater(
|
||||
stdout,
|
||||
emitsThrough(
|
||||
contains('VM service still not ready. It is possible the target has failed'),
|
||||
),
|
||||
);
|
||||
expect(process.kill(), isTrue);
|
||||
},
|
||||
timeout: const Timeout(Duration(seconds: 45)),
|
||||
); // Standard 30 is flaky because this is a long running test, https://github.com/flutter/flutter/issues/156456
|
||||
|
||||
test('exits with code 1 when results are mixed', () async {
|
||||
await expectScriptResult(
|
||||
<String>[
|
||||
'smoke_test_failure',
|
||||
'smoke_test_success',
|
||||
],
|
||||
1,
|
||||
);
|
||||
await expectScriptResult(<String>['smoke_test_failure', 'smoke_test_success'], 1);
|
||||
});
|
||||
|
||||
test('exits with code 0 when provided a valid device ID', () async {
|
||||
await expectScriptResult(<String>['smoke_test_device'], 0,
|
||||
deviceId: 'FAKE');
|
||||
await expectScriptResult(<String>['smoke_test_device'], 0, deviceId: 'FAKE');
|
||||
});
|
||||
|
||||
test('exits with code 1 when provided a bad device ID', () async {
|
||||
await expectScriptResult(<String>['smoke_test_device'], 1,
|
||||
deviceId: 'THIS_IS_NOT_VALID');
|
||||
await expectScriptResult(<String>['smoke_test_device'], 1, deviceId: 'THIS_IS_NOT_VALID');
|
||||
});
|
||||
|
||||
|
||||
test('runs A/B test', () async {
|
||||
final Directory tempDirectory = Directory.systemTemp.createTempSync('flutter_devicelab_ab_test.');
|
||||
final Directory tempDirectory = Directory.systemTemp.createTempSync(
|
||||
'flutter_devicelab_ab_test.',
|
||||
);
|
||||
final File abResultsFile = File(path.join(tempDirectory.path, 'test_results.json'));
|
||||
|
||||
expect(abResultsFile.existsSync(), isFalse);
|
||||
|
||||
final ProcessResult result = await runScript(
|
||||
<String>['smoke_test_success'],
|
||||
<String>['--ab=2', '--local-engine=host_debug_unopt', '--local-engine-host=host_debug_unopt', '--ab-result-file', abResultsFile.path],
|
||||
<String>[
|
||||
'--ab=2',
|
||||
'--local-engine=host_debug_unopt',
|
||||
'--local-engine-host=host_debug_unopt',
|
||||
'--ab-result-file',
|
||||
abResultsFile.path,
|
||||
],
|
||||
);
|
||||
expect(result.exitCode, 0);
|
||||
|
||||
String sectionHeader = !Platform.isWindows
|
||||
? '═════════════════════════╡ ••• A/B results so far ••• ╞═════════════════════════'
|
||||
: 'A/B results so far';
|
||||
String sectionHeader =
|
||||
!Platform.isWindows
|
||||
? '═════════════════════════╡ ••• A/B results so far ••• ╞═════════════════════════'
|
||||
: 'A/B results so far';
|
||||
expect(
|
||||
result.stdout,
|
||||
contains(
|
||||
@@ -140,9 +150,10 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
sectionHeader = !Platform.isWindows
|
||||
? '════════════════════════════╡ ••• Raw results ••• ╞═════════════════════════════'
|
||||
: 'Raw results';
|
||||
sectionHeader =
|
||||
!Platform.isWindows
|
||||
? '════════════════════════════╡ ••• Raw results ••• ╞═════════════════════════════'
|
||||
: 'Raw results';
|
||||
expect(
|
||||
result.stdout,
|
||||
contains(
|
||||
@@ -157,9 +168,10 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
sectionHeader = !Platform.isWindows
|
||||
? '═════════════════════════╡ ••• Final A/B results ••• ╞══════════════════════════'
|
||||
: 'Final A/B results';
|
||||
sectionHeader =
|
||||
!Platform.isWindows
|
||||
? '═════════════════════════╡ ••• Final A/B results ••• ╞══════════════════════════'
|
||||
: 'Final A/B results';
|
||||
expect(
|
||||
result.stdout,
|
||||
contains(
|
||||
|
||||
@@ -42,32 +42,30 @@ void main() {
|
||||
expect(printLog[1], 'flaky: false');
|
||||
});
|
||||
|
||||
test('Ensures task results are received before task process shuts down.', () async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/155475
|
||||
//
|
||||
// Runs multiple concurrent instances of a short-lived task in an effort to
|
||||
// trigger the race between the VM service processing the response from
|
||||
// ext.cocoonRunTask and the VM shutting down, which will throw a RPCError
|
||||
// with a "Service connection disposed" message.
|
||||
//
|
||||
// Obviously this isn't foolproof, but this test becoming flaky or failing
|
||||
// consistently should signal that we're encountering a shutdown race
|
||||
// somewhere.
|
||||
const int runs = 30;
|
||||
try {
|
||||
await Future.wait(
|
||||
<Future<void>>[
|
||||
test(
|
||||
'Ensures task results are received before task process shuts down.',
|
||||
() async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/155475
|
||||
//
|
||||
// Runs multiple concurrent instances of a short-lived task in an effort to
|
||||
// trigger the race between the VM service processing the response from
|
||||
// ext.cocoonRunTask and the VM shutting down, which will throw a RPCError
|
||||
// with a "Service connection disposed" message.
|
||||
//
|
||||
// Obviously this isn't foolproof, but this test becoming flaky or failing
|
||||
// consistently should signal that we're encountering a shutdown race
|
||||
// somewhere.
|
||||
const int runs = 30;
|
||||
try {
|
||||
await Future.wait(<Future<void>>[
|
||||
for (int i = 0; i < runs; ++i)
|
||||
runTasks(
|
||||
<String>['smoke_test_success'],
|
||||
isolateParams: isolateParams,
|
||||
),
|
||||
],
|
||||
eagerError: true,
|
||||
);
|
||||
} on RPCError catch (e) {
|
||||
fail('Unexpected RPCError: $e');
|
||||
}
|
||||
}, timeout: const Timeout.factor(2));
|
||||
runTasks(<String>['smoke_test_success'], isolateParams: isolateParams),
|
||||
], eagerError: true);
|
||||
} on RPCError catch (e) {
|
||||
fail('Unexpected RPCError: $e');
|
||||
}
|
||||
},
|
||||
timeout: const Timeout.factor(2),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,28 +23,28 @@ ProcessId CreationDate CommandLine
|
||||
|
||||
|
||||
''';
|
||||
final List<RunningProcessInfo> results =
|
||||
processPowershellOutput(powershellOutput).toList();
|
||||
final List<RunningProcessInfo> results = processPowershellOutput(powershellOutput).toList();
|
||||
expect(results.length, 3);
|
||||
expect(
|
||||
results,
|
||||
equals(<RunningProcessInfo>[
|
||||
RunningProcessInfo(
|
||||
6552,
|
||||
r'"C:\tools\dart-sdk\bin\dart.exe" .\bin\agent.dart ci',
|
||||
DateTime(2019, 7, 3, 17, 0, 27),
|
||||
),
|
||||
RunningProcessInfo(
|
||||
6553,
|
||||
r'"C:\tools\dart-sdk1\bin\dart.exe" .\bin\agent.dart ci',
|
||||
DateTime(2019, 7, 3, 22, 0, 27),
|
||||
),
|
||||
RunningProcessInfo(
|
||||
6554,
|
||||
r'"C:\tools\dart-sdk2\bin\dart.exe" .\bin\agent.dart ci',
|
||||
DateTime(2019, 7, 3, 11, 0, 27),
|
||||
),
|
||||
]));
|
||||
results,
|
||||
equals(<RunningProcessInfo>[
|
||||
RunningProcessInfo(
|
||||
6552,
|
||||
r'"C:\tools\dart-sdk\bin\dart.exe" .\bin\agent.dart ci',
|
||||
DateTime(2019, 7, 3, 17, 0, 27),
|
||||
),
|
||||
RunningProcessInfo(
|
||||
6553,
|
||||
r'"C:\tools\dart-sdk1\bin\dart.exe" .\bin\agent.dart ci',
|
||||
DateTime(2019, 7, 3, 22, 0, 27),
|
||||
),
|
||||
RunningProcessInfo(
|
||||
6554,
|
||||
r'"C:\tools\dart-sdk2\bin\dart.exe" .\bin\agent.dart ci',
|
||||
DateTime(2019, 7, 3, 11, 0, 27),
|
||||
),
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
test('Parse Posix output', () {
|
||||
@@ -54,23 +54,15 @@ Sat Mar 9 20:12:47 2019 1 /sbin/launchd
|
||||
Sat Mar 9 20:13:00 2019 49 /usr/sbin/syslogd
|
||||
''';
|
||||
|
||||
final List<RunningProcessInfo> results =
|
||||
processPsOutput(psOutput, null).toList();
|
||||
final List<RunningProcessInfo> results = processPsOutput(psOutput, null).toList();
|
||||
expect(results.length, 2);
|
||||
expect(
|
||||
results,
|
||||
equals(<RunningProcessInfo>[
|
||||
RunningProcessInfo(
|
||||
1,
|
||||
'/sbin/launchd',
|
||||
DateTime(2019, 3, 9, 20, 12, 47),
|
||||
),
|
||||
RunningProcessInfo(
|
||||
49,
|
||||
'/usr/sbin/syslogd',
|
||||
DateTime(2019, 3, 9, 20, 13),
|
||||
),
|
||||
]));
|
||||
results,
|
||||
equals(<RunningProcessInfo>[
|
||||
RunningProcessInfo(1, '/sbin/launchd', DateTime(2019, 3, 9, 20, 12, 47)),
|
||||
RunningProcessInfo(49, '/usr/sbin/syslogd', DateTime(2019, 3, 9, 20, 13)),
|
||||
]),
|
||||
);
|
||||
});
|
||||
|
||||
test('RunningProcessInfo.terminate', () {
|
||||
@@ -78,7 +70,9 @@ Sat Mar 9 20:13:00 2019 49 /usr/sbin/syslogd
|
||||
final FakeProcessManager fakeProcessManager = FakeProcessManager();
|
||||
process.terminate(processManager: fakeProcessManager);
|
||||
if (Platform.isWindows) {
|
||||
expect(fakeProcessManager.log, <String>['run([taskkill.exe, /pid, 123, /f], null, null, null, null, null, null)']);
|
||||
expect(fakeProcessManager.log, <String>[
|
||||
'run([taskkill.exe, /pid, 123, /f], null, null, null, null, null, null)',
|
||||
]);
|
||||
} else {
|
||||
expect(fakeProcessManager.log, <String>['killPid(123, SIGKILL)']);
|
||||
}
|
||||
@@ -89,7 +83,7 @@ class FakeProcessManager implements ProcessManager {
|
||||
final List<String> log = <String>[];
|
||||
|
||||
@override
|
||||
bool canRun(Object? a, { String? workingDirectory }) {
|
||||
bool canRun(Object? a, {String? workingDirectory}) {
|
||||
log.add('canRun($a, $workingDirectory)');
|
||||
return true;
|
||||
}
|
||||
@@ -101,7 +95,8 @@ class FakeProcessManager implements ProcessManager {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ProcessResult> run(List<Object> a, {
|
||||
Future<ProcessResult> run(
|
||||
List<Object> a, {
|
||||
Map<String, String>? environment,
|
||||
bool? includeParentEnvironment,
|
||||
bool? runInShell,
|
||||
@@ -109,12 +104,15 @@ class FakeProcessManager implements ProcessManager {
|
||||
Encoding? stdoutEncoding,
|
||||
String? workingDirectory,
|
||||
}) async {
|
||||
log.add('run($a, $environment, $includeParentEnvironment, $runInShell, $stderrEncoding, $stdoutEncoding, $workingDirectory)');
|
||||
log.add(
|
||||
'run($a, $environment, $includeParentEnvironment, $runInShell, $stderrEncoding, $stdoutEncoding, $workingDirectory)',
|
||||
);
|
||||
return ProcessResult(1, 0, 'stdout', 'stderr');
|
||||
}
|
||||
|
||||
@override
|
||||
ProcessResult runSync(List<Object> a, {
|
||||
ProcessResult runSync(
|
||||
List<Object> a, {
|
||||
Map<String, String>? environment,
|
||||
bool? includeParentEnvironment,
|
||||
bool? runInShell,
|
||||
@@ -122,7 +120,9 @@ class FakeProcessManager implements ProcessManager {
|
||||
Encoding? stdoutEncoding,
|
||||
String? workingDirectory,
|
||||
}) {
|
||||
log.add('runSync($a, $environment, $includeParentEnvironment, $runInShell, $stderrEncoding, $stdoutEncoding, $workingDirectory)');
|
||||
log.add(
|
||||
'runSync($a, $environment, $includeParentEnvironment, $runInShell, $stderrEncoding, $stdoutEncoding, $workingDirectory)',
|
||||
);
|
||||
return ProcessResult(1, 0, 'stdout', 'stderr');
|
||||
}
|
||||
|
||||
@@ -135,7 +135,9 @@ class FakeProcessManager implements ProcessManager {
|
||||
bool? runInShell,
|
||||
String? workingDirectory,
|
||||
}) {
|
||||
log.add('start($a, $environment, $includeParentEnvironment, $mode, $runInShell, $workingDirectory)');
|
||||
log.add(
|
||||
'start($a, $environment, $includeParentEnvironment, $mode, $runInShell, $workingDirectory)',
|
||||
);
|
||||
return Completer<Process>().future;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,7 @@ void main() {
|
||||
test('succeeded', () {
|
||||
final Map<String, dynamic> expectedJson = <String, dynamic>{
|
||||
'success': true,
|
||||
'data': <String, dynamic>{
|
||||
'i': 5,
|
||||
'j': 10,
|
||||
'not_a_metric': 'something',
|
||||
},
|
||||
'data': <String, dynamic>{'i': 5, 'j': 10, 'not_a_metric': 'something'},
|
||||
'benchmarkScoreKeys': <String>['i', 'j'],
|
||||
'detailFiles': <String>[],
|
||||
};
|
||||
@@ -24,9 +20,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('succeeded with empty data', () {
|
||||
final TaskResult result = TaskResult.fromJson(<String, dynamic>{
|
||||
'success': true,
|
||||
});
|
||||
final TaskResult result = TaskResult.fromJson(<String, dynamic>{'success': true});
|
||||
final Map<String, dynamic> expectedJson = <String, dynamic>{
|
||||
'success': true,
|
||||
'data': null,
|
||||
|
||||
@@ -63,8 +63,12 @@ void main() {
|
||||
),
|
||||
);
|
||||
final String capturedPrint = capturedPrintLines.toString();
|
||||
expect(capturedPrint,
|
||||
contains('with environment {FLUTTER_DEVICELAB_DEVICEID: FAKE_SUCCESS, BOT: true, LANG: en_US.UTF-8}'));
|
||||
expect(
|
||||
capturedPrint,
|
||||
contains(
|
||||
'with environment {FLUTTER_DEVICELAB_DEVICEID: FAKE_SUCCESS, BOT: true, LANG: en_US.UTF-8}',
|
||||
),
|
||||
);
|
||||
expect(capturedPrint, contains('Process terminated with exit code 0.'));
|
||||
});
|
||||
|
||||
@@ -75,7 +79,10 @@ void main() {
|
||||
deviceId: 'FAKE_SUCCESS',
|
||||
isolateParams: isolateParams,
|
||||
);
|
||||
expect(result.message, 'Task failed: Exception: Both build and test should not be passed. Pass only one.');
|
||||
expect(
|
||||
result.message,
|
||||
'Task failed: Exception: Both build and test should not be passed. Pass only one.',
|
||||
);
|
||||
});
|
||||
|
||||
test('copies artifacts when build and application binary arg are given', () async {
|
||||
|
||||
@@ -19,12 +19,12 @@ void main() {
|
||||
|
||||
group('parse service', () {
|
||||
const String badOutput = 'No uri here';
|
||||
const String sampleOutput = 'A Dart VM Service on '
|
||||
'Pixel 3 XL is available at: http://127.0.0.1:9090/LpjUpsdEjqI=/';
|
||||
const String sampleOutput =
|
||||
'A Dart VM Service on '
|
||||
'Pixel 3 XL is available at: http://127.0.0.1:9090/LpjUpsdEjqI=/';
|
||||
|
||||
test('uri', () {
|
||||
expect(parseServiceUri(sampleOutput),
|
||||
Uri.parse('http://127.0.0.1:9090/LpjUpsdEjqI=/'));
|
||||
expect(parseServiceUri(sampleOutput), Uri.parse('http://127.0.0.1:9090/LpjUpsdEjqI=/'));
|
||||
expect(parseServiceUri(badOutput), null);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user