| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub | 5 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub |
| 6 /// tests are integration tests that stage some stuff on the file system, run | 6 /// tests are integration tests that stage some stuff on the file system, run |
| 7 /// pub, and then validate the results. This library provides an API to build | 7 /// pub, and then validate the results. This library provides an API to build |
| 8 /// tests like that. | 8 /// tests like that. |
| 9 library test_pub; | 9 library test_pub; |
| 10 | 10 |
| 11 import 'dart:async'; | 11 import 'dart:async'; |
| 12 import 'dart:convert'; |
| 12 import 'dart:io'; | 13 import 'dart:io'; |
| 13 import 'dart:json' as json; | 14 import 'dart:json' as json; |
| 14 import 'dart:math'; | 15 import 'dart:math'; |
| 15 | 16 |
| 16 import 'package:http/testing.dart'; | 17 import 'package:http/testing.dart'; |
| 17 import 'package:path/path.dart' as path; | 18 import 'package:path/path.dart' as path; |
| 18 import 'package:scheduled_test/scheduled_process.dart'; | 19 import 'package:scheduled_test/scheduled_process.dart'; |
| 19 import 'package:scheduled_test/scheduled_server.dart'; | 20 import 'package:scheduled_test/scheduled_server.dart'; |
| 20 import 'package:scheduled_test/scheduled_test.dart'; | 21 import 'package:scheduled_test/scheduled_test.dart'; |
| 21 import 'package:unittest/compact_vm_config.dart'; | 22 import 'package:unittest/compact_vm_config.dart'; |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 /// A subclass of [ScheduledProcess] that parses pub's verbose logging output | 495 /// A subclass of [ScheduledProcess] that parses pub's verbose logging output |
| 495 /// and makes [nextLine], [nextErrLine], [remainingStdout], and | 496 /// and makes [nextLine], [nextErrLine], [remainingStdout], and |
| 496 /// [remainingStderr] work as though pub weren't running in verbose mode. | 497 /// [remainingStderr] work as though pub weren't running in verbose mode. |
| 497 class PubProcess extends ScheduledProcess { | 498 class PubProcess extends ScheduledProcess { |
| 498 Stream<Pair<log.Level, String>> _log; | 499 Stream<Pair<log.Level, String>> _log; |
| 499 Stream<String> _stdout; | 500 Stream<String> _stdout; |
| 500 Stream<String> _stderr; | 501 Stream<String> _stderr; |
| 501 | 502 |
| 502 PubProcess.start(executable, arguments, | 503 PubProcess.start(executable, arguments, |
| 503 {workingDirectory, environment, String description, | 504 {workingDirectory, environment, String description, |
| 504 Encoding encoding: Encoding.UTF_8}) | 505 Encoding encoding: UTF8}) |
| 505 : super.start(executable, arguments, | 506 : super.start(executable, arguments, |
| 506 workingDirectory: workingDirectory, | 507 workingDirectory: workingDirectory, |
| 507 environment: environment, | 508 environment: environment, |
| 508 description: description, | 509 description: description, |
| 509 encoding: encoding); | 510 encoding: encoding); |
| 510 | 511 |
| 511 Stream<Pair<log.Level, String>> _logStream() { | 512 Stream<Pair<log.Level, String>> _logStream() { |
| 512 if (_log == null) { | 513 if (_log == null) { |
| 513 _log = mergeStreams( | 514 _log = mergeStreams( |
| 514 _outputToLog(super.stdoutStream(), log.Level.MESSAGE), | 515 _outputToLog(super.stdoutStream(), log.Level.MESSAGE), |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 bool matches(item, Map matchState) { | 789 bool matches(item, Map matchState) { |
| 789 if (item is! Pair) return false; | 790 if (item is! Pair) return false; |
| 790 return _firstMatcher.matches(item.first, matchState) && | 791 return _firstMatcher.matches(item.first, matchState) && |
| 791 _lastMatcher.matches(item.last, matchState); | 792 _lastMatcher.matches(item.last, matchState); |
| 792 } | 793 } |
| 793 | 794 |
| 794 Description describe(Description description) { | 795 Description describe(Description description) { |
| 795 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 796 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
| 796 } | 797 } |
| 797 } | 798 } |
| OLD | NEW |