-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Parser machine logs #118707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parser machine logs #118707
Conversation
dev/bots/test.dart
Outdated
| try { | ||
| final File info = fileSystem.file(path.join(flutterRoot, 'error.log')); | ||
| info.writeAsStringSync(json.encode(test.errors)); | ||
| } on fs.FileSystemException catch (e){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what kind of file system exceptions do you anticipate? and why should we silently (to my knowledge, nobody actually checks the logs on green builds) swallow them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is me planing for the worst and just caching a file system exception because in theory it can happen https://api.flutter.dev/flutter/dart-io/File/writeAsStringSync.html; The reason I don't fail this is because if it didn't fail at dart run test --file-reporter... it means that the failure only occurs after trying to write to a file, something unrelated to the PR in testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in the case dart run test failed first and later on this failed too the we will have a red build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we fail writing this file, will the recipe fail later on trying to read it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I think it should fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then better to fail fast with a very specific error message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you suggest raising an exception in here stating that something failed in creating the error.log file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I don't know if there is value in catching this exception if the recipe will just fail later. Then someone investigating a broken tree might think there is something wrong with the recipe, when really the problem was earlier and we could have left clues as the real location of the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough
dev/bots/tool_subsharding.dart
Outdated
| } | ||
|
|
||
| /// Intended to parse the output file of `dart test --file-reporter json:file_name | ||
| TestFileReporterResults parseFileReporter(File metrics) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style nit: this function's whole purpose is to take input values, process them, and then return an initialized instance of a class--the paradigm with object-oriented programming is to do this from a constructor. Since you need to keep state as you're parsing, it makes sense to track this state in a factory, and then at the end, once you have all your state initialized, call a hidden private constructor from that factory, like:
class TestFileReporterResults {
TestFileReporterResults._({
required this.allTestSpecs,
required this.hasFailedTests,
required this.errors,
});
/// Intended to parse the output file of `dart test --file-reporter json:file_name
factory TestFileReporterResults.fromFile(File metrics) {
if (!metrics.existsSync()) {
throw Exception('${metrics.path} does not exist');
}
final Map<int, TestSpecs> testSpecs = <int, TestSpecs>{};
bool hasFailedTests = true;
final List<String> errors = <String>[];
for(final String metric in metrics.readAsLinesSync()) {
final Map<String, dynamic> entry = json.decode(metric) as Map<String, dynamic>;
if (entry.containsKey('suite')) {
final Map<dynamic, dynamic> suite = entry['suite'] as Map<dynamic, dynamic>;
addTestSpec(suite, entry['time'] as int, testSpecs);
} else if (isMetricDone(entry, testSpecs)) {
final Map<dynamic, dynamic> group = entry['group'] as Map<dynamic, dynamic>;
final int suiteID = group['suiteID'] as int;
addMetricDone(suiteID, entry['time'] as int, testSpecs);
} else if (entry.containsKey('error') && entry.containsKey('stackTrace')) {
errors.add('${entry['error']}\n ${entry['stackTrace']}');
} else if (entry.containsKey('success') && entry['success'] == true) {
hasFailedTests = false;
}
}
return TestFileReporterResults._(allTestSpecs: testSpecs, hasFailedTests: hasFailedTests, errors: errors);
}
final Map<int, TestSpecs> allTestSpecs;
bool hasFailedTests;
final List<String> errors;
static void addTestSpec(Map<dynamic, dynamic> suite, int time, Map<int, TestSpecs> allTestSpecs) {
allTestSpecs[suite['id'] as int] = TestSpecs(
path: suite['path'] as String,
startTime: time,
);
}
static void addMetricDone(int suiteID, int time, Map<int, TestSpecs> allTestSpecs) {
final TestSpecs testSpec = allTestSpecs[suiteID]!;
testSpec.endTime = time;
}
static bool isMetricDone(Map<String, dynamic> entry, Map<int, TestSpecs> allTestSpecs) {
if (entry.containsKey('group') && entry['type'] as String == 'group') {
final Map<dynamic, dynamic> group = entry['group'] as Map<dynamic, dynamic>;
return allTestSpecs.containsKey(group['suiteID'] as int);
}
return false;
}
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition, I can see you're typing the suite as Map<dynamic, dynamic>--can the key really be anything other than a string? Also, prefer Object? over dynamic, per https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#avoid-using-var-and-dynamic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good; I wasn't able to find info on what types can be returned from --file-reporter thats why I decided to go with Map<dynamic, dynamic> rather than anything else, I can change this to Object? as per style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's JSON, the spec only allows strings as the keys: https://www.json.org/json-en.html
dev/bots/test.dart
Outdated
| final File info = fileSystem.file(path.join(flutterRoot, 'error.log')); | ||
| info.writeAsStringSync(json.encode(test.errors)); | ||
| } on fs.FileSystemException catch (e){ | ||
| throw fs.FileSystemException('Failed to generate info file (error.log): $e'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's enough to just not catch this (I'm pretty sure the exception message will have details on exactly what it was trying to do when it failed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And by not catching it, you'll get a more accurate stacktrace
dev/bots/tool_subsharding.dart
Outdated
| bool hasFailedTests = true; | ||
| final List<String> errors = <String>[]; | ||
|
|
||
| for(final String metric in metrics.readAsLinesSync()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| for(final String metric in metrics.readAsLinesSync()) { | |
| for (final String metric in metrics.readAsLinesSync()) { |
dev/bots/tool_subsharding.dart
Outdated
| final Map<String, Object?> group = entry['group']! as Map<String, Object?>; | ||
| final int suiteID = group['suiteID']! as int; | ||
| addMetricDone(suiteID, entry['time']! as int, testSpecs); | ||
| } else if (entry.containsKey('error') && entry.containsKey('stackTrace')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we still track if it had an error but no stacktrace?
christopherfujino
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two nits, otherwise LGTM
* 254a796 Revert "Reland "Add --serve-observatory flag to run, attach, and test (#118402)" (#119529)" (flutter/flutter#119729) * 1573c12 Marks Mac_android microbenchmarks to be unflaky (flutter/flutter#119727) * 5613ab0 remove unnecessary parens (flutter/flutter#119736) * 1305a50 Roll Flutter Engine from c08a286d60e9 to ba3adb74d952 (5 revisions) (flutter/flutter#119741) * 484d881 [conductor] update console link (flutter/flutter#118338) * 73124dc Fix `ListTileThemeData.copyWith` doesn't override correct properties (flutter/flutter#119738) * bc8927c 2b8dd4e5c Use Windows high contrast black/white theme with `MaterialApp` themes (flutter/engine#39206) (flutter/flutter#119747) * 578edfc Catch errors thrown while handling pointer events (flutter/flutter#119577) * 8fd5d4e Remove deprecated SystemNavigator.routeUpdated method (flutter/flutter#119187) * 7a926dc Deprecate MediaQuery[Data].fromWindow (flutter/flutter#119647) * cd118da Update a test expectation that depended on an SkParagraph fix (flutter/flutter#119756) * 4ae2d3b 🔥 Do not format the messages file for `gen-l10n` (flutter/flutter#119596) * 8f5949e Roll Flutter Engine from 2b8dd4e5c699 to a12d102773dd (2 revisions) (flutter/flutter#119758) * 4c99da6 Avoid printing blank lines between "Another exception was thrown:" messages. (flutter/flutter#119587) * 2ecf4ae Update the counter app to enable Material 3 (flutter/flutter#118835) * 0b8486d 29d09845f Roll Dart SDK from b47964e5d575 to 1c219a91e637 (1 revision) (flutter/engine#39324) (flutter/flutter#119763) * ca7b7e3 Roll Flutter Engine from 29d09845f21e to 97d27ff59459 (2 revisions) (flutter/flutter#119765) * 475fc4a Run Mac hostonly tests on any available arch (flutter/flutter#119762) * 322d10e 18118e10a Add iOS spring animation objc files (flutter/engine#38801) (flutter/flutter#119768) * f767f86 check if directory exists before listing content (flutter/flutter#119748) * 34730c7 Revert "Run Mac hostonly tests on any available arch (#119762)" (flutter/flutter#119784) * f9daa9a Roll Flutter Engine from 18118e10a0a5 to 679c4b42e222 (4 revisions) (flutter/flutter#119783) * fd76ef0 Reland "Add API for discovering assets" (flutter/flutter#119277) * ca0596e Fix `pub get --unknown-flag` (flutter/flutter#119622) * 9abb6d7 Roll Plugins from 9da327c to 9302d87 (11 revisions) (flutter/flutter#119825) * 9eafbcc Roll Flutter Engine from 679c4b42e222 to 388890a98e5b (6 revisions) (flutter/flutter#119830) * 1ee8799 Revert "[Re-land] Exposed tooltip longPress (#118796)" (flutter/flutter#119832) * 07b51a0 Add missing variants and *new* indicators to `useMaterial3` docs (flutter/flutter#119799) * 201380a e9e601c7c [web] Hide autofill overlay (flutter/engine#39294) (flutter/flutter#119833) * 1c0065c 27f55219d Roll Fuchsia Linux SDK from QxkjqmRgowkk_n2NZ... to pWloCaRzjLEAUvQEz... (flutter/engine#39339) (flutter/flutter#119838) * e7d934a Marks Linux_android android_choreographer_do_frame_test to be flaky (flutter/flutter#119721) * 3f986e4 Roll Flutter Engine from 27f55219df79 to ae38c9585a61 (2 revisions) (flutter/flutter#119840) * b0f1714 Make Flex,Row,Column const for real (flutter/flutter#119673) * d4b6898 [web] Put all index.html operations in one place (flutter/flutter#118188) * d63987f Parser machine logs (flutter/flutter#118707) * 22bbdf0 Android defines target update (flutter/flutter#119766) * 8387c23 [flutter_tools] Use base DAP detach and ensure correct output (flutter/flutter#119076) * d820aec Manual pub roll with dwds fix (flutter/flutter#119575) * 72f9cf5 Roll Flutter Engine from ae38c9585a61 to 616ecd8be3de (3 revisions) (flutter/flutter#119859) * cfdc358 roll packages (flutter/flutter#119865) * d875899 Bump test Chrome version for Mac arm support (flutter/flutter#119773) * 9b86a48 Fix gets removedItem instead of its index (flutter/flutter#119638) * 66b2ca6 Roll Flutter Engine from 616ecd8be3de to 2871970337df (3 revisions) (flutter/flutter#119870) * c626460 Make `_focusDebug` not interpolate in debug mode (flutter/flutter#119680) * a27802e flutter_tool: remove explicit length header in HTTP response (flutter/flutter#119869) * 3570cce Remove deprecated kind in GestureRecognizer et al (flutter/flutter#119572) * bc45b18 2696fff87 Roll Skia from c2d81db3ef41 to 4f0166baf5a4 (13 revisions) (flutter/engine#39348) (flutter/flutter#119879) * f3effce Roll Flutter Engine from 2696fff8716d to e3fe6dade964 (3 revisions) (flutter/flutter#119892) * 69421c1 [framework] use shader tiling instead of repeated calls to drawImage (flutter/flutter#119495) * 6b83eff Roll Flutter Engine from e3fe6dade964 to 655530e3fd15 (5 revisions) (flutter/flutter#119905) * a5d8a4a 67d35267c [Impeller] Use minimal coverage for stencil restores after overdraw prevention (flutter/engine#39358) (flutter/flutter#119910) * fc8ea56 0fb48ce5b Roll Dart SDK from 69452c5012d9 to be795cc64bd7 (1 revision) (flutter/engine#39360) (flutter/flutter#119926) * e0b2138 Dispose OverlayEntry in TooltipState. (flutter/flutter#117291) * c5e8757 Add M3 support for iconbuttons in error state in TextFields (flutter/flutter#119925)
* 254a796 Revert "Reland "Add --serve-observatory flag to run, attach, and test (#118402)" (#119529)" (flutter/flutter#119729) * 1573c12 Marks Mac_android microbenchmarks to be unflaky (flutter/flutter#119727) * 5613ab0 remove unnecessary parens (flutter/flutter#119736) * 1305a50 Roll Flutter Engine from c08a286d60e9 to ba3adb74d952 (5 revisions) (flutter/flutter#119741) * 484d881 [conductor] update console link (flutter/flutter#118338) * 73124dc Fix `ListTileThemeData.copyWith` doesn't override correct properties (flutter/flutter#119738) * bc8927c 2b8dd4e5c Use Windows high contrast black/white theme with `MaterialApp` themes (flutter/engine#39206) (flutter/flutter#119747) * 578edfc Catch errors thrown while handling pointer events (flutter/flutter#119577) * 8fd5d4e Remove deprecated SystemNavigator.routeUpdated method (flutter/flutter#119187) * 7a926dc Deprecate MediaQuery[Data].fromWindow (flutter/flutter#119647) * cd118da Update a test expectation that depended on an SkParagraph fix (flutter/flutter#119756) * 4ae2d3b 🔥 Do not format the messages file for `gen-l10n` (flutter/flutter#119596) * 8f5949e Roll Flutter Engine from 2b8dd4e5c699 to a12d102773dd (2 revisions) (flutter/flutter#119758) * 4c99da6 Avoid printing blank lines between "Another exception was thrown:" messages. (flutter/flutter#119587) * 2ecf4ae Update the counter app to enable Material 3 (flutter/flutter#118835) * 0b8486d 29d09845f Roll Dart SDK from b47964e5d575 to 1c219a91e637 (1 revision) (flutter/engine#39324) (flutter/flutter#119763) * ca7b7e3 Roll Flutter Engine from 29d09845f21e to 97d27ff59459 (2 revisions) (flutter/flutter#119765) * 475fc4a Run Mac hostonly tests on any available arch (flutter/flutter#119762) * 322d10e 18118e10a Add iOS spring animation objc files (flutter/engine#38801) (flutter/flutter#119768) * f767f86 check if directory exists before listing content (flutter/flutter#119748) * 34730c7 Revert "Run Mac hostonly tests on any available arch (#119762)" (flutter/flutter#119784) * f9daa9a Roll Flutter Engine from 18118e10a0a5 to 679c4b42e222 (4 revisions) (flutter/flutter#119783) * fd76ef0 Reland "Add API for discovering assets" (flutter/flutter#119277) * ca0596e Fix `pub get --unknown-flag` (flutter/flutter#119622) * 9abb6d7 Roll Plugins from 9da327c to 9302d87 (11 revisions) (flutter/flutter#119825) * 9eafbcc Roll Flutter Engine from 679c4b42e222 to 388890a98e5b (6 revisions) (flutter/flutter#119830) * 1ee8799 Revert "[Re-land] Exposed tooltip longPress (#118796)" (flutter/flutter#119832) * 07b51a0 Add missing variants and *new* indicators to `useMaterial3` docs (flutter/flutter#119799) * 201380a e9e601c7c [web] Hide autofill overlay (flutter/engine#39294) (flutter/flutter#119833) * 1c0065c 27f55219d Roll Fuchsia Linux SDK from QxkjqmRgowkk_n2NZ... to pWloCaRzjLEAUvQEz... (flutter/engine#39339) (flutter/flutter#119838) * e7d934a Marks Linux_android android_choreographer_do_frame_test to be flaky (flutter/flutter#119721) * 3f986e4 Roll Flutter Engine from 27f55219df79 to ae38c9585a61 (2 revisions) (flutter/flutter#119840) * b0f1714 Make Flex,Row,Column const for real (flutter/flutter#119673) * d4b6898 [web] Put all index.html operations in one place (flutter/flutter#118188) * d63987f Parser machine logs (flutter/flutter#118707) * 22bbdf0 Android defines target update (flutter/flutter#119766) * 8387c23 [flutter_tools] Use base DAP detach and ensure correct output (flutter/flutter#119076) * d820aec Manual pub roll with dwds fix (flutter/flutter#119575) * 72f9cf5 Roll Flutter Engine from ae38c9585a61 to 616ecd8be3de (3 revisions) (flutter/flutter#119859) * cfdc358 roll packages (flutter/flutter#119865) * d875899 Bump test Chrome version for Mac arm support (flutter/flutter#119773) * 9b86a48 Fix gets removedItem instead of its index (flutter/flutter#119638) * 66b2ca6 Roll Flutter Engine from 616ecd8be3de to 2871970337df (3 revisions) (flutter/flutter#119870) * c626460 Make `_focusDebug` not interpolate in debug mode (flutter/flutter#119680) * a27802e flutter_tool: remove explicit length header in HTTP response (flutter/flutter#119869) * 3570cce Remove deprecated kind in GestureRecognizer et al (flutter/flutter#119572) * bc45b18 2696fff87 Roll Skia from c2d81db3ef41 to 4f0166baf5a4 (13 revisions) (flutter/engine#39348) (flutter/flutter#119879) * f3effce Roll Flutter Engine from 2696fff8716d to e3fe6dade964 (3 revisions) (flutter/flutter#119892) * 69421c1 [framework] use shader tiling instead of repeated calls to drawImage (flutter/flutter#119495) * 6b83eff Roll Flutter Engine from e3fe6dade964 to 655530e3fd15 (5 revisions) (flutter/flutter#119905) * a5d8a4a 67d35267c [Impeller] Use minimal coverage for stencil restores after overdraw prevention (flutter/engine#39358) (flutter/flutter#119910) * fc8ea56 0fb48ce5b Roll Dart SDK from 69452c5012d9 to be795cc64bd7 (1 revision) (flutter/engine#39360) (flutter/flutter#119926) * e0b2138 Dispose OverlayEntry in TooltipState. (flutter/flutter#117291) * c5e8757 Add M3 support for iconbuttons in error state in TextFields (flutter/flutter#119925)
#114548
Pre-launch Checklist
///).