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

Side by Side Diff: test/io.dart

Issue 979513002: pkg/unittest: Add a server for serving test assets to browsers. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Fix libDir. Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 library unittest.test.io; 5 library unittest.test.io;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:mirrors'; 8 import 'dart:mirrors';
9 9
10 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
11 import 'package:unittest/src/util/io.dart';
11 12
12 /// The root directory of the `unittest` package. 13 /// The path to the root directory of the `unittest` package.
13 final String packageDir = _computePackageDir(); 14 final String packageDir = p.dirname(p.dirname(libraryPath(#unittest.test.io)));
14 String _computePackageDir() =>
15 p.dirname(p.dirname(_libraryPath(#unittest.test.io)));
16 15
17 /// Runs the unittest executable with the package root set properly. 16 /// Runs the unittest executable with the package root set properly.
18 ProcessResult runUnittest(List<String> args, {String workingDirectory, 17 ProcessResult runUnittest(List<String> args, {String workingDirectory,
19 Map<String, String> environment}) { 18 Map<String, String> environment}) {
20 var allArgs = [ 19 var allArgs = [
21 p.join(packageDir, 'bin/unittest.dart'), 20 p.join(packageDir, 'bin/unittest.dart'),
22 "--package-root=${p.join(packageDir, 'packages')}" 21 "--package-root=${p.join(packageDir, 'packages')}"
23 ]..addAll(args); 22 ]..addAll(args);
24 23
25 if (environment == null) environment = {}; 24 if (environment == null) environment = {};
26 environment.putIfAbsent("_UNITTEST_USE_COLOR", () => "false"); 25 environment.putIfAbsent("_UNITTEST_USE_COLOR", () => "false");
27 26
28 // TODO(nweiz): Use ScheduledProcess once it's compatible. 27 // TODO(nweiz): Use ScheduledProcess once it's compatible.
29 return runDart(allArgs, workingDirectory: workingDirectory, 28 return runDart(allArgs, workingDirectory: workingDirectory,
30 environment: environment); 29 environment: environment);
31 } 30 }
32 31
33 /// Runs Dart. 32 /// Runs Dart.
34 ProcessResult runDart(List<String> args, {String workingDirectory, 33 ProcessResult runDart(List<String> args, {String workingDirectory,
35 Map<String, String> environment}) { 34 Map<String, String> environment}) {
36 var allArgs = Platform.executableArguments.toList()..addAll(args); 35 var allArgs = Platform.executableArguments.toList()..addAll(args);
37 36
38 // TODO(nweiz): Use ScheduledProcess once it's compatible. 37 // TODO(nweiz): Use ScheduledProcess once it's compatible.
39 return Process.runSync(Platform.executable, allArgs, 38 return Process.runSync(Platform.executable, allArgs,
40 workingDirectory: workingDirectory, environment: environment); 39 workingDirectory: workingDirectory, environment: environment);
41 } 40 }
42
43 /// Returns the path to the library named [libraryName].
44 ///
45 /// The library name must be globally unique, or the wrong library path may be
46 /// returned.
47 String _libraryPath(Symbol libraryName) {
48 var lib = currentMirrorSystem().findLibrary(libraryName);
49 return p.fromUri(lib.uri);
50 }
OLDNEW
« lib/src/runner/loader.dart ('K') | « pubspec.yaml ('k') | test/runner/loader_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698