| OLD | NEW |
| 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.unittest; | 5 library unittest.unittest; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'dart:isolate'; | 9 import 'dart:isolate'; |
| 10 | 10 |
| 11 import 'package:args/args.dart'; | 11 import 'package:args/args.dart'; |
| 12 import 'package:stack_trace/stack_trace.dart'; | 12 import 'package:stack_trace/stack_trace.dart'; |
| 13 | 13 |
| 14 import 'package:unittest/src/runner/console_reporter.dart'; | 14 import 'package:unittest/src/runner/reporter/compact.dart'; |
| 15 import 'package:unittest/src/runner/load_exception.dart'; | 15 import 'package:unittest/src/runner/load_exception.dart'; |
| 16 import 'package:unittest/src/runner/loader.dart'; | 16 import 'package:unittest/src/runner/loader.dart'; |
| 17 import 'package:unittest/src/util/exit_codes.dart' as exit_codes; | 17 import 'package:unittest/src/util/exit_codes.dart' as exit_codes; |
| 18 import 'package:unittest/src/util/io.dart'; | 18 import 'package:unittest/src/util/io.dart'; |
| 19 import 'package:unittest/src/utils.dart'; | 19 import 'package:unittest/src/utils.dart'; |
| 20 | 20 |
| 21 /// The argument parser used to parse the executable arguments. | 21 /// The argument parser used to parse the executable arguments. |
| 22 final _parser = new ArgParser(); | 22 final _parser = new ArgParser(); |
| 23 | 23 |
| 24 void main(List<String> args) { | 24 void main(List<String> args) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 55 } | 55 } |
| 56 | 56 |
| 57 return Future.wait(paths.map((path) { | 57 return Future.wait(paths.map((path) { |
| 58 if (new Directory(path).existsSync()) return loader.loadDir(path); | 58 if (new Directory(path).existsSync()) return loader.loadDir(path); |
| 59 if (new File(path).existsSync()) return loader.loadFile(path); | 59 if (new File(path).existsSync()) return loader.loadFile(path); |
| 60 throw new LoadException(path, 'Does not exist.'); | 60 throw new LoadException(path, 'Does not exist.'); |
| 61 })); | 61 })); |
| 62 }).then((suites) { | 62 }).then((suites) { |
| 63 var color = options["color"]; | 63 var color = options["color"]; |
| 64 if (color == null) color = canUseSpecialChars; | 64 if (color == null) color = canUseSpecialChars; |
| 65 var reporter = new ConsoleReporter(flatten(suites), color: color); | 65 var reporter = new CompactReporter(flatten(suites), color: color); |
| 66 return reporter.run().then((success) { | 66 return reporter.run().then((success) { |
| 67 exitCode = success ? 0 : 1; | 67 exitCode = success ? 0 : 1; |
| 68 }).whenComplete(() => reporter.close()); | 68 }).whenComplete(() => reporter.close()); |
| 69 }).catchError((error, stackTrace) { | 69 }).catchError((error, stackTrace) { |
| 70 if (error is LoadException) { | 70 if (error is LoadException) { |
| 71 // TODO(nweiz): color this message? | 71 // TODO(nweiz): color this message? |
| 72 stderr.writeln(getErrorMessage(error)); | 72 stderr.writeln(getErrorMessage(error)); |
| 73 | 73 |
| 74 // Only print stack traces for load errors that come from the user's | 74 // Only print stack traces for load errors that come from the user's |
| 75 if (error.innerError is! IOException && | 75 if (error.innerError is! IOException && |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 output = stderr; | 112 output = stderr; |
| 113 } | 113 } |
| 114 | 114 |
| 115 output.write("""$message | 115 output.write("""$message |
| 116 | 116 |
| 117 Usage: pub run unittest:unittest [files or directories...] | 117 Usage: pub run unittest:unittest [files or directories...] |
| 118 | 118 |
| 119 ${_parser.usage} | 119 ${_parser.usage} |
| 120 """); | 120 """); |
| 121 } | 121 } |
| OLD | NEW |