OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
727 } | 727 } |
728 } | 728 } |
729 | 729 |
730 void _validateOutputString(List<String> failures, String pipe, | 730 void _validateOutputString(List<String> failures, String pipe, |
731 String expectedText, List<String> actual) { | 731 String expectedText, List<String> actual) { |
732 final expected = expectedText.split('\n'); | 732 final expected = expectedText.split('\n'); |
733 | 733 |
734 // Strip off the last line. This lets us have expected multiline strings | 734 // Strip off the last line. This lets us have expected multiline strings |
735 // where the closing ''' is on its own line. It also fixes '' expected output | 735 // where the closing ''' is on its own line. It also fixes '' expected output |
736 // to expect zero lines of output, not a single empty line. | 736 // to expect zero lines of output, not a single empty line. |
737 expected.removeLast(); | 737 if (expected.last.trim() == '') { |
nweiz
2013/02/13 00:23:32
Are there cases where we're not printing trailing
Bob Nystrom
2013/02/13 00:52:58
I don't think so. The 'if' here allows you to vali
| |
738 expected.removeLast(); | |
739 } | |
738 | 740 |
739 var results = []; | 741 var results = []; |
740 var failed = false; | 742 var failed = false; |
741 | 743 |
742 // Compare them line by line to see which ones match. | 744 // Compare them line by line to see which ones match. |
743 var length = max(expected.length, actual.length); | 745 var length = max(expected.length, actual.length); |
744 for (var i = 0; i < length; i++) { | 746 for (var i = 0; i < length; i++) { |
745 if (i >= actual.length) { | 747 if (i >= actual.length) { |
746 // Missing output. | 748 // Missing output. |
747 failed = true; | 749 failed = true; |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1599 /// calling [completion] is unnecessary. | 1601 /// calling [completion] is unnecessary. |
1600 void expectLater(Future actual, matcher, {String reason, | 1602 void expectLater(Future actual, matcher, {String reason, |
1601 FailureHandler failureHandler, bool verbose: false}) { | 1603 FailureHandler failureHandler, bool verbose: false}) { |
1602 _schedule((_) { | 1604 _schedule((_) { |
1603 return actual.then((value) { | 1605 return actual.then((value) { |
1604 expect(value, matcher, reason: reason, failureHandler: failureHandler, | 1606 expect(value, matcher, reason: reason, failureHandler: failureHandler, |
1605 verbose: false); | 1607 verbose: false); |
1606 }); | 1608 }); |
1607 }); | 1609 }); |
1608 } | 1610 } |
OLD | NEW |