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

Side by Side Diff: tools/testing/dart/browser_test.dart

Issue 10584014: Change test scripts to use Path library in most places, instead of strings. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Take out changes to Path as separate CL. Created 8 years, 5 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
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 String GetHtmlContents(String title, 5 String GetHtmlContents(String title,
6 String controllerScript, 6 String controllerScript,
7 String scriptType, 7 String scriptType,
8 String sourceScript) => 8 String sourceScript) =>
9 """ 9 """
10 <!DOCTYPE html> 10 <!DOCTYPE html>
11 <html> 11 <html>
12 <head> 12 <head>
13 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 13 <meta http-equiv="X-UA-Compatible" content="IE=edge">
14 <title> Test $title </title> 14 <title> Test $title </title>
15 <style> 15 <style>
16 .unittest-table { font-family:monospace; border:1px; } 16 .unittest-table { font-family:monospace; border:1px; }
17 .unittest-pass { background: #6b3;} 17 .unittest-pass { background: #6b3;}
18 .unittest-fail { background: #d55;} 18 .unittest-fail { background: #d55;}
19 .unittest-error { background: #a11;} 19 .unittest-error { background: #a11;}
20 </style> 20 </style>
21 </head> 21 </head>
22 <body> 22 <body>
23 <h1> Running $title </h1> 23 <h1> Running $title </h1>
24 <script type="text/javascript" src="$controllerScript"></script> 24 <script type="text/javascript" src="$controllerScript"></script>
25 <script type="$scriptType" src="$sourceScript"></script> 25 <script type="$scriptType" src="$sourceScript"></script>
26 </body> 26 </body>
27 </html> 27 </html>
28 """; 28 """;
29 29
30 /** 30 String WrapDartTestInLibrary(Path test) =>
31 * Returns the native [path] converted for use in a URI.
32 */
33 nativePathToUri(String path) {
34 // This regexp matches Windows-like file names. Strictly speaking,
35 // this prevents us from having a file named a:something on Linux,
36 // but since this wrapping is a hack in the first place, it seems
37 // better to exercise this path on all architectures.
38 final re = const RegExp('^[a-z]:', ignoreCase: true);
39 if (re.hasMatch(path)) {
40 path = '/$path';
41 }
42 return path.replaceAll('\\', '/');
43 }
44
45 String WrapDartTestInLibrary(String test) =>
46 """ 31 """
47 #library('libraryWrapper'); 32 #library('libraryWrapper');
48 #source('${nativePathToUri(test)}'); 33 #source('$test');
49 """; 34 """;
50 35
51 String DartTestWrapper(String dartHome, String library) { 36 String DartTestWrapper(Path dartHome, Path library) {
52 dartHome = nativePathToUri(dartHome);
53 library = nativePathToUri(library);
54 return """ 37 return """
55 #library('test'); 38 #library('test');
56 39
57 #import('${dartHome}/lib/unittest/unittest.dart', prefix: 'unittest'); 40 #import('${dartHome.append('lib/unittest/unittest.dart')}, prefix: 'unittest');
58 #import('${dartHome}/lib/unittest/html_config.dart', prefix: 'config'); 41 #import('${dartHome.append('lib/unittest/html_config.dart')}, prefix: 'config');
59 42
60 #import('${library}', prefix: "Test"); 43 #import('${library}', prefix: "Test");
61 44
62 main() { 45 main() {
63 config.useHtmlConfiguration(); 46 config.useHtmlConfiguration();
64 try { 47 try {
65 unittest.ensureInitialized(); 48 unittest.ensureInitialized();
66 Test.main(); 49 Test.main();
67 } catch(var e, var trace) { 50 } catch(var e, var trace) {
68 unittest.reportTestError( 51 unittest.reportTestError(
69 e.toString(), trace == null ? '' : trace.toString()); 52 e.toString(), trace == null ? '' : trace.toString());
70 } 53 }
71 } 54 }
72 """; 55 """;
73 } 56 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698