Skip to content

Commit

Permalink
Adds package:litetest, uses it instead of package:test under testing/…
Browse files Browse the repository at this point in the history
…dart (flutter#26215)
  • Loading branch information
zanderso authored May 20, 2021
1 parent 67c537d commit dd24949
Show file tree
Hide file tree
Showing 45 changed files with 1,045 additions and 245 deletions.
9 changes: 9 additions & 0 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -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',

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

Expand All @@ -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': [
{
Expand Down
15 changes: 13 additions & 2 deletions ci/analyze.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down
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
Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions testing/dart/channel_buffers_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
22 changes: 9 additions & 13 deletions testing/dart/codec_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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 {
Expand All @@ -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'));
}
});

Expand Down Expand Up @@ -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
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions testing/dart/color_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)));
});

Expand Down
8 changes: 4 additions & 4 deletions testing/dart/compositing_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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', () {
Expand All @@ -28,7 +28,7 @@ void main() {
assert(() {
expect(
() => builder.pushTransform(matrix4WrongLength),
throwsA(const TypeMatcher<AssertionError>()),
expectAssertion,
);
return true;
}());
Expand All @@ -42,7 +42,7 @@ void main() {
assert(() {
expect(
() => builder.pushTransform(matrix4NaN),
throwsA(const TypeMatcher<AssertionError>()),
expectAssertion,
);
return true;
}());
Expand All @@ -56,7 +56,7 @@ void main() {
assert(() {
expect(
() => builder.pushTransform(matrix4Infinity),
throwsA(const TypeMatcher<AssertionError>()),
expectAssertion,
);
return true;
}());
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/dart_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/encoding_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions testing/dart/geometry_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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', () {
Expand Down Expand Up @@ -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', () {
Expand Down
4 changes: 2 additions & 2 deletions testing/dart/gradient_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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', () {
Expand Down Expand Up @@ -67,7 +67,7 @@ void main() {
Offset.zero,
1.0,
),
throwsA(const TypeMatcher<AssertionError>()),
expectAssertion,
);
return true;
}());
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/image_descriptor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/image_dispose_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions testing/dart/image_filter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion testing/dart/image_resize_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit dd24949

Please sign in to comment.