| Index: tools/testing/dart/browser_test.dart
|
| diff --git a/tools/testing/dart/browser_test.dart b/tools/testing/dart/browser_test.dart
|
| index b47bbf8ed1faefbd0dbe5688cee465c19b686262..6bfc93af5e715e9c1dcf3f80e3ea6d62203d3f7e 100644
|
| --- a/tools/testing/dart/browser_test.dart
|
| +++ b/tools/testing/dart/browser_test.dart
|
| @@ -48,31 +48,37 @@ String getHtmlLayoutContents(String scriptType, String sourceScript) =>
|
| </html>
|
| """;
|
|
|
| -String wrapDartTestInLibrary(Path test) =>
|
| +String wrapDartTestInLibrary(Path test, String testPath) =>
|
| """
|
| library libraryWrapper;
|
| -part '$test';
|
| +part '${pathLib.relative(test.toNativePath(),
|
| + from: pathLib.dirname(testPath)).replaceAll('\\', '\\\\')}';
|
| """;
|
|
|
| -String dartTestWrapper(Path dartHome, Path library) {
|
| +String dartTestWrapper(Path dartHome, String testPath, Path library) {
|
| + var testPathDir = pathLib.dirname(testPath);
|
| + var dartHomePath = dartHome.toNativePath();
|
| + // TODO(efortuna): Unify path libraries used in test.dart.
|
| + var unitTest = pathLib.relative(pathLib.join(dartHomePath,
|
| + 'pkg/unittest/lib'), from: testPathDir).replaceAll('\\', '\\\\');
|
| +
|
| + var libString = library.toNativePath();
|
| + if (!pathLib.isAbsolute(libString)) {
|
| + libString = pathLib.join(dartHome.toNativePath(), libString);
|
| + }
|
| // Tests inside "pkg" import unittest using "package:". All others use a
|
| // relative path. The imports need to agree, so use a matching form here.
|
| - var unitTest = dartHome.append("pkg/unittest/lib").toString();
|
| -
|
| - // TODO(rnystrom): Looking in the entire path here is wrong. It should only
|
| - // consider the relative path within dartHome. Unfortunately,
|
| - // Path.relativeTo() does not handle cases where library is already a relative
|
| - // path, and Path.isAbsolute does not work on Windows.
|
| - if (library.segments().contains("pkg")) {
|
| + if (pathLib.split(pathLib.relative(libString,
|
| + from: dartHome.toNativePath())).contains("pkg")) {
|
| unitTest = 'package:unittest';
|
| }
|
| -
|
| return """
|
| library test;
|
|
|
| import '$unitTest/unittest.dart' as unittest;
|
| import '$unitTest/html_config.dart' as config;
|
| -import '${library}' as Test;
|
| +import '${pathLib.relative(libString, from: testPathDir).replaceAll(
|
| + '\\', '\\\\')}' as Test;
|
|
|
| main() {
|
| config.useHtmlConfiguration();
|
|
|