Chromium Code Reviews| Index: sdk/lib/_internal/dartdoc/test/dartdoc_test.dart |
| diff --git a/sdk/lib/_internal/dartdoc/test/dartdoc_test.dart b/sdk/lib/_internal/dartdoc/test/dartdoc_test.dart |
| index e588aa5aa6aad5ce5572b6e7339f2f102c5d7284..3b003e3c65d10da50b59b5f41d068eea2db25172 100644 |
| --- a/sdk/lib/_internal/dartdoc/test/dartdoc_test.dart |
| +++ b/sdk/lib/_internal/dartdoc/test/dartdoc_test.dart |
| @@ -7,16 +7,15 @@ library dartdocTests; |
| import 'dart:async'; |
| import 'dart:io'; |
| -import '../../../../../pkg/pathos/lib/path.dart' as path; |
| + |
| +import 'package:pathos/path.dart' as path; |
| +import 'package:unittest/unittest.dart'; |
| // TODO(rnystrom): Use "package:" URL (#4968). |
|
Bob Nystrom
2013/03/26 01:55:44
Do you want to fix these imports, or just remove t
nweiz
2013/03/26 02:09:53
These still want to be changed to "package:" impor
|
| import '../lib/dartdoc.dart' as dd; |
| import '../lib/markdown.dart'; |
| import 'markdown_test.dart'; |
| -// TODO(rnystrom): Better path to unittest. |
| -import '../../../../../pkg/unittest/lib/unittest.dart'; |
| - |
| // Pretty test config with --human |
| import '../../../../../utils/tests/pub/command_line_config.dart'; |
| @@ -237,11 +236,8 @@ void _testRunDartDoc(List<String> libraryPaths, void eval(ProcessResult)) { |
| expect(_runDartdoc(libraryPaths).then(eval), completes); |
| } |
| -/// Runs dartdoc with the libraryPaths provided, and completes to dartdoc's |
| -/// ProcessResult. |
| -Future<ProcessResult> _runDartdoc(List<String> libraryPaths) { |
| - var dartBin = new Options().executable; |
| - |
| +/// The path to the root directory of the dartdoc app. |
|
Bob Nystrom
2013/03/26 01:55:44
"app" -> "entrypoint".
nweiz
2013/03/26 02:09:53
Done.
|
| +String get _dartdocDir { |
| var dir = path.absolute(new Options().script); |
| while (path.basename(dir) != 'dartdoc') { |
| if (!path.absolute(dir).contains('dartdoc') || dir == path.dirname(dir)) { |
| @@ -249,9 +245,40 @@ Future<ProcessResult> _runDartdoc(List<String> libraryPaths) { |
| } |
| dir = path.dirname(dir); |
| } |
| - var dartdoc = path.join(path.absolute(dir), 'bin/dartdoc.dart'); |
| + return path.absolute(dir); |
| +} |
| + |
| +/// The path to use for the package root for subprocesses. |
| +String get _packageRoot { |
| + var sdkVersionPath = path.join(_dartdocDir, '..', '..', '..', 'version'); |
| + if (new File(sdkVersionPath).existsSync()) { |
| + // It looks like dartdoc is being run from the SDK, so we should set the |
| + // package root to the SDK's packages directory. |
| + return path.absolute(path.join(_dartdocDir, '..', '..', '..', 'packages')); |
| + } |
| + |
| + // It looks like Dartdoc is being run from the Dart repo, so the package root |
| + // is in the build output directory. We can find that directory relative to |
| + // the Dart executable, but that could be in one of two places: in |
| + // "$BUILD/dart" or "$BUILD/dart-sdk/bin/dart". |
| + var executableDir = path.dirname(new Options().executable); |
| + if (new Directory(path.join(executableDir, 'dart-sdk')).existsSync()) { |
| + // The executable is in "$BUILD/dart". |
| + return path.absolute(path.join(executableDir, 'packages')); |
| + } else { |
| + // The executable is in "$BUILD/dart-sdk/bin/dart". |
| + return path.absolute(path.join(executableDir, '..', '..', 'packages')); |
| + } |
| +} |
| + |
| +/// Runs dartdoc with the libraryPaths provided, and completes to dartdoc's |
| +/// ProcessResult. |
| +Future<ProcessResult> _runDartdoc(List<String> libraryPaths) { |
| + var dartBin = new Options().executable; |
| + |
| + var dartdoc = path.join(_dartdocDir, 'bin/dartdoc.dart'); |
| - final runArgs = [dartdoc]; |
| + final runArgs = ['--package-root=$_packageRoot/', dartdoc]; |
| // Turn relative libraryPaths to absolute ones. |
| runArgs.addAll(libraryPaths |