Chromium Code Reviews| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 </body> | 47 </body> |
| 48 </html> | 48 </html> |
| 49 """; | 49 """; |
| 50 | 50 |
| 51 String wrapDartTestInLibrary(Path test) => | 51 String wrapDartTestInLibrary(Path test) => |
| 52 """ | 52 """ |
| 53 library libraryWrapper; | 53 library libraryWrapper; |
| 54 part '$test'; | 54 part '$test'; |
| 55 """; | 55 """; |
| 56 | 56 |
| 57 String dartTestWrapper(Path dartHome, Path library) { | 57 String dartTestWrapper(Path dartHome, String testPath, Path library) { |
| 58 // Tests inside "pkg" import unittest using "package:". All others use a | 58 // 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. | 59 // relative path. The imports need to agree, so use a matching form here. |
| 60 var unitTest = dartHome.append("pkg/unittest/lib").toString(); | 60 var testPathDir = pathLib.dirname(testPath.toString()); |
|
Bob Nystrom
2013/01/05 00:26:43
Remove the toString(), it's already one. :)
| |
| 61 var unitTest = pathLib.relative( | |
| 62 dartHome.append("pkg/unittest/lib").toString(), from: testPathDir); | |
|
Bob Nystrom
2013/01/05 00:26:43
Mixing Path and the path lib is a bit confusing to
| |
| 61 | 63 |
| 62 // TODO(rnystrom): Looking in the entire path here is wrong. It should only | 64 var libString = library.toString(); |
| 63 // consider the relative path within dartHome. Unfortunately, | 65 if (!pathLib.isAbsolute(libString)) { |
| 64 // Path.relativeTo() does not handle cases where library is already a relative | 66 libString = pathLib.join(dartHome.toString(), libString); |
|
Bob Nystrom
2013/01/05 00:26:43
toNativeString(), I think? Path always trips me up
| |
| 65 // path, and Path.isAbsolute does not work on Windows. | 67 } |
| 66 if (library.segments().contains("pkg")) { | 68 if (pathLib.relative(libString, from: dartHome.toString()).contains("pkg")) { |
| 67 unitTest = 'package:unittest'; | 69 unitTest = 'package:unittest'; |
| 68 } | 70 } |
| 69 | |
| 70 return """ | 71 return """ |
| 71 library test; | 72 library test; |
| 72 | 73 |
| 73 import '$unitTest/unittest.dart' as unittest; | 74 import '$unitTest/unittest.dart' as unittest; |
| 74 import '$unitTest/html_config.dart' as config; | 75 import '$unitTest/html_config.dart' as config; |
| 75 import '${library}' as Test; | 76 import '${pathLib.relative(libString, from: testPathDir)}' as Test; |
| 76 | 77 |
| 77 main() { | 78 main() { |
| 78 config.useHtmlConfiguration(); | 79 config.useHtmlConfiguration(); |
| 79 unittest.group('', Test.main); | 80 unittest.group('', Test.main); |
| 80 } | 81 } |
| 81 """; | 82 """; |
| 82 } | 83 } |
| OLD | NEW |