OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env dart |
| 2 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. |
| 5 |
| 6 /// For each codegen test file, this generates a little HTML page that you can |
| 7 /// load directly in your browser to run and debug the test. |
| 8 // TODO(rnystrom): This script is still pretty rough around the edges. Use it |
| 9 // with caution and fix stuff if you see it doing something dumb. |
| 10 |
| 11 import 'dart:io'; |
| 12 |
| 13 import 'package:path/path.dart' as p; |
| 14 |
| 15 final scriptDir = p.dirname(p.fromUri(Platform.script)); |
| 16 final ddcDir = p.dirname(scriptDir); |
| 17 |
| 18 main() { |
| 19 var expectDir = p.normalize(p.join(scriptDir, "../test/codegen/expect")); |
| 20 |
| 21 var tests = new Directory(expectDir) |
| 22 .listSync(recursive: true) |
| 23 .map((entry) => p.relative(entry.path, from: expectDir)) |
| 24 .where((path) => path.endsWith(".js") || path.endsWith(".err")) |
| 25 .map(p.withoutExtension) |
| 26 .toSet() |
| 27 .toList(); |
| 28 |
| 29 // TODO(rnystrom): Do something more graceful than blowing away the whole |
| 30 // directory. |
| 31 new Directory("debug").deleteSync(recursive: true); |
| 32 |
| 33 tests.forEach(makePage); |
| 34 } |
| 35 |
| 36 void makePage(String test) { |
| 37 // Create the containing directory if needed. |
| 38 var dir = new Directory(p.join(ddcDir, "debug", p.dirname(test))); |
| 39 if (!dir.existsSync()) dir.createSync(recursive: true); |
| 40 |
| 41 // Make a header line that links to all of the directories. |
| 42 var parts = p.split(p.normalize(p.join("debug", p.dirname(test)))); |
| 43 var headers = []; |
| 44 var i = parts.length; |
| 45 for (var part in parts) { |
| 46 headers.add('<a href="${'../' * i}$part">$part</a>'); |
| 47 i--; |
| 48 } |
| 49 var header = headers.join(' / '); |
| 50 |
| 51 var toRoot = p.relative(ddcDir, from: dir.path); |
| 52 new File(p.join("debug", "$test.html")).writeAsStringSync(""" |
| 53 <!DOCTYPE html> |
| 54 <html> |
| 55 <head> |
| 56 <meta http-equiv="Content-type" content="text/html;charset=UTF-8" /> |
| 57 <title>$test</title> |
| 58 </head> |
| 59 <body> |
| 60 <h1>$header / ${p.basename(test)}</h1> |
| 61 <h3>Errors</h3> |
| 62 <iframe src="$toRoot/test/codegen/expect/$test.err" width="80%"></iframe> |
| 63 <h3>Warnings</h3> |
| 64 <iframe src="$toRoot/test/codegen/expect/$test.txt" width="80%"></iframe> |
| 65 <script src="$toRoot/lib/runtime/dart_library.js"></script> |
| 66 <script src="$toRoot/lib/runtime/dart_sdk.js"></script> |
| 67 <script src="$toRoot/test/codegen/expect/expect.js"></script> |
| 68 <script src="$toRoot/test/codegen/expect/$test.js"></script> |
| 69 <script> |
| 70 dart_library.start('$test', '${p.basename(test)}'); |
| 71 </script> |
| 72 </body> |
| 73 </html> |
| 74 """); |
| 75 } |
OLD | NEW |