|
4 | 4 |
|
5 | 5 | import 'dart:io';
|
6 | 6 |
|
| 7 | +import 'package:litetest/litetest.dart'; |
7 | 8 | import 'package:path/path.dart' as path;
|
8 | 9 |
|
9 |
| -import 'utils.dart'; |
10 |
| - |
11 | 10 | Future<void> main(List<String> args) async {
|
12 | 11 | if (args.length != 2) {
|
13 | 12 | stderr.writeln('The first argument must be the path to the frontend server dill.');
|
14 | 13 | stderr.writeln('The second argument must be the path to the flutter_patched_sdk');
|
15 | 14 | exit(-1);
|
16 | 15 | }
|
17 | 16 |
|
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'); |
28 | 26 |
|
29 | 27 |
|
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); |
36 | 32 | }
|
| 33 | + expect(result.exitCode, 0); |
| 34 | + } |
37 | 35 |
|
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 | + } |
53 | 51 |
|
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 | + }); |
64 | 59 |
|
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); |
78 | 73 |
|
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)); |
89 | 80 | });
|
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 |
| - } |
98 | 81 | }
|
0 commit comments