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

Side by Side Diff: test/io.dart

Issue 933083002: Add a test runner executable. (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: fix loader_test? Created 5 years, 10 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 8
9 import 'package:path/path.dart' as p; 9 import 'package:path/path.dart' as p;
10 import 'package:stack_trace/stack_trace.dart'; 10 import 'package:stack_trace/stack_trace.dart';
11 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
kevmoo 2015/02/19 01:54:08 unused import
12 12
13 /// The root directory of the `unittest` package. 13 /// The root directory of the `unittest` package.
14 final String packageDir = _computePackageDir(); 14 final String packageDir = _computePackageDir();
15 String _computePackageDir() { 15 String _computePackageDir() {
16 var trace = new Trace.current(); 16 var trace = new Trace.current();
17 return p.dirname(p.dirname(p.fromUri(trace.frames.first.uri))); 17 return p.dirname(p.dirname(p.fromUri(trace.frames.first.uri)));
18 } 18 }
19 19
20 /// Returns a matcher that matches a [FileSystemException] with the given 20 /// Runs the unittest executable with the package root set properly.
21 /// [message]. 21 ProcessResult runUnittest(List<String> args, {String workingDirectory}) {
22 Matcher isFileSystemException(String message) => predicate( 22 var allArgs = Platform.executableArguments.toList()
23 (error) => error is FileSystemException && error.message == message, 23 ..add(p.join(packageDir, 'bin/unittest.dart'))
24 'is a FileSystemException with message "$message"'); 24 ..add("--package-root=${p.join(packageDir, 'packages')}")
25 ..addAll(args);
25 26
27 // TODO(nweiz): Use ScheduledProcess once it's compatible.
28 return Process.runSync(Platform.executable, allArgs,
29 workingDirectory: workingDirectory);
30 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698