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

Side by Side Diff: tests/compiler/dart2js/source_map_consistency_helper.dart

Issue 228003005: Remove redundancy in source map entries. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changed command path. Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014, 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 import 'dart:convert';
7 import 'dart:async';
8
9 import 'package:path/path.dart' as path;
10 import 'package:expect/expect.dart';
11 import 'package:source_maps/source_maps.dart';
12
13 checkConsistency(Uri outUri) {
14 print('Accessing $outUri');
15 File sourceFile = new File.fromUri(outUri);
16 Expect.isTrue(sourceFile.existsSync());
17 String mapName = getMapReferenceFromJsOutput(sourceFile.readAsStringSync());
18 Uri mapUri = outUri.resolve(mapName);
19 print('Accessing $mapUri');
20 File mapFile = new File.fromUri(mapUri);
21 Expect.isTrue(mapFile.existsSync());
22 SingleMapping sourceMap = new SingleMapping.fromJson(
23 JSON.decode(mapFile.readAsStringSync()));
24 Expect.equals(outUri, mapUri.resolve(sourceMap.targetUrl));
25 print('Checking sources');
26 sourceMap.urls.forEach((String url) {
27 Expect.isTrue(new File.fromUri(mapUri.resolve(url)).existsSync());
28 });
29 }
30
31 String getMapReferenceFromJsOutput(String file) {
32 List<String> out = file.split('\n');
33 String mapReference = out[out.length - 3]; // #sourceMappingURL=<url>
34 Expect.isTrue(mapReference.startsWith('//# sourceMappingURL='));
35 return mapReference.substring(mapReference.indexOf('=') + 1);
36 }
37
38 copyDirectory(Directory sourceDir, Directory destinationDir) {
39 sourceDir.listSync().forEach((FileSystemEntity element) {
40 String newPath = path.join(destinationDir.path,
41 path.basename(element.path));
42 if (element is File) {
43 element.copySync(newPath);
44 } else if (element is Directory) {
45 Directory newDestinationDir = new Directory(newPath);
46 newDestinationDir.createSync();
47 copyDirectory(element, newDestinationDir);
48 }
49 });
50 }
51
52 Future<Directory> createTempDir() {
53 return Directory.systemTemp
54 .createTemp('sourceMap_test-')
55 .then((Directory dir) {
56 return dir;
57 });
58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698