Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: pkg/front_end/test/fasta/messages_test.dart

Issue 3010843002: message.yaml test - first cut (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
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.
4
5 import 'dart:io';
6
7 import 'package:yaml/yaml.dart' show loadYaml;
8
9 main(List<String> arguments) async {
10 Uri messagesFile = Platform.script.resolve("../../messages.yaml");
ahe 2017/09/01 12:27:55 I think this is more reliable: Uri.base.resolve("
11 Map yaml = loadYaml(await new File.fromUri(messagesFile).readAsStringSync());
ahe 2017/09/01 12:27:54 Remove Sync.
12
13 int untestedExampleCount = 0;
14 int missingExamplesCount = 0;
15 int missingAnalyzerCode = 0;
16 int missingDart2jsCode = 0;
17 List<String> keys = yaml.keys.toList()..sort();
18 for (String name in keys) {
19 var description = yaml[name];
20 while (description is String) {
21 description = yaml[description];
22 }
23 Map map = description;
24
25 int localUntestedExampleCount = countExamples(map, name, 'bytes');
26 localUntestedExampleCount += countExamples(map, name, 'declaration');
27 localUntestedExampleCount += countExamples(map, name, 'expression');
28 localUntestedExampleCount += countExamples(map, name, 'script');
29 localUntestedExampleCount += countExamples(map, name, 'statement');
30 if (localUntestedExampleCount == 0) ++missingExamplesCount;
31 untestedExampleCount += localUntestedExampleCount;
32
33 if (map['analyzerCode'] == null) ++missingAnalyzerCode;
34 if (map['dart2jsCode'] == null) ++missingDart2jsCode;
35 }
36
37 print('$untestedExampleCount examples not tested');
38 print('$missingExamplesCount error codes missing examples');
39 print('$missingAnalyzerCode error codes missing analyzer code');
40 print('$missingDart2jsCode error codes missing dart2js code');
ahe 2017/09/01 12:27:54 We don't need dart2js error codes for all errors.
41
42 // TODO(danrubel): Update this test to assert each count == 0.
43 // Allow them to be non-zero until messages.yaml has been updated.
44 return untestedExampleCount == 0 ||
45 missingExamplesCount == 0 ||
46 missingAnalyzerCode == 0 ||
47 missingDart2jsCode == 0
48 ? 1
49 : 0;
ahe 2017/09/01 12:27:54 In Dart, main's return value is ignored. So how ab
50 }
51
52 int countExamples(Map map, String name, String key) {
53 var example = map[key];
54 if (example == null) return 0;
55 if (example is String) return 1;
56 if (example is List) return example.length;
57 if (example is Map) return example.length;
58
59 throw 'Unknown value for $name $key --> ${example.runtimeType}\n $example';
60 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698