| OLD | NEW | 
|   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, |   8                        Path controllerScript, | 
|   9                        Path dartJsScript, |   9                        Path dartJsScript, | 
|  10                        String scriptType, |  10                        String scriptType, | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
|  41 </head> |  41 </head> | 
|  42 <body> |  42 <body> | 
|  43   <script type="text/javascript"> |  43   <script type="text/javascript"> | 
|  44     if (navigator.webkitStartDart) navigator.webkitStartDart(); |  44     if (navigator.webkitStartDart) navigator.webkitStartDart(); | 
|  45   </script> |  45   </script> | 
|  46   <script type="$scriptType" src="$sourceScript"></script> |  46   <script type="$scriptType" src="$sourceScript"></script> | 
|  47 </body> |  47 </body> | 
|  48 </html> |  48 </html> | 
|  49 """; |  49 """; | 
|  50  |  50  | 
|  51 String wrapDartTestInLibrary(Path test) => |  51 String wrapDartTestInLibrary(Path test, String testPath) => | 
|  52 """ |  52 """ | 
|  53 library libraryWrapper; |  53 library libraryWrapper; | 
|  54 part '$test'; |  54 part '${pathLib.relative(test.toNativePath(), | 
 |  55     from: pathLib.dirname(testPath)).replaceAll('\\', '\\\\')}'; | 
|  55 """; |  56 """; | 
|  56  |  57  | 
|  57 String dartTestWrapper(Path dartHome, Path library) { |  58 String dartTestWrapper(Path dartHome, String testPath, Path library) { | 
 |  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   } | 
|  58   // Tests inside "pkg" import unittest using "package:". All others use a |  69   // Tests inside "pkg" import unittest using "package:". All others use a | 
|  59   // relative path. The imports need to agree, so use a matching form here. |  70   // relative path. The imports need to agree, so use a matching form here. | 
|  60   var unitTest = dartHome.append("pkg/unittest/lib").toString(); |  71   if (pathLib.split(pathLib.relative(libString, | 
|  61  |  72       from: dartHome.toNativePath())).contains("pkg")) { | 
|  62   // TODO(rnystrom): Looking in the entire path here is wrong. It should only |  | 
|  63   // consider the relative path within dartHome. Unfortunately, |  | 
|  64   // Path.relativeTo() does not handle cases where library is already a relative |  | 
|  65   // path, and Path.isAbsolute does not work on Windows. |  | 
|  66   if (library.segments().contains("pkg")) { |  | 
|  67     unitTest = 'package:unittest'; |  73     unitTest = 'package:unittest'; | 
|  68   } |  74   } | 
|  69  |  | 
|  70   return """ |  75   return """ | 
|  71 library test; |  76 library test; | 
|  72  |  77  | 
|  73 import '$unitTest/unittest.dart' as unittest; |  78 import '$unitTest/unittest.dart' as unittest; | 
|  74 import '$unitTest/html_config.dart' as config; |  79 import '$unitTest/html_config.dart' as config; | 
|  75 import '${library}' as Test; |  80 import '${pathLib.relative(libString, from: testPathDir).replaceAll( | 
 |  81     '\\', '\\\\')}' as Test; | 
|  76  |  82  | 
|  77 main() { |  83 main() { | 
|  78   config.useHtmlConfiguration(); |  84   config.useHtmlConfiguration(); | 
|  79   unittest.group('', Test.main); |  85   unittest.group('', Test.main); | 
|  80 } |  86 } | 
|  81 """; |  87 """; | 
|  82 } |  88 } | 
| OLD | NEW |