Skip to content
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

fix: fix test report in case of multiline test name #535

Merged
merged 4 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/src/cli/flutter_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,9 @@ Future<int> _flutterTest({

final timeElapsed = Duration(milliseconds: event.time).formatted();
final stats = computeStats();
final testName = test.name.truncated(
_lineLength - (timeElapsed.length + stats.length + 2),
);
final testName = test.name.toSingleLine().truncated(
_lineLength - (timeElapsed.length + stats.length + 2),
);
stdout('''$clearLine$timeElapsed $stats: $testName''');
}

Expand Down Expand Up @@ -496,6 +496,9 @@ extension on String {
final truncated = substring(length - maxLength, length).trim();
return '...$truncated';
}

String toSingleLine() =>
replaceAll('\n', '').replaceAll(RegExp(r'\s\s+'), ' ');
}

String? _getTraceLocation({
Expand Down
40 changes: 39 additions & 1 deletion test/fixtures/test_runner_fixtures.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,21 @@ const skipExceptionMessageJsonOuput = [
'type': 'testStart',
'time': 2757
},
{
'test': {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move this test after id: 28 so that they are in order? Also we should update the testDone event to have a different timestamp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @felangel for reviewing. Done

Copy link
Contributor Author

@agacemi agacemi Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear Reviewers @felangel @tomarra @erickzanardo @dewinjm , if you have a bit littre time to reviews my 4 PRs. We need them in our projet. Thank you in advance

'id': 29,
'name': '''this is the case of a multiline test name that should '''
''' be well processed by very_good test ''',
'suiteID': 4,
'groupIDs': [16],
'metadata': {'skip': false, 'skipReason': null},
'line': 4,
'column': 3,
'url': 'file:///my_app/test/counter/view/long_name_test.dart'
},
'type': 'testStart',
'time': 2757
felangel marked this conversation as resolved.
Show resolved Hide resolved
},
{
'testID': 15,
'result': 'success',
Expand Down Expand Up @@ -1401,5 +1416,28 @@ const skipExceptionMessageJsonOuput = [
'type': 'testDone',
'time': 4248
},
{'success': false, 'type': 'done', 'time': 4266},
{
'test': {
'id': 29,
'name': '''this is the case of a multiline test name that should '''
''' be well processed by very_good test ''',
'suiteID': 4,
'groupIDs': [16],
'metadata': {'skip': false, 'skipReason': null},
'line': 4,
'column': 3,
'url': 'file:///my_app/test/counter/view/multiline_test.dart'
},
'type': 'testStart',
'time': 5440
},
{
'testID': 29,
'result': 'success',
'skipped': false,
'hidden': false,
'type': 'testDone',
'time': 5449
},
{'success': false, 'type': 'done', 'time': 5466},
];
3 changes: 2 additions & 1 deletion test/src/cli/flutter_cli_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,8 @@ void main() {
'\x1B[2K\r00:04 +5 -1 ~2: CounterView renders current count',
'''\x1B[2K\r00:04 +6 -1 ~2: CounterView calls increment when increment button is tapped''',
'''\x1B[2K\r00:04 +7 -1 ~2: CounterView calls decrement when decrement button is tapped''',
'\x1B[2K\r00:04 +7 -1 ~2: Some tests failed.\n'
'''\x1B[2K\r00:05 +8 -1 ~2: ...tiline test name that should be well processed by very_good test''',
'\x1B[2K\r00:05 +8 -1 ~2: Some tests failed.\n'
]),
);
expect(
Expand Down