OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library dart2js.serialization_model_test; | 5 library dart2js.serialization_model_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
(...skipping 12 matching lines...) Expand all Loading... |
23 import 'package:compiler/src/serialization/equivalence.dart'; | 23 import 'package:compiler/src/serialization/equivalence.dart'; |
24 import 'package:compiler/src/serialization/task.dart'; | 24 import 'package:compiler/src/serialization/task.dart'; |
25 import 'package:compiler/src/universe/world_impact.dart'; | 25 import 'package:compiler/src/universe/world_impact.dart'; |
26 import 'package:compiler/src/universe/class_set.dart'; | 26 import 'package:compiler/src/universe/class_set.dart'; |
27 import 'package:compiler/src/universe/use.dart'; | 27 import 'package:compiler/src/universe/use.dart'; |
28 import 'memory_compiler.dart'; | 28 import 'memory_compiler.dart'; |
29 import 'serialization_helper.dart'; | 29 import 'serialization_helper.dart'; |
30 import 'serialization_test_data.dart'; | 30 import 'serialization_test_data.dart'; |
31 import 'serialization_test_helper.dart'; | 31 import 'serialization_test_helper.dart'; |
32 | 32 |
33 main(List<String> arguments) { | 33 main(List<String> args) { |
34 String filename; | |
35 for (String arg in arguments) { | |
36 if (!arg.startsWith('-')) { | |
37 filename = arg; | |
38 } | |
39 } | |
40 bool verbose = arguments.contains('-v'); | |
41 | |
42 asyncTest(() async { | 34 asyncTest(() async { |
43 print('------------------------------------------------------------------'); | 35 Arguments arguments = new Arguments.from(args); |
44 print('serialize dart:core'); | 36 String serializedData = await serializeDartCore(arguments: arguments); |
45 print('------------------------------------------------------------------'); | 37 if (arguments.filename != null) { |
46 String serializedData; | 38 Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename)); |
47 File file = new File('out.data'); | |
48 if (arguments.contains('-l')) { | |
49 if (file.existsSync()) { | |
50 print('Loading data from $file'); | |
51 serializedData = file.readAsStringSync(); | |
52 } | |
53 } | |
54 if (serializedData == null) { | |
55 serializedData = await serializeDartCore(); | |
56 if (arguments.contains('-s')) { | |
57 print('Saving data to $file'); | |
58 file.writeAsStringSync(serializedData); | |
59 } | |
60 } | |
61 if (filename != null) { | |
62 Uri entryPoint = Uri.base.resolve(nativeToUriPath(filename)); | |
63 await check(serializedData, entryPoint); | 39 await check(serializedData, entryPoint); |
64 } else { | 40 } else { |
65 Uri entryPoint = Uri.parse('memory:main.dart'); | 41 Uri entryPoint = Uri.parse('memory:main.dart'); |
66 for (Test test in TESTS) { | 42 for (Test test in TESTS) { |
67 if (test.sourceFiles['main.dart'] | 43 if (test.sourceFiles['main.dart'] |
68 .contains('main(List<String> arguments)')) { | 44 .contains('main(List<String> arguments)')) { |
69 // TODO(johnniwinther): Check this test. | 45 // TODO(johnniwinther): Check this test. |
70 continue; | 46 continue; |
71 } | 47 } |
72 print('=============================================================='); | 48 print('=============================================================='); |
73 print(test.sourceFiles); | 49 print(test.sourceFiles); |
74 await check( | 50 await check( |
75 serializedData, | 51 serializedData, |
76 entryPoint, | 52 entryPoint, |
77 sourceFiles: test.sourceFiles, | 53 sourceFiles: test.sourceFiles, |
78 verbose: verbose); | 54 verbose: arguments.verbose); |
79 } | 55 } |
80 } | 56 } |
81 }); | 57 }); |
82 } | 58 } |
83 | 59 |
84 Future check( | 60 Future check( |
85 String serializedData, | 61 String serializedData, |
86 Uri entryPoint, | 62 Uri entryPoint, |
87 {Map<String, String> sourceFiles: const <String, String>{}, | 63 {Map<String, String> sourceFiles: const <String, String>{}, |
88 bool verbose: false}) async { | 64 bool verbose: false}) async { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 | 190 |
215 if (failOnUnfound || remaining.isNotEmpty) { | 191 if (failOnUnfound || remaining.isNotEmpty) { |
216 Expect.fail(message); | 192 Expect.fail(message); |
217 } else { | 193 } else { |
218 print(message); | 194 print(message); |
219 } | 195 } |
220 } else if (verbose) { | 196 } else if (verbose) { |
221 print(message); | 197 print(message); |
222 } | 198 } |
223 } | 199 } |
OLD | NEW |