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

Adds package:litetest, uses it instead of package:test under testing/dart #26215

Merged
merged 1 commit into from
May 20, 2021
Merged
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: 9 additions & 0 deletions DEPS
Original file line number Diff line number Diff line change
@@ -401,6 +401,12 @@ deps = {
'src/third_party/pkg/file':
Var('github_git') + '/google/file.dart.git' + '@' + '427bb20ccc852425d67f2880da2a9b4707c266b4', # 6.1.0

'src/third_party/pkg/image':
Var('github_git') + '/brendan-duncan/image.git' + '@' + '3.0.2',

'src/third_party/pkg/petitparser':
Var('github_git') + '/petitparser/dart-petitparser' + '@' + '4.1.0',
Comment on lines +404 to +408
Copy link
Contributor

Choose a reason for hiding this comment

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

These dependencies (and XML) could be painful to upgrade, which we'll eventually want to do. Can we just get rid of them?

It looks like we only use this to encode and write a PNG image. We should be able to do that via dart:ui.

Copy link
Contributor

Choose a reason for hiding this comment

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

(This, of course, should be done in a separate PR, and I'm not terribly partial to whether it's done before or after this one lands)

Copy link
Contributor

Choose a reason for hiding this comment

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

Filed

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, in this PR, I think I should leave the test logic as-is, but I am totally on board with cutting down on the dependencies.


'src/third_party/pkg/platform':
Var('github_git') + '/google/platform.dart.git' + '@' + 'f63fd0bc3021354a0687dc935962c9acc003f47e', # 3.0.1

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

'src/third_party/pkg/xml':
Var('github_git') + '/renggli/dart-xml' + '@' + '22a9e95c07c51429da368301047ffeba945b72a7', # 5.1.0

'src/third_party/android_tools/ndk': {
'packages': [
{
15 changes: 13 additions & 2 deletions ci/analyze.sh
Original file line number Diff line number Diff line change
@@ -71,16 +71,27 @@ analyze \
"$FLUTTER_DIR/flutter_frontend_server"

echo "Analyzing tools/licenses..."
(cd "$FLUTTER_DIR/tools/licenses" && "$PUB" get)
analyze \
--packages="$FLUTTER_DIR/tools/licenses/.dart_tool/package_config.json" \
--options "$FLUTTER_DIR/tools/licenses/analysis_options.yaml" \
"$FLUTTER_DIR/tools/licenses"

echo "Analyzing testing/litetest"
analyze \
--packages="$FLUTTER_DIR/testing/litetest/.dart_tool/package_config.json" \
--options "$FLUTTER_DIR/analysis_options.yaml" \
"$FLUTTER_DIR/testing/litetest"

echo "Analyzing testing/smoke_test_failure"
analyze \
--packages="$FLUTTER_DIR/testing/smoke_test_failure/.dart_tool/package_config.json" \
--options "$FLUTTER_DIR/analysis_options.yaml" \
"$FLUTTER_DIR/testing/smoke_test_failure"

echo "Analyzing testing/dart..."
"$FLUTTER_DIR/tools/gn" --unoptimized
autoninja -C "$SRC_DIR/out/host_debug_unopt" sky_engine sky_services
(cd "$FLUTTER_DIR/testing/dart" && "$PUB" get)
(cd "$FLUTTER_DIR/testing/dart" && "$PUB" get --offline)
analyze \
--packages="$FLUTTER_DIR/testing/dart/.dart_tool/package_config.json" \
--options "$FLUTTER_DIR/analysis_options.yaml" \
2 changes: 1 addition & 1 deletion ci/licenses_golden/tool_signature
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Signature: 7af516b6fef310e37406f37cc6da30ae
Signature: 469fde92656a4a5e122b7601271cf2cb

6 changes: 2 additions & 4 deletions testing/dart/canvas_test.dart
Original file line number Diff line number Diff line change
@@ -7,12 +7,10 @@ import 'dart:async';
import 'dart:io';
import 'dart:typed_data';
import 'dart:ui';
import 'package:image/image.dart' as dart_image;

import 'package:image/image.dart' as dart_image;
import 'package:litetest/litetest.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

import 'test_util.dart';

typedef CanvasCallback = void Function(Canvas canvas);

6 changes: 3 additions & 3 deletions testing/dart/channel_buffers_test.dart
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import 'dart:convert';
import 'dart:typed_data';
import 'dart:ui' as ui;

import 'package:test/test.dart';
import 'package:litetest/litetest.dart';

ByteData _makeByteData(String str) {
final Uint8List list = utf8.encode(str) as Uint8List;
@@ -160,7 +160,7 @@ void main() {
didCallCallback = true;
}
void twoCallback(ByteData responseData) {
throw TestFailure('wrong callback called');
fail('wrong callback called');
}
_resize(buffers, channel, 100);
buffers.push(channel, one, oneCallback);
@@ -181,7 +181,7 @@ void main() {
didCallCallback = true;
}
void twoCallback(ByteData responseData) {
throw TestFailure('wrong callback called');
fail('wrong callback called');
}
_resize(buffers, channel, 1);
buffers.push(channel, one, oneCallback);
22 changes: 9 additions & 13 deletions testing/dart/codec_test.dart
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import 'dart:io';
import 'dart:typed_data';
import 'dart:ui' as ui;

import 'package:test/test.dart';
import 'package:litetest/litetest.dart';
import 'package:path/path.dart' as path;

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

test('Fails with invalid data', () async {
final Uint8List data = Uint8List.fromList(<int>[1, 2, 3]);
expect(
() => ui.instantiateImageCodec(data),
throwsA(exceptionWithMessage('Invalid image data'))
);
try {
await ui.instantiateImageCodec(data);
fail('exception not thrown');
} on Exception catch (e) {
expect(e.toString(), contains('Invalid image data'));
}
});

test('getNextFrame fails with invalid data', () async {
@@ -41,8 +43,8 @@ void main() {
try {
await codec.getNextFrame();
fail('exception not thrown');
} catch(e) {
expect(e, exceptionWithMessage('Codec failed'));
} on Exception catch (e) {
expect(e.toString(), contains('Codec failed'));
}
});

@@ -97,9 +99,3 @@ File _getSkiaResource(String fileName) {
path.join('third_party', 'skia', 'resources', 'images', fileName);
return File(assetPath);
}

Matcher exceptionWithMessage(String m) {
return predicate<Exception>((Exception e) {
return e is Exception && e.toString().contains(m);
});
}
2 changes: 1 addition & 1 deletion testing/dart/color_filter_test.dart
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
import 'dart:typed_data';
import 'dart:ui';

import 'package:test/test.dart';
import 'package:litetest/litetest.dart';

const Color red = Color(0xFFAA0000);
const Color green = Color(0xFF00AA00);
8 changes: 4 additions & 4 deletions testing/dart/color_test.dart
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
// @dart = 2.6
import 'dart:ui';

import 'package:test/test.dart';
import 'package:litetest/litetest.dart';

class NotAColor extends Color {
const NotAColor(int value) : super(value);
@@ -50,9 +50,9 @@ void main() {
test('two colors are only == if they have the same runtime type', () {
expect(const Color(0x12345678), equals(const Color(0x12345678)));
expect(const Color(0x12345678), equals(Color(0x12345678))); // ignore: prefer_const_constructors
expect(const Color(0x12345678), isNot(equals(const Color(0x87654321))));
expect(const Color(0x12345678), isNot(equals(const NotAColor(0x12345678))));
expect(const NotAColor(0x12345678), isNot(equals(const Color(0x12345678))));
expect(const Color(0x12345678), notEquals(const Color(0x87654321)));
expect(const Color(0x12345678), notEquals(const NotAColor(0x12345678)));
expect(const NotAColor(0x12345678), notEquals(const Color(0x12345678)));
expect(const NotAColor(0x12345678), equals(const NotAColor(0x12345678)));
Comment on lines 51 to 56
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, I'm not a fan of these kind of matchers anyway. I'd much rather just see expect(Color(...) == Color(...), true);, or even just make the second parameter to expect optional so that it more or less workslike assert.

That said, I like notEquals better than isNot(somethingElse(isNot(......

});

8 changes: 4 additions & 4 deletions testing/dart/compositing_test.dart
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
import 'dart:typed_data' show Float64List;
import 'dart:ui';

import 'package:test/test.dart';
import 'package:litetest/litetest.dart';

void main() {
test('pushTransform validates the matrix', () {
@@ -28,7 +28,7 @@ void main() {
assert(() {
expect(
() => builder.pushTransform(matrix4WrongLength),
throwsA(const TypeMatcher<AssertionError>()),
expectAssertion,
);
return true;
}());
@@ -42,7 +42,7 @@ void main() {
assert(() {
expect(
() => builder.pushTransform(matrix4NaN),
throwsA(const TypeMatcher<AssertionError>()),
expectAssertion,
);
return true;
}());
@@ -56,7 +56,7 @@ void main() {
assert(() {
expect(
() => builder.pushTransform(matrix4Infinity),
throwsA(const TypeMatcher<AssertionError>()),
expectAssertion,
);
return true;
}());
2 changes: 1 addition & 1 deletion testing/dart/dart_test.dart
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
// @dart = 2.6
import 'dart:async';

import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
import 'package:litetest/litetest.dart';

/// Verifies Dart semantics governed by flags set by Flutter tooling.
void main() {
2 changes: 1 addition & 1 deletion testing/dart/encoding_test.dart
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@ import 'dart:io';
import 'dart:typed_data';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

const int _kWidth = 10;
const int _kRadius = 2;
6 changes: 3 additions & 3 deletions testing/dart/geometry_test.dart
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import 'dart:math' as math show sqrt;
import 'dart:math' show pi;
import 'dart:ui';

import 'package:test/test.dart';
import 'package:litetest/litetest.dart';

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

test('OffsetBase.==', () {
expect(const Offset(0, 0), equals(const Offset(0, 0)));
expect(const Offset(0, 0), isNot(equals(const Offset(1, 0))));
expect(const Offset(0, 0), isNot(equals(const Offset(0, 1))));
expect(const Offset(0, 0), notEquals(const Offset(1, 0)));
expect(const Offset(0, 0), notEquals(const Offset(0, 1)));
});

test('Offset.direction', () {
4 changes: 2 additions & 2 deletions testing/dart/gradient_test.dart
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
// @dart = 2.6
import 'dart:ui';

import 'package:test/test.dart';
import 'package:litetest/litetest.dart';

void main() {
test('Gradient.radial with no focal point', () {
@@ -67,7 +67,7 @@ void main() {
Offset.zero,
1.0,
),
throwsA(const TypeMatcher<AssertionError>()),
expectAssertion,
);
return true;
}());
2 changes: 1 addition & 1 deletion testing/dart/image_descriptor_test.dart
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@ import 'dart:io';
import 'dart:typed_data';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

void main() {
test('basic image descriptor - encoded - greyscale', () async {
2 changes: 1 addition & 1 deletion testing/dart/image_dispose_test.dart
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ import 'dart:io';
import 'dart:typed_data';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

void main() {
bool assertsEnabled = false;
6 changes: 3 additions & 3 deletions testing/dart/image_filter_test.dart
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
import 'dart:typed_data';
import 'dart:ui';

import 'package:test/test.dart';
import 'package:litetest/litetest.dart';

const Color red = Color(0xFFAA0000);
const Color green = Color(0xFF00AA00);
@@ -127,9 +127,9 @@ void main() {
expect(a[i].hashCode, equals(b[j].hashCode));
expect(a[i].toString(), equals(b[j].toString()));
} else {
expect(a[i], isNot(b[j]));
expect(a[i], notEquals(b[j]));
// No expectations on hashCode if objects are not equal
expect(a[i].toString(), isNot(b[j].toString()));
expect(a[i].toString(), notEquals(b[j].toString()));
}
}
}
2 changes: 1 addition & 1 deletion testing/dart/image_resize_test.dart
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@ import 'dart:io';
import 'dart:typed_data';
import 'dart:ui';

import 'package:litetest/litetest.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';

void main() {
bool assertsEnabled = false;
Loading