Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit dd24949

Browse files
authored
Adds package:litetest, uses it instead of package:test under testing/dart (#26215)
1 parent 67c537d commit dd24949

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1045
-245
lines changed

DEPS

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,12 @@ deps = {
401401
'src/third_party/pkg/file':
402402
Var('github_git') + '/google/file.dart.git' + '@' + '427bb20ccc852425d67f2880da2a9b4707c266b4', # 6.1.0
403403

404+
'src/third_party/pkg/image':
405+
Var('github_git') + '/brendan-duncan/image.git' + '@' + '3.0.2',
406+
407+
'src/third_party/pkg/petitparser':
408+
Var('github_git') + '/petitparser/dart-petitparser' + '@' + '4.1.0',
409+
404410
'src/third_party/pkg/platform':
405411
Var('github_git') + '/google/platform.dart.git' + '@' + 'f63fd0bc3021354a0687dc935962c9acc003f47e', # 3.0.1
406412

@@ -410,6 +416,9 @@ deps = {
410416
'src/third_party/pkg/when':
411417
Var('dart_git') + '/when.git' + '@' + '0.2.0',
412418

419+
'src/third_party/pkg/xml':
420+
Var('github_git') + '/renggli/dart-xml' + '@' + '22a9e95c07c51429da368301047ffeba945b72a7', # 5.1.0
421+
413422
'src/third_party/android_tools/ndk': {
414423
'packages': [
415424
{

ci/analyze.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,27 @@ analyze \
7171
"$FLUTTER_DIR/flutter_frontend_server"
7272

7373
echo "Analyzing tools/licenses..."
74-
(cd "$FLUTTER_DIR/tools/licenses" && "$PUB" get)
7574
analyze \
7675
--packages="$FLUTTER_DIR/tools/licenses/.dart_tool/package_config.json" \
7776
--options "$FLUTTER_DIR/tools/licenses/analysis_options.yaml" \
7877
"$FLUTTER_DIR/tools/licenses"
7978

79+
echo "Analyzing testing/litetest"
80+
analyze \
81+
--packages="$FLUTTER_DIR/testing/litetest/.dart_tool/package_config.json" \
82+
--options "$FLUTTER_DIR/analysis_options.yaml" \
83+
"$FLUTTER_DIR/testing/litetest"
84+
85+
echo "Analyzing testing/smoke_test_failure"
86+
analyze \
87+
--packages="$FLUTTER_DIR/testing/smoke_test_failure/.dart_tool/package_config.json" \
88+
--options "$FLUTTER_DIR/analysis_options.yaml" \
89+
"$FLUTTER_DIR/testing/smoke_test_failure"
90+
8091
echo "Analyzing testing/dart..."
8192
"$FLUTTER_DIR/tools/gn" --unoptimized
8293
autoninja -C "$SRC_DIR/out/host_debug_unopt" sky_engine sky_services
83-
(cd "$FLUTTER_DIR/testing/dart" && "$PUB" get)
94+
(cd "$FLUTTER_DIR/testing/dart" && "$PUB" get --offline)
8495
analyze \
8596
--packages="$FLUTTER_DIR/testing/dart/.dart_tool/package_config.json" \
8697
--options "$FLUTTER_DIR/analysis_options.yaml" \

ci/licenses_golden/tool_signature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Signature: 7af516b6fef310e37406f37cc6da30ae
1+
Signature: 469fde92656a4a5e122b7601271cf2cb
22

testing/dart/canvas_test.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ import 'dart:async';
77
import 'dart:io';
88
import 'dart:typed_data';
99
import 'dart:ui';
10-
import 'package:image/image.dart' as dart_image;
1110

11+
import 'package:image/image.dart' as dart_image;
12+
import 'package:litetest/litetest.dart';
1213
import 'package:path/path.dart' as path;
13-
import 'package:test/test.dart';
14-
15-
import 'test_util.dart';
1614

1715
typedef CanvasCallback = void Function(Canvas canvas);
1816

testing/dart/channel_buffers_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'dart:convert';
1111
import 'dart:typed_data';
1212
import 'dart:ui' as ui;
1313

14-
import 'package:test/test.dart';
14+
import 'package:litetest/litetest.dart';
1515

1616
ByteData _makeByteData(String str) {
1717
final Uint8List list = utf8.encode(str) as Uint8List;
@@ -160,7 +160,7 @@ void main() {
160160
didCallCallback = true;
161161
}
162162
void twoCallback(ByteData responseData) {
163-
throw TestFailure('wrong callback called');
163+
fail('wrong callback called');
164164
}
165165
_resize(buffers, channel, 100);
166166
buffers.push(channel, one, oneCallback);
@@ -181,7 +181,7 @@ void main() {
181181
didCallCallback = true;
182182
}
183183
void twoCallback(ByteData responseData) {
184-
throw TestFailure('wrong callback called');
184+
fail('wrong callback called');
185185
}
186186
_resize(buffers, channel, 1);
187187
buffers.push(channel, one, oneCallback);

testing/dart/codec_test.dart

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'dart:io';
77
import 'dart:typed_data';
88
import 'dart:ui' as ui;
99

10-
import 'package:test/test.dart';
10+
import 'package:litetest/litetest.dart';
1111
import 'package:path/path.dart' as path;
1212

1313
void main() {
@@ -28,10 +28,12 @@ void main() {
2828

2929
test('Fails with invalid data', () async {
3030
final Uint8List data = Uint8List.fromList(<int>[1, 2, 3]);
31-
expect(
32-
() => ui.instantiateImageCodec(data),
33-
throwsA(exceptionWithMessage('Invalid image data'))
34-
);
31+
try {
32+
await ui.instantiateImageCodec(data);
33+
fail('exception not thrown');
34+
} on Exception catch (e) {
35+
expect(e.toString(), contains('Invalid image data'));
36+
}
3537
});
3638

3739
test('getNextFrame fails with invalid data', () async {
@@ -41,8 +43,8 @@ void main() {
4143
try {
4244
await codec.getNextFrame();
4345
fail('exception not thrown');
44-
} catch(e) {
45-
expect(e, exceptionWithMessage('Codec failed'));
46+
} on Exception catch (e) {
47+
expect(e.toString(), contains('Codec failed'));
4648
}
4749
});
4850

@@ -97,9 +99,3 @@ File _getSkiaResource(String fileName) {
9799
path.join('third_party', 'skia', 'resources', 'images', fileName);
98100
return File(assetPath);
99101
}
100-
101-
Matcher exceptionWithMessage(String m) {
102-
return predicate<Exception>((Exception e) {
103-
return e is Exception && e.toString().contains(m);
104-
});
105-
}

testing/dart/color_filter_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import 'dart:typed_data';
77
import 'dart:ui';
88

9-
import 'package:test/test.dart';
9+
import 'package:litetest/litetest.dart';
1010

1111
const Color red = Color(0xFFAA0000);
1212
const Color green = Color(0xFF00AA00);

testing/dart/color_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// @dart = 2.6
66
import 'dart:ui';
77

8-
import 'package:test/test.dart';
8+
import 'package:litetest/litetest.dart';
99

1010
class NotAColor extends Color {
1111
const NotAColor(int value) : super(value);
@@ -50,9 +50,9 @@ void main() {
5050
test('two colors are only == if they have the same runtime type', () {
5151
expect(const Color(0x12345678), equals(const Color(0x12345678)));
5252
expect(const Color(0x12345678), equals(Color(0x12345678))); // ignore: prefer_const_constructors
53-
expect(const Color(0x12345678), isNot(equals(const Color(0x87654321))));
54-
expect(const Color(0x12345678), isNot(equals(const NotAColor(0x12345678))));
55-
expect(const NotAColor(0x12345678), isNot(equals(const Color(0x12345678))));
53+
expect(const Color(0x12345678), notEquals(const Color(0x87654321)));
54+
expect(const Color(0x12345678), notEquals(const NotAColor(0x12345678)));
55+
expect(const NotAColor(0x12345678), notEquals(const Color(0x12345678)));
5656
expect(const NotAColor(0x12345678), equals(const NotAColor(0x12345678)));
5757
});
5858

testing/dart/compositing_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import 'dart:typed_data' show Float64List;
77
import 'dart:ui';
88

9-
import 'package:test/test.dart';
9+
import 'package:litetest/litetest.dart';
1010

1111
void main() {
1212
test('pushTransform validates the matrix', () {
@@ -28,7 +28,7 @@ void main() {
2828
assert(() {
2929
expect(
3030
() => builder.pushTransform(matrix4WrongLength),
31-
throwsA(const TypeMatcher<AssertionError>()),
31+
expectAssertion,
3232
);
3333
return true;
3434
}());
@@ -42,7 +42,7 @@ void main() {
4242
assert(() {
4343
expect(
4444
() => builder.pushTransform(matrix4NaN),
45-
throwsA(const TypeMatcher<AssertionError>()),
45+
expectAssertion,
4646
);
4747
return true;
4848
}());
@@ -56,7 +56,7 @@ void main() {
5656
assert(() {
5757
expect(
5858
() => builder.pushTransform(matrix4Infinity),
59-
throwsA(const TypeMatcher<AssertionError>()),
59+
expectAssertion,
6060
);
6161
return true;
6262
}());

testing/dart/dart_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// @dart = 2.6
66
import 'dart:async';
77

8-
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
8+
import 'package:litetest/litetest.dart';
99

1010
/// Verifies Dart semantics governed by flags set by Flutter tooling.
1111
void main() {

testing/dart/encoding_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import 'dart:io';
88
import 'dart:typed_data';
99
import 'dart:ui';
1010

11+
import 'package:litetest/litetest.dart';
1112
import 'package:path/path.dart' as path;
12-
import 'package:test/test.dart';
1313

1414
const int _kWidth = 10;
1515
const int _kRadius = 2;

testing/dart/geometry_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'dart:math' as math show sqrt;
77
import 'dart:math' show pi;
88
import 'dart:ui';
99

10-
import 'package:test/test.dart';
10+
import 'package:litetest/litetest.dart';
1111

1212
void main() {
1313
group('Offset', () {
@@ -46,8 +46,8 @@ void main() {
4646

4747
test('OffsetBase.==', () {
4848
expect(const Offset(0, 0), equals(const Offset(0, 0)));
49-
expect(const Offset(0, 0), isNot(equals(const Offset(1, 0))));
50-
expect(const Offset(0, 0), isNot(equals(const Offset(0, 1))));
49+
expect(const Offset(0, 0), notEquals(const Offset(1, 0)));
50+
expect(const Offset(0, 0), notEquals(const Offset(0, 1)));
5151
});
5252

5353
test('Offset.direction', () {

testing/dart/gradient_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// @dart = 2.6
66
import 'dart:ui';
77

8-
import 'package:test/test.dart';
8+
import 'package:litetest/litetest.dart';
99

1010
void main() {
1111
test('Gradient.radial with no focal point', () {
@@ -67,7 +67,7 @@ void main() {
6767
Offset.zero,
6868
1.0,
6969
),
70-
throwsA(const TypeMatcher<AssertionError>()),
70+
expectAssertion,
7171
);
7272
return true;
7373
}());

testing/dart/image_descriptor_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import 'dart:io';
88
import 'dart:typed_data';
99
import 'dart:ui';
1010

11+
import 'package:litetest/litetest.dart';
1112
import 'package:path/path.dart' as path;
12-
import 'package:test/test.dart';
1313

1414
void main() {
1515
test('basic image descriptor - encoded - greyscale', () async {

testing/dart/image_dispose_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import 'dart:io';
77
import 'dart:typed_data';
88
import 'dart:ui';
99

10+
import 'package:litetest/litetest.dart';
1011
import 'package:path/path.dart' as path;
11-
import 'package:test/test.dart';
1212

1313
void main() {
1414
bool assertsEnabled = false;

testing/dart/image_filter_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import 'dart:typed_data';
77
import 'dart:ui';
88

9-
import 'package:test/test.dart';
9+
import 'package:litetest/litetest.dart';
1010

1111
const Color red = Color(0xFFAA0000);
1212
const Color green = Color(0xFF00AA00);
@@ -127,9 +127,9 @@ void main() {
127127
expect(a[i].hashCode, equals(b[j].hashCode));
128128
expect(a[i].toString(), equals(b[j].toString()));
129129
} else {
130-
expect(a[i], isNot(b[j]));
130+
expect(a[i], notEquals(b[j]));
131131
// No expectations on hashCode if objects are not equal
132-
expect(a[i].toString(), isNot(b[j].toString()));
132+
expect(a[i].toString(), notEquals(b[j].toString()));
133133
}
134134
}
135135
}

testing/dart/image_resize_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import 'dart:io';
88
import 'dart:typed_data';
99
import 'dart:ui';
1010

11+
import 'package:litetest/litetest.dart';
1112
import 'package:path/path.dart' as path;
12-
import 'package:test/test.dart';
1313

1414
void main() {
1515
bool assertsEnabled = false;

0 commit comments

Comments
 (0)