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

Side by Side Diff: pkg/dart_messages/test/dart_messages_test.dart

Issue 1582903003: Generate dart2js and analyzer files for shared messages. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: remove dead code and add todo instead. Created 4 years, 11 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
OLDNEW
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 import 'dart:convert'; 5 import 'dart:convert';
6 import 'dart:io'; 6 import 'dart:io';
7 7
8 import '../lib/shared_messages.dart'; 8 import '../lib/shared_messages.dart';
9 9
10 void testJsonIsUpdated() { 10 void testJsonIsUpdated() {
11 var packageRoot = Platform.packageRoot; 11 var packageRoot = Platform.packageRoot;
12 if (packageRoot == null || packageRoot == "") { 12 if (packageRoot == null || packageRoot == "") {
13 throw new UnsupportedError("This test requires a package root."); 13 throw new UnsupportedError("This test requires a package root.");
14 } 14 }
15 var jsonUri = 15 var jsonUri =
16 Uri.parse(packageRoot).resolve('dart_messages/shared_messages.json'); 16 Uri.parse(packageRoot).resolve('dart_messages/shared_messages.json');
17 var jsonPath = jsonUri.toFilePath(); 17 var jsonPath = jsonUri.toFilePath();
18 var content = new File(jsonPath).readAsStringSync(); 18 var content = new File(jsonPath).readAsStringSync();
19 if (JSON.encode(MESSAGES) != content) { 19 if (messagesAsJson != content) {
20 print("The content of the Dart messages and the corresponding JSON file"); 20 print("The content of the Dart messages and the corresponding JSON file");
21 print("is not the same."); 21 print("is not the same.");
22 print("Please run bin/json_converter to update the JSON file."); 22 print("Please run bin/publish.dart to update the JSON file.");
23 throw "Content is not the same"; 23 throw "Content is not the same";
24 } 24 }
25 } 25 }
26 26
27 void testIdsAreUnique() { 27 void testIdsAreUnique() {
28 var usedIds = new Set(); 28 var usedIds = new Set();
29 for (var entry in MESSAGES.values) { 29 for (var entry in MESSAGES.values) {
30 var id = entry['id']; 30 var id = entry.id;
31 if (!usedIds.add(id)) { 31 if (!usedIds.add(id)) {
32 throw "Id appears twice: $id"; 32 throw "Id appears twice: $id";
33 } 33 }
34 } 34 }
35 } 35 }
36 36
37 void main() { 37 void main() {
38 testJsonIsUpdated(); 38 testJsonIsUpdated();
39 testIdsAreUnique(); 39 testIdsAreUnique();
40 } 40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698