OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:convert'; | 5 import 'dart:convert'; |
6 // We need to use the 'io' prefix here, otherwise io.exitCode will shadow | 6 // We need to use the 'io' prefix here, otherwise io.exitCode will shadow |
7 // CommandOutput.exitCode in subclasses of CommandOutput. | 7 // CommandOutput.exitCode in subclasses of CommandOutput. |
8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
9 | 9 |
10 import 'browser_controller.dart'; | 10 import 'browser_controller.dart'; |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 if (exitCode != 0) return Expectation.pass; | 753 if (exitCode != 0) return Expectation.pass; |
754 return Expectation.missingRuntimeError; | 754 return Expectation.missingRuntimeError; |
755 } | 755 } |
756 | 756 |
757 var outcome = exitCode == 0 ? Expectation.pass : Expectation.runtimeError; | 757 var outcome = exitCode == 0 ? Expectation.pass : Expectation.runtimeError; |
758 outcome = _negateOutcomeIfIncompleteAsyncTest(outcome, decodeUtf8(stdout)); | 758 outcome = _negateOutcomeIfIncompleteAsyncTest(outcome, decodeUtf8(stdout)); |
759 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); | 759 return _negateOutcomeIfNegativeTest(outcome, testCase.isNegative); |
760 } | 760 } |
761 } | 761 } |
762 | 762 |
763 class PubCommandOutput extends CommandOutput { | |
764 PubCommandOutput(PubCommand command, int exitCode, bool timedOut, | |
765 List<int> stdout, List<int> stderr, Duration time) | |
766 : super(command, exitCode, timedOut, stdout, stderr, time, false, 0); | |
767 | |
768 Expectation result(TestCase testCase) { | |
769 // Handle crashes and timeouts first. | |
770 if (hasCrashed) return Expectation.crash; | |
771 if (hasTimedOut) return Expectation.timeout; | |
772 if (hasNonUtf8) return Expectation.nonUtf8Error; | |
773 | |
774 if (exitCode == 0) { | |
775 return Expectation.pass; | |
776 } else if ((command as PubCommand).command == 'get') { | |
777 return Expectation.pubGetError; | |
778 } else { | |
779 return Expectation.fail; | |
780 } | |
781 } | |
782 } | |
783 | |
784 class ScriptCommandOutput extends CommandOutput { | 763 class ScriptCommandOutput extends CommandOutput { |
785 final Expectation _result; | 764 final Expectation _result; |
786 | 765 |
787 ScriptCommandOutput(ScriptCommand command, this._result, | 766 ScriptCommandOutput(ScriptCommand command, this._result, |
788 String scriptExecutionInformation, Duration time) | 767 String scriptExecutionInformation, Duration time) |
789 : super(command, 0, false, [], [], time, false, 0) { | 768 : super(command, 0, false, [], [], time, false, 0) { |
790 var lines = scriptExecutionInformation.split("\n"); | 769 var lines = scriptExecutionInformation.split("\n"); |
791 diagnostics.addAll(lines); | 770 diagnostics.addAll(lines); |
792 } | 771 } |
793 | 772 |
(...skipping 29 matching lines...) Expand all Loading... |
823 if (command.displayName == 'precompiler' || | 802 if (command.displayName == 'precompiler' || |
824 command.displayName == 'app_jit') { | 803 command.displayName == 'app_jit') { |
825 return new VMCommandOutput( | 804 return new VMCommandOutput( |
826 command, exitCode, timedOut, stdout, stderr, time, pid); | 805 command, exitCode, timedOut, stdout, stderr, time, pid); |
827 } | 806 } |
828 return new CompilationCommandOutput( | 807 return new CompilationCommandOutput( |
829 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); | 808 command, exitCode, timedOut, stdout, stderr, time, compilationSkipped); |
830 } else if (command is JSCommandlineCommand) { | 809 } else if (command is JSCommandlineCommand) { |
831 return new JSCommandLineOutput( | 810 return new JSCommandLineOutput( |
832 command, exitCode, timedOut, stdout, stderr, time); | 811 command, exitCode, timedOut, stdout, stderr, time); |
833 } else if (command is PubCommand) { | |
834 return new PubCommandOutput( | |
835 command, exitCode, timedOut, stdout, stderr, time); | |
836 } | 812 } |
837 | 813 |
838 return new CommandOutput(command, exitCode, timedOut, stdout, stderr, time, | 814 return new CommandOutput(command, exitCode, timedOut, stdout, stderr, time, |
839 compilationSkipped, pid); | 815 compilationSkipped, pid); |
840 } | 816 } |
841 | 817 |
842 class UnittestSuiteMessagesMixin { | 818 class UnittestSuiteMessagesMixin { |
843 bool _isAsyncTest(String testOutput) { | 819 bool _isAsyncTest(String testOutput) { |
844 return testOutput.contains("unittest-suite-wait-for-done"); | 820 return testOutput.contains("unittest-suite-wait-for-done"); |
845 } | 821 } |
846 | 822 |
847 bool _isAsyncTestSuccessful(String testOutput) { | 823 bool _isAsyncTestSuccessful(String testOutput) { |
848 return testOutput.contains("unittest-suite-success"); | 824 return testOutput.contains("unittest-suite-success"); |
849 } | 825 } |
850 | 826 |
851 Expectation _negateOutcomeIfIncompleteAsyncTest( | 827 Expectation _negateOutcomeIfIncompleteAsyncTest( |
852 Expectation outcome, String testOutput) { | 828 Expectation outcome, String testOutput) { |
853 // If this is an asynchronous test and the asynchronous operation didn't | 829 // If this is an asynchronous test and the asynchronous operation didn't |
854 // complete successfully, it's outcome is Expectation.FAIL. | 830 // complete successfully, it's outcome is Expectation.FAIL. |
855 // TODO: maybe we should introduce a AsyncIncomplete marker or so | 831 // TODO: maybe we should introduce a AsyncIncomplete marker or so |
856 if (outcome == Expectation.pass) { | 832 if (outcome == Expectation.pass) { |
857 if (_isAsyncTest(testOutput) && !_isAsyncTestSuccessful(testOutput)) { | 833 if (_isAsyncTest(testOutput) && !_isAsyncTestSuccessful(testOutput)) { |
858 return Expectation.fail; | 834 return Expectation.fail; |
859 } | 835 } |
860 } | 836 } |
861 return outcome; | 837 return outcome; |
862 } | 838 } |
863 } | 839 } |
OLD | NEW |