From 612ca3a09dc8a51f4bd1855ec161c7d7a2708933 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum <nweiz@google.com> Date: Thu, 19 Feb 2015 15:17:55 -0800 Subject: [PATCH] Fix the tests from the latest CL. This ensures that console_reporter_test isn't run on browsers, and improves the path detection for test/io.dart. R=kevmoo@google.com Review URL: https://codereview.chromium.org//944553002 --- .status | 1 + test/io.dart | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.status b/.status index b1e4dbea..b43df788 100644 --- a/.status +++ b/.status @@ -25,6 +25,7 @@ lib/*/*/*/*: SkipByDesign # dart:io-specific tests. [ $browser ] +test/console_reporter_test: SkipByDesign test/loader_test: SkipByDesign test/runner_test: SkipByDesign test/vm_listener_test: SkipByDesign diff --git a/test/io.dart b/test/io.dart index 1dbc377e..fc545621 100644 --- a/test/io.dart +++ b/test/io.dart @@ -5,16 +5,15 @@ library unittest.test.io; import 'dart:io'; +import 'dart:mirrors'; import 'package:path/path.dart' as p; import 'package:stack_trace/stack_trace.dart'; /// The root directory of the `unittest` package. final String packageDir = _computePackageDir(); -String _computePackageDir() { - var trace = new Trace.current(); - return p.dirname(p.dirname(p.fromUri(trace.frames.first.uri))); -} +String _computePackageDir() => + p.dirname(p.dirname(_libraryPath(#unittest.test.io))); /// Runs the unittest executable with the package root set properly. ProcessResult runUnittest(List<String> args, {String workingDirectory}) { @@ -27,3 +26,14 @@ ProcessResult runUnittest(List<String> args, {String workingDirectory}) { return Process.runSync(Platform.executable, allArgs, workingDirectory: workingDirectory); } + +/// Returns the path to the library named [libraryName]. +/// +/// The library name must be globally unique, or the wrong library path may be +/// returned. +String _libraryPath(Symbol libraryName) { + var lib = currentMirrorSystem().findLibrary(libraryName); + return p.fromUri(lib.uri); +} + + -- GitLab