| OLD | NEW |
| 1 # Copyright (c) 2016 Google Inc. All rights reserved. | 1 # Copyright (c) 2016 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 import optparse | 29 import optparse |
| 30 import unittest | 30 import unittest |
| 31 | 31 |
| 32 from webkitpy.common.system.outputcapture import OutputCapture | 32 from webkitpy.common.system.output_capture import OutputCapture |
| 33 from webkitpy.tool.commands.command import Command | 33 from webkitpy.tool.commands.command import Command |
| 34 | 34 |
| 35 | 35 |
| 36 class TrivialCommand(Command): | 36 class TrivialCommand(Command): |
| 37 name = "trivial" | 37 name = "trivial" |
| 38 help_text = "help text" | 38 help_text = "help text" |
| 39 long_help = "trivial command long help text" | 39 long_help = "trivial command long help text" |
| 40 show_in_main_help = True | 40 show_in_main_help = True |
| 41 | 41 |
| 42 def __init__(self, **kwargs): | 42 def __init__(self, **kwargs): |
| (...skipping 29 matching lines...) Expand all Loading... |
| 72 | 72 |
| 73 def test_required_arguments(self): | 73 def test_required_arguments(self): |
| 74 class TrivialCommandWithRequiredAndOptionalArgs(TrivialCommand): | 74 class TrivialCommandWithRequiredAndOptionalArgs(TrivialCommand): |
| 75 argument_names = "ARG1 ARG2 [ARG3]" | 75 argument_names = "ARG1 ARG2 [ARG3]" |
| 76 two_required_arguments = TrivialCommandWithRequiredAndOptionalArgs() | 76 two_required_arguments = TrivialCommandWithRequiredAndOptionalArgs() |
| 77 expected_logs = ("2 arguments required, 1 argument provided. Provided:
'foo' Required: ARG1 ARG2\n" | 77 expected_logs = ("2 arguments required, 1 argument provided. Provided:
'foo' Required: ARG1 ARG2\n" |
| 78 "See 'dummy-tool help trivial' for usage.\n") | 78 "See 'dummy-tool help trivial' for usage.\n") |
| 79 exit_code = OutputCapture().assert_outputs(self, two_required_arguments.
check_arguments_and_execute, | 79 exit_code = OutputCapture().assert_outputs(self, two_required_arguments.
check_arguments_and_execute, |
| 80 [None, ["foo"], DummyTool()],
expected_logs=expected_logs) | 80 [None, ["foo"], DummyTool()],
expected_logs=expected_logs) |
| 81 self.assertEqual(exit_code, 1) | 81 self.assertEqual(exit_code, 1) |
| OLD | NEW |