Skip to content

Commit c5050bc

Browse files
authored
Prepare for running tests on Windows (flutter#14112)
Seems like we don't yet run the flutter tests on Windows, but we're close to being able to. This makes some minor changes to make that more possible: - fix the stack parsing code to support Windows paths - fix the tests for the stack error handling code to handle Windows paths - skip some tests that rely on Ahem font metrics
1 parent 0efc8cd commit c5050bc

File tree

5 files changed

+25
-15
lines changed

5 files changed

+25
-15
lines changed

packages/flutter/lib/src/foundation/assertions.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ class FlutterError extends AssertionError {
361361
'_FakeAsync',
362362
'_FrameCallbackEntry',
363363
];
364-
final RegExp stackParser = new RegExp(r'^#[0-9]+ +([^.]+).* \(([^/]*)/.+:[0-9]+(?::[0-9]+)?\)$');
364+
final RegExp stackParser = new RegExp(r'^#[0-9]+ +([^.]+).* \(([^/\\]*)[/\\].+:[0-9]+(?::[0-9]+)?\)$');
365365
final RegExp packageParser = new RegExp(r'^([^:]+):(.+)$');
366366
final List<String> result = <String>[];
367367
final List<String> skipped = <String>[];

packages/flutter/test/foundation/error_reporting_test.dart

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// found in the LICENSE file.
44

55
import 'dart:async';
6+
import 'dart:io' show Platform;
67

78
import 'package:flutter/foundation.dart';
89
import 'package:test/test.dart';
@@ -43,6 +44,8 @@ Future<Null> main() async {
4344

4445
final StackTrace sampleStack = await getSampleStack();
4546

47+
final String divider = Platform.pathSeparator;
48+
4649
test('Error reporting - pretest', () async {
4750
expect(debugPrint, equals(debugPrintThrottled));
4851
debugPrint = (String message, { int wrapWidth }) {
@@ -66,18 +69,18 @@ Future<Null> main() async {
6669
'^══╡ EXCEPTION CAUGHT BY ERROR HANDLING TEST ╞═══════════════════════════════════════════════════════\n'
6770
'The following assertion was thrown testing the error handling logic:\n'
6871
'Message goes here\\.\n'
69-
'\'[^\']+flutter/test/foundation/error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\'\n'
72+
'\'[^\']+flutter${divider}test${divider}foundation${divider}error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\'\n'
7073
'\n'
7174
'Either the assertion indicates an error in the framework itself, or we should provide substantially '
7275
'more information in this error message to help you determine and fix the underlying cause\\.\n'
7376
'In either case, please report this assertion by filing a bug on GitHub:\n'
7477
' https://github\\.com/flutter/flutter/issues/new\n'
7578
'\n'
7679
'When the exception was thrown, this was the stack:\n'
77-
'#0 getSampleStack\\.<anonymous closure> \\([^)]+flutter/test/foundation/error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
78-
'#2 getSampleStack \\([^)]+flutter/test/foundation/error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
80+
'#0 getSampleStack\\.<anonymous closure> \\([^)]+flutter${divider}test${divider}foundation${divider}error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
81+
'#2 getSampleStack \\([^)]+flutter${divider}test${divider}foundation${divider}error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
7982
'<asynchronous suspension>\n' // TODO(ianh): https://github.com/flutter/flutter/issues/4021
80-
'#3 main \\([^)]+flutter/test/foundation/error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
83+
'#3 main \\([^)]+flutter${divider}test${divider}foundation${divider}error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
8184
'(.+\n)+' // TODO(ianh): when fixing #4021, also filter out frames from the test infrastructure below the first call to our main()
8285
'\\(elided [0-9]+ frames from package dart:async\\)\n'
8386
'\n'
@@ -107,7 +110,7 @@ Future<Null> main() async {
107110
'word word word word word word word word word word word word word word word word word word word word '
108111
'word word word word word word word word word word word word word word word word word word word word '
109112
'word word word word word word word word word word word word word word word word word word word word\n'
110-
'\'[^\']+flutter/test/foundation/error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\'\n'
113+
'\'[^\']+flutter${divider}test${divider}foundation${divider}error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\'\n'
111114
'\n'
112115
'Either the assertion indicates an error in the framework itself, or we should provide substantially '
113116
'more information in this error message to help you determine and fix the underlying cause\\.\n'
@@ -147,18 +150,18 @@ Future<Null> main() async {
147150
expect(console.join('\n'), matches(new RegExp(
148151
'^══╡ EXCEPTION CAUGHT BY ERROR HANDLING TEST ╞═══════════════════════════════════════════════════════\n'
149152
'The following assertion was thrown testing the error handling logic:\n'
150-
'\'[^\']+flutter/test/foundation/error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\': is not true\\.\n'
153+
'\'[^\']+flutter${divider}test${divider}foundation${divider}error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\': is not true\\.\n'
151154
'\n'
152155
'Either the assertion indicates an error in the framework itself, or we should provide substantially '
153156
'more information in this error message to help you determine and fix the underlying cause\\.\n'
154157
'In either case, please report this assertion by filing a bug on GitHub:\n'
155158
' https://github\\.com/flutter/flutter/issues/new\n'
156159
'\n'
157160
'When the exception was thrown, this was the stack:\n'
158-
'#0 getSampleStack\\.<anonymous closure> \\([^)]+flutter/test/foundation/error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
159-
'#2 getSampleStack \\([^)]+flutter/test/foundation/error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
161+
'#0 getSampleStack\\.<anonymous closure> \\([^)]+flutter${divider}test${divider}foundation${divider}error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
162+
'#2 getSampleStack \\([^)]+flutter${divider}test${divider}foundation${divider}error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
160163
'<asynchronous suspension>\n' // TODO(ianh): https://github.com/flutter/flutter/issues/4021
161-
'#3 main \\([^)]+flutter/test/foundation/error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
164+
'#3 main \\([^)]+flutter${divider}test${divider}foundation${divider}error_reporting_test\\.dart:[0-9]+:[0-9]+\\)\n'
162165
'(.+\n)+' // TODO(ianh): when fixing #4021, also filter out frames from the test infrastructure below the first call to our main()
163166
'\\(elided [0-9]+ frames from package dart:async\\)\n'
164167
'\n'
@@ -170,7 +173,7 @@ Future<Null> main() async {
170173
FlutterError.dumpErrorToConsole(new FlutterErrorDetails(
171174
exception: getAssertionErrorWithoutMessage(),
172175
));
173-
expect(console.join('\n'), matches('Another exception was thrown: \'[^\']+flutter/test/foundation/error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\': is not true\\.'));
176+
expect(console.join('\n'), matches('Another exception was thrown: \'[^\']+flutter${divider}test${divider}foundation${divider}error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\': is not true\\.'));
174177
console.clear();
175178
FlutterError.resetErrorCount();
176179
});

packages/flutter/test/foundation/stack_trace_test.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'dart:io';
6+
57
import 'package:flutter/foundation.dart';
68
import 'package:test/test.dart';
79

810
void main() {
911
// TODO(8128): These tests and the filtering mechanism should be revisited to account for causal async stack traces.
1012

13+
final String divider = Platform.pathSeparator;
14+
1115
test('FlutterError.defaultStackFilter', () {
1216
final List<String> filtered = FlutterError.defaultStackFilter(StackTrace.current.toString().trimRight().split('\n')).toList();
1317
expect(filtered.length, greaterThanOrEqualTo(4));
1418
expect(filtered[0], matches(r'^#0 +main\.<anonymous closure> \(.*stack_trace_test\.dart:[0-9]+:[0-9]+\)$'));
15-
expect(filtered[1], matches(r'^#1 +Declarer\.test\.<anonymous closure>.<anonymous closure> \(package:test/.+:[0-9]+:[0-9]+\)$'));
19+
expect(filtered[1], matches(r'^#1 +Declarer\.test\.<anonymous closure>.<anonymous closure> \(package:test' + divider + r'.+:[0-9]+:[0-9]+\)$'));
1620
expect(filtered[2], equals('<asynchronous suspension>'));
1721
expect(filtered.last, matches(r'^\(elided [1-9][0-9]+ frames from package dart:async, package dart:async-patch, and package stack_trace\)$'));
1822
});

packages/flutter/test/painting/text_painter_rtl_test.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'dart:io';
6+
57
import 'package:flutter/foundation.dart';
68
import 'package:flutter/painting.dart';
79
import 'package:flutter_test/flutter_test.dart';
@@ -317,7 +319,7 @@ void main() {
317319
const TextBox.fromLTRBD(0.0, 10.0, 10.0, 20.0, TextDirection.rtl), // Alef
318320
],
319321
);
320-
});
322+
}, skip: Platform.isWindows); // Ahem-based tests don't yet quite work on Windows
321323

322324
test('TextPainter - line wrap mid-word', () {
323325
final TextPainter painter = new TextPainter()

packages/flutter/test/rendering/paragraph_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'dart:io';
56
import 'dart:ui' as ui show TextBox;
67

78
import 'package:flutter/rendering.dart';
@@ -68,7 +69,7 @@ void main() {
6869

6970
expect(boxes.any((ui.TextBox box) => box.left == 250 && box.top == 0), isTrue);
7071
expect(boxes.any((ui.TextBox box) => box.right == 100 && box.top == 10), isTrue);
71-
});
72+
}, skip: Platform.isWindows); // Ahem-based tests don't yet quite work on Windows
7273

7374
test('getWordBoundary control test', () {
7475
final RenderParagraph paragraph = new RenderParagraph(
@@ -190,7 +191,7 @@ void main() {
190191

191192
layoutAt(3);
192193
expect(paragraph.size.height, 30.0);
193-
});
194+
}, skip: Platform.isWindows); // Ahem-based tests don't yet quite work on Windows
194195

195196
test('changing color does not do layout', () {
196197
final RenderParagraph paragraph = new RenderParagraph(

0 commit comments

Comments
 (0)