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

Commit c5195ea

Browse files
authored
Use package:litetest for flutter_frontend_server (#26341)
1 parent df1adb3 commit c5195ea

File tree

3 files changed

+73
-115
lines changed

3 files changed

+73
-115
lines changed

flutter_frontend_server/pubspec.yaml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Copyright 2013 The Flutter Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
15
name: flutter_frontend_server
26
publish_to: none
37
version: 0.1.1-dev
@@ -6,8 +10,9 @@ homepage: https://flutter.dev
610
author: Flutter Authors <[email protected]>
711

812
# Do not add any dependencies that require more than what is provided in
9-
# //third_party/dart/pkg or //third_party/dart/third_party/pkg.
10-
# In particular, package:test is not usable here.
13+
# //third_party/pkg, //third_party/dart/pkg or
14+
# //third_party/dart/third_party/pkg. In particular, package:test is not usable
15+
# here.
1116

1217
# If you do add packages here, make sure you can run `pub get --offline`, and
1318
# check the .packages and .package_config to make sure all the paths are
@@ -35,6 +40,9 @@ dependencies:
3540
usage: any
3641
vm: any
3742

43+
dev_dependencies:
44+
litetest: any
45+
3846
dependency_overrides:
3947
_fe_analyzer_shared:
4048
path: ../../third_party/dart/pkg/_fe_analyzer_shared
@@ -44,6 +52,8 @@ dependency_overrides:
4452
path: ../../third_party/dart/third_party/pkg/args
4553
async:
4654
path: ../../third_party/dart/third_party/pkg/async
55+
async_helper:
56+
path: ../../third_party/dart/pkg/async_helper
4757
bazel_worker:
4858
path: ../../third_party/dart/third_party/pkg/bazel_worker
4959
build_integration:
@@ -60,6 +70,8 @@ dependency_overrides:
6070
path: ../../third_party/dart/third_party/pkg/crypto
6171
dev_compiler:
6272
path: ../../third_party/dart/pkg/dev_compiler
73+
expect:
74+
path: ../../third_party/dart/pkg/expect
6375
fixnum:
6476
path: ../../third_party/dart/third_party/pkg/fixnum
6577
front_end:
@@ -68,6 +80,8 @@ dependency_overrides:
6880
path: ../../third_party/dart/pkg/frontend_server
6981
kernel:
7082
path: ../../third_party/dart/pkg/kernel
83+
litetest:
84+
path: ../testing/litetest
7185
logging:
7286
path: ../../third_party/dart/third_party/pkg/logging
7387
matcher:

flutter_frontend_server/test/to_string_test.dart

Lines changed: 57 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -4,95 +4,78 @@
44

55
import 'dart:io';
66

7+
import 'package:litetest/litetest.dart';
78
import 'package:path/path.dart' as path;
89

9-
import 'utils.dart';
10-
1110
Future<void> main(List<String> args) async {
1211
if (args.length != 2) {
1312
stderr.writeln('The first argument must be the path to the frontend server dill.');
1413
stderr.writeln('The second argument must be the path to the flutter_patched_sdk');
1514
exit(-1);
1615
}
1716

18-
group('Integration tests', () {
19-
final String dart = Platform.resolvedExecutable;
20-
final String frontendServer = args[0];
21-
final String sdkRoot = args[1];
22-
final String basePath = path.canonicalize(path.join(path.dirname(Platform.script.path), '..'));
23-
final String fixtures = path.join(basePath, 'test', 'fixtures');
24-
final String mainDart = path.join(fixtures, 'lib', 'main.dart');
25-
final String packageConfig = path.join(fixtures, '.dart_tool', 'package_config.json');
26-
final String regularDill = path.join(fixtures, 'toString.dill');
27-
final String transformedDill = path.join(fixtures, 'toStringTransformed.dill');
17+
final String dart = Platform.resolvedExecutable;
18+
final String frontendServer = args[0];
19+
final String sdkRoot = args[1];
20+
final String basePath = path.canonicalize(path.join(path.dirname(Platform.script.path), '..'));
21+
final String fixtures = path.join(basePath, 'test', 'fixtures');
22+
final String mainDart = path.join(fixtures, 'lib', 'main.dart');
23+
final String packageConfig = path.join(fixtures, '.dart_tool', 'package_config.json');
24+
final String regularDill = path.join(fixtures, 'toString.dill');
25+
final String transformedDill = path.join(fixtures, 'toStringTransformed.dill');
2826

2927

30-
void _checkProcessResult(ProcessResult result) {
31-
if (result.exitCode != 0) {
32-
stdout.writeln(result.stdout);
33-
stderr.writeln(result.stderr);
34-
}
35-
expect(result.exitCode == 0, 'Expected result.exitCode to be 0');
28+
void _checkProcessResult(ProcessResult result) {
29+
if (result.exitCode != 0) {
30+
stdout.writeln(result.stdout);
31+
stderr.writeln(result.stderr);
3632
}
33+
expect(result.exitCode, 0);
34+
}
3735

38-
test('Without flag', () {
39-
_checkProcessResult(Process.runSync(dart, <String>[
40-
frontendServer,
41-
'--sdk-root=$sdkRoot',
42-
'--target=flutter',
43-
'--packages=$packageConfig',
44-
'--output-dill=$regularDill',
45-
mainDart,
46-
]));
47-
final ProcessResult runResult = Process.runSync(dart, <String>[regularDill]);
48-
_checkProcessResult(runResult);
49-
String paintString = '"Paint.toString":"Paint(Color(0xffffffff))"';
50-
if (const bool.fromEnvironment('dart.vm.product', defaultValue: false)) {
51-
paintString = '"Paint.toString":"Instance of \'Paint\'"';
52-
}
36+
test('Without flag', () {
37+
_checkProcessResult(Process.runSync(dart, <String>[
38+
frontendServer,
39+
'--sdk-root=$sdkRoot',
40+
'--target=flutter',
41+
'--packages=$packageConfig',
42+
'--output-dill=$regularDill',
43+
mainDart,
44+
]));
45+
final ProcessResult runResult = Process.runSync(dart, <String>[regularDill]);
46+
_checkProcessResult(runResult);
47+
String paintString = '"Paint.toString":"Paint(Color(0xffffffff))"';
48+
if (const bool.fromEnvironment('dart.vm.product', defaultValue: false)) {
49+
paintString = '"Paint.toString":"Instance of \'Paint\'"';
50+
}
5351

54-
final String expectedStdout = '{$paintString,'
55-
'"Brightness.toString":"Brightness.dark",'
56-
'"Foo.toString":"I am a Foo",'
57-
'"Keep.toString":"I am a Keep"}';
58-
final String actualStdout = runResult.stdout.trim() as String;
59-
expect(
60-
actualStdout == expectedStdout,
61-
'Expected "$expectedStdout" but got "$actualStdout"',
62-
);
63-
});
52+
final String expectedStdout = '{$paintString,'
53+
'"Brightness.toString":"Brightness.dark",'
54+
'"Foo.toString":"I am a Foo",'
55+
'"Keep.toString":"I am a Keep"}';
56+
final String actualStdout = runResult.stdout.trim() as String;
57+
expect(actualStdout, equals(expectedStdout));
58+
});
6459

65-
test('With flag', () {
66-
_checkProcessResult(Process.runSync(dart, <String>[
67-
frontendServer,
68-
'--sdk-root=$sdkRoot',
69-
'--target=flutter',
70-
'--packages=$packageConfig',
71-
'--output-dill=$transformedDill',
72-
'--delete-tostring-package-uri', 'dart:ui',
73-
'--delete-tostring-package-uri', 'package:flutter_frontend_fixtures',
74-
mainDart,
75-
]));
76-
final ProcessResult runResult = Process.runSync(dart, <String>[transformedDill]);
77-
_checkProcessResult(runResult);
60+
test('With flag', () {
61+
_checkProcessResult(Process.runSync(dart, <String>[
62+
frontendServer,
63+
'--sdk-root=$sdkRoot',
64+
'--target=flutter',
65+
'--packages=$packageConfig',
66+
'--output-dill=$transformedDill',
67+
'--delete-tostring-package-uri', 'dart:ui',
68+
'--delete-tostring-package-uri', 'package:flutter_frontend_fixtures',
69+
mainDart,
70+
]));
71+
final ProcessResult runResult = Process.runSync(dart, <String>[transformedDill]);
72+
_checkProcessResult(runResult);
7873

79-
const String expectedStdout = '{"Paint.toString":"Instance of \'Paint\'",'
80-
'"Brightness.toString":"Brightness.dark",'
81-
'"Foo.toString":"Instance of \'Foo\'",'
82-
'"Keep.toString":"I am a Keep"}';
83-
final String actualStdout = runResult.stdout.trim() as String;
84-
expect(
85-
actualStdout == expectedStdout,
86-
'Expected "$expectedStdout" but got "$actualStdout"',
87-
);
88-
});
74+
const String expectedStdout = '{"Paint.toString":"Instance of \'Paint\'",'
75+
'"Brightness.toString":"Brightness.dark",'
76+
'"Foo.toString":"Instance of \'Foo\'",'
77+
'"Keep.toString":"I am a Keep"}';
78+
final String actualStdout = runResult.stdout.trim() as String;
79+
expect(actualStdout, equals(expectedStdout));
8980
});
90-
91-
if (TestFailure.testFailures == 0) {
92-
print('All tests passed!');
93-
exit(0);
94-
} else {
95-
print('${TestFailure.testFailures} test expectations failed');
96-
exit(1);
97-
}
9881
}

flutter_frontend_server/test/utils.dart

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)