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

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

Issue 219263003: Add end-to-end test for consistency in source map file and js file. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed pub serve test. 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
« no previous file with comments | « no previous file | tests/compiler/dart2js/source_map_d2js_consistency_test.dart » ('j') | 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) 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 }
26
27 String getMapReferenceFromJsOutput(String file) {
28 List<String> out = file.split('\n');
29 String mapReference = out[out.length - 3]; // #sourceMappingURL=<url>
30 Expect.isTrue(mapReference.startsWith('//# sourceMappingURL='));
31 return mapReference.substring(mapReference.indexOf('=') + 1);
32 }
33
34 copyDirectory(Directory sourceDir, Directory destinationDir) {
35 sourceDir.listSync().forEach((FileSystemEntity element) {
36 String newPath = path.join(destinationDir.path,
37 path.basename(element.path));
38 if (element is File) {
39 File newFile = element.copySync(newPath);
Johnni Winther 2014/04/02 08:43:30 It seems we don't need the [newFile] variable.
zarah 2014/04/02 08:58:49 Done.
40 } else if (element is Directory) {
41 Directory newDestinationDir = new Directory(newPath);
42 newDestinationDir.createSync();
43 copyDirectory(element, newDestinationDir);
44 }
45 });
46 }
47
48 Future<Directory> createTempDir() {
49 return Directory.systemTemp
50 .createTemp('sourceMap_test-')
51 .then((Directory dir) {
52 return dir;
53 });
54 }
OLDNEW
« no previous file with comments | « no previous file | tests/compiler/dart2js/source_map_d2js_consistency_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698