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

Unified Diff: sdk/lib/_internal/dartdoc/test/dartdoc_test.dart

Issue 12782016: Switch pkg packages, pub, and dartdoc to use package: imports. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/dartdoc/pubspec.yaml ('k') | sdk/lib/_internal/dartdoc/test/markdown_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e5b67872a54093312f97b4c7dcde43e81fc9ad95 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).
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 entrypoint.
+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
« no previous file with comments | « sdk/lib/_internal/dartdoc/pubspec.yaml ('k') | sdk/lib/_internal/dartdoc/test/markdown_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698