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 /// A command-line tool that verifies that deferred libraries split the code as | 5 /// A command-line tool that verifies that deferred libraries split the code as |
6 /// expected. | 6 /// expected. |
7 /// This tool checks that the output from dart2js meets a given specification, | 7 /// This tool checks that the output from dart2js meets a given specification, |
8 /// given in a YAML file. The format of the YAML file is: | 8 /// given in a YAML file. The format of the YAML file is: |
9 /// | 9 /// |
10 /// main: | 10 /// main: |
(...skipping 18 matching lines...) Expand all Loading... |
29 /// contained in that part. Any package that is not explicitly listed is | 29 /// contained in that part. Any package that is not explicitly listed is |
30 /// expected to be in the main part. For instance, in the example YAML above | 30 /// expected to be in the main part. For instance, in the example YAML above |
31 /// the part named "baz" is expected to contain the packages "baz" and "quux". | 31 /// the part named "baz" is expected to contain the packages "baz" and "quux". |
32 /// | 32 /// |
33 /// The names for parts given in the specification YAML file (besides "main") | 33 /// The names for parts given in the specification YAML file (besides "main") |
34 /// are arbitrary and just used for reporting when the output does not meet the | 34 /// are arbitrary and just used for reporting when the output does not meet the |
35 /// specification. | 35 /// specification. |
36 library dart2js_info.bin.deferred_library_check; | 36 library dart2js_info.bin.deferred_library_check; |
37 | 37 |
38 import 'dart:async'; | 38 import 'dart:async'; |
39 import 'dart:convert'; | |
40 import 'dart:io'; | 39 import 'dart:io'; |
41 | 40 |
42 import 'package:dart2js_info/info.dart'; | |
43 import 'package:dart2js_info/deferred_library_check.dart'; | 41 import 'package:dart2js_info/deferred_library_check.dart'; |
| 42 import 'package:dart2js_info/src/util.dart'; |
44 import 'package:yaml/yaml.dart'; | 43 import 'package:yaml/yaml.dart'; |
45 | 44 |
46 Future main(List<String> args) async { | 45 Future main(List<String> args) async { |
47 if (args.length < 2) { | 46 if (args.length < 2) { |
48 usage(); | 47 usage(); |
49 exit(1); | 48 exit(1); |
50 } | 49 } |
51 var info = await infoFromFile(args[0]); | 50 var info = await infoFromFile(args[0]); |
52 var manifest = await manifestFromFile(args[1]); | 51 var manifest = await manifestFromFile(args[1]); |
53 | 52 |
54 var failures = checkDeferredLibraryManifest(info, manifest); | 53 var failures = checkDeferredLibraryManifest(info, manifest); |
55 failures.forEach(print); | 54 failures.forEach(print); |
56 if (failures.isNotEmpty) exitCode = 1; | 55 if (failures.isNotEmpty) exitCode = 1; |
57 } | 56 } |
58 | 57 |
59 Future<AllInfo> infoFromFile(String fileName) async { | |
60 var file = await new File(fileName).readAsString(); | |
61 return new AllInfoJsonCodec().decode(JSON.decode(file)); | |
62 } | |
63 | |
64 Future manifestFromFile(String fileName) async { | 58 Future manifestFromFile(String fileName) async { |
65 var file = await new File(fileName).readAsString(); | 59 var file = await new File(fileName).readAsString(); |
66 return loadYaml(file); | 60 return loadYaml(file); |
67 } | 61 } |
68 | 62 |
69 void usage() { | 63 void usage() { |
70 print(''' | 64 print(''' |
71 usage: dart2js_info_deferred_library_check dump.info.json manifest.yaml'''); | 65 usage: dart2js_info_deferred_library_check dump.info.json manifest.yaml'''); |
72 } | 66 } |
OLD | NEW |