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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/compiler/dart2js/source_map_d2js_consistency_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/source_map_consistency_helper.dart
diff --git a/tests/compiler/dart2js/source_map_consistency_helper.dart b/tests/compiler/dart2js/source_map_consistency_helper.dart
new file mode 100644
index 0000000000000000000000000000000000000000..ad87c6eda1ab31a5c338611295ea32086acdc180
--- /dev/null
+++ b/tests/compiler/dart2js/source_map_consistency_helper.dart
@@ -0,0 +1,54 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:io';
+import 'dart:convert';
+import 'dart:async';
+
+import 'package:path/path.dart' as path;
+import 'package:expect/expect.dart';
+import 'package:source_maps/source_maps.dart';
+
+checkConsistency(Uri outUri) {
+ print('Accessing $outUri');
+ File sourceFile = new File.fromUri(outUri);
+ Expect.isTrue(sourceFile.existsSync());
+ String mapName = getMapReferenceFromJsOutput(sourceFile.readAsStringSync());
+ Uri mapUri = outUri.resolve(mapName);
+ print('Accessing $mapUri');
+ File mapFile = new File.fromUri(mapUri);
+ Expect.isTrue(mapFile.existsSync());
+ SingleMapping sourceMap = new SingleMapping.fromJson(
+ JSON.decode(mapFile.readAsStringSync()));
+ Expect.equals(outUri, mapUri.resolve(sourceMap.targetUrl));
+}
+
+String getMapReferenceFromJsOutput(String file) {
+ List<String> out = file.split('\n');
+ String mapReference = out[out.length - 3]; // #sourceMappingURL=<url>
+ Expect.isTrue(mapReference.startsWith('//# sourceMappingURL='));
+ return mapReference.substring(mapReference.indexOf('=') + 1);
+}
+
+copyDirectory(Directory sourceDir, Directory destinationDir) {
+ sourceDir.listSync().forEach((FileSystemEntity element) {
+ String newPath = path.join(destinationDir.path,
+ path.basename(element.path));
+ if (element is File) {
+ 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.
+ } else if (element is Directory) {
+ Directory newDestinationDir = new Directory(newPath);
+ newDestinationDir.createSync();
+ copyDirectory(element, newDestinationDir);
+ }
+ });
+}
+
+Future<Directory> createTempDir() {
+ return Directory.systemTemp
+ .createTemp('sourceMap_test-')
+ .then((Directory dir) {
+ return dir;
+ });
+}
« 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