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

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

Issue 12183022: Change the location of the output directory of generated tests to be inside build directory, but no… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 part of test_suite; 5 part of test_suite;
6 6
7 String getHtmlContents(String title, 7 String getHtmlContents(String title,
8 Path controllerScript,
9 Path dartJsScript,
10 String scriptType, 8 String scriptType,
11 Path sourceScript) => 9 Path sourceScript) =>
12 """ 10 """
13 <!DOCTYPE html> 11 <!DOCTYPE html>
14 <html> 12 <html>
15 <head> 13 <head>
16 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 14 <meta http-equiv="X-UA-Compatible" content="IE=edge">
17 <title> Test $title </title> 15 <title> Test $title </title>
18 <style> 16 <style>
19 .unittest-table { font-family:monospace; border:1px; } 17 .unittest-table { font-family:monospace; border:1px; }
20 .unittest-pass { background: #6b3;} 18 .unittest-pass { background: #6b3;}
21 .unittest-fail { background: #d55;} 19 .unittest-fail { background: #d55;}
22 .unittest-error { background: #a11;} 20 .unittest-error { background: #a11;}
23 </style> 21 </style>
24 </head> 22 </head>
25 <body> 23 <body>
26 <h1> Running $title </h1> 24 <h1> Running $title </h1>
27 <script type="text/javascript" src="$controllerScript"></script> 25 <script type="text/javascript" src="/pkg/unittest/test_controller.js"></script >
28 <script type="$scriptType" src="$sourceScript" onerror="externalError(null)"> 26 <script type="$scriptType" src="$sourceScript" onerror="externalError(null)">
29 </script> 27 </script>
30 <script type="text/javascript" src="$dartJsScript"></script> 28 <script type="text/javascript" src="/pkg/browser/lib/dart.js"></script>
31 </body> 29 </body>
32 </html> 30 </html>
33 """; 31 """;
34 32
35 String getHtmlLayoutContents(String scriptType, String sourceScript) => 33 String getHtmlLayoutContents(String scriptType, String sourceScript) =>
36 """ 34 """
37 <!DOCTYPE html> 35 <!DOCTYPE html>
38 <html> 36 <html>
39 <head> 37 <head>
40 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 38 <meta http-equiv="X-UA-Compatible" content="IE=edge">
41 </head> 39 </head>
42 <body> 40 <body>
43 <script type="text/javascript"> 41 <script type="text/javascript">
44 if (navigator.webkitStartDart) navigator.webkitStartDart(); 42 if (navigator.webkitStartDart) navigator.webkitStartDart();
45 </script> 43 </script>
46 <script type="$scriptType" src="$sourceScript"></script> 44 <script type="$scriptType" src="$sourceScript"></script>
47 </body> 45 </body>
48 </html> 46 </html>
49 """; 47 """;
50 48
51 String wrapDartTestInLibrary(Path test, String testPath) => 49 String wrapDartTestInLibrary(Path testRelativeToDart) =>
52 """ 50 """
53 library libraryWrapper; 51 library libraryWrapper;
54 part '${pathLib.relative(test.toNativePath(), 52 part '/$testRelativeToDart';
55 from: pathLib.dirname(testPath)).replaceAll('\\', '\\\\')}';
56 """; 53 """;
57 54
58 String dartTestWrapper(Path dartHome, String testPath, Path library) { 55 String dartTestWrapper(bool usePackageImport, String libraryPathComponent) {
59 var testPathDir = pathLib.dirname(testPath);
60 var dartHomePath = dartHome.toNativePath();
61 // TODO(efortuna): Unify path libraries used in test.dart.
62 var unitTest = pathLib.relative(pathLib.join(dartHomePath,
63 'pkg/unittest/lib'), from: testPathDir).replaceAll('\\', '\\\\');
64
65 var libString = library.toNativePath();
66 if (!pathLib.isAbsolute(libString)) {
67 libString = pathLib.join(dartHome.toNativePath(), libString);
68 }
69 // Tests inside "pkg" import unittest using "package:". All others use a 56 // Tests inside "pkg" import unittest using "package:". All others use a
70 // relative path. The imports need to agree, so use a matching form here. 57 // relative path. The imports need to agree, so use a matching form here.
71 if (pathLib.split(pathLib.relative(libString, 58 var unitTest;
72 from: dartHome.toNativePath())).contains("pkg")) { 59 if (usePackageImport) {
73 unitTest = 'package:unittest'; 60 unitTest = 'package:unittest';
61 } else {
62 unitTest = '/pkg/unittest/lib';
74 } 63 }
75 return """ 64 return """
76 library test; 65 library test;
77 66
78 import '$unitTest/unittest.dart' as unittest; 67 import '$unitTest/unittest.dart' as unittest;
79 import '$unitTest/html_config.dart' as config; 68 import '$unitTest/html_config.dart' as config;
80 import '${pathLib.relative(libString, from: testPathDir).replaceAll( 69 import '$libraryPathComponent' as Test;
81 '\\', '\\\\')}' as Test;
82 70
83 main() { 71 main() {
84 config.useHtmlConfiguration(); 72 config.useHtmlConfiguration();
85 unittest.group('', Test.main); 73 unittest.group('', Test.main);
86 } 74 }
87 """; 75 """;
88 } 76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698