1 # Copyright (C) 2009 Google Inc. All rights reserved. 2 # 3 # Redistribution and use in source and binary forms, with or without 4 # modification, are permitted provided that the following conditions are 5 # met: 6 # 7 # * Redistributions of source code must retain the above copyright 8 # notice, this list of conditions and the following disclaimer. 9 # * Redistributions in binary form must reproduce the above 10 # copyright notice, this list of conditions and the following disclaimer 11 # in the documentation and/or other materials provided with the 12 # distribution. 13 # * Neither the name of Google Inc. nor the names of its 14 # contributors may be used to endorse or promote products derived from 15 # this software without specific prior written permission. 16 # 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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. 28 29 from webkitpy.commands.commandtest import CommandsTest 30 from webkitpy.commands.download import * 31 from webkitpy.mock import Mock 32 33 class DownloadCommandsTest(CommandsTest): 34 def _default_options(self): 35 options = Mock() 36 options.force_clean = False 37 options.clean = True 38 options.check_builders = True 39 options.quiet = False 40 options.non_interactive = False 41 options.update = True 42 options.build = True 43 options.test = True 44 options.close_bug = True 45 options.complete_rollout = False 46 return options 47 48 def test_build(self): 49 expected_stderr = "Updating working directory\nBuilding WebKit\n" 50 self.assert_execute_outputs(Build(), [], options=self._default_options(), expected_stderr=expected_stderr) 51 52 def test_build_and_test(self): 53 expected_stderr = "Updating working directory\nBuilding WebKit\nRunning Python unit tests\nRunning Perl unit tests\nRunning JavaScriptCore tests\nRunning run-webkit-tests\n" 54 self.assert_execute_outputs(BuildAndTest(), [], options=self._default_options(), expected_stderr=expected_stderr) 55 56 def test_apply_attachment(self): 57 options = self._default_options() 58 options.update = True 59 options.local_commit = True 60 expected_stderr = "Updating working directory\nProcessing 1 patch from 1 bug.\nProcessing patch 197 from bug 42.\n" 61 self.assert_execute_outputs(ApplyAttachment(), [197], options=options, expected_stderr=expected_stderr) 62 63 def test_apply_patches(self): 64 options = self._default_options() 65 options.update = True 66 options.local_commit = True 67 expected_stderr = "Updating working directory\n2 reviewed patches found on bug 42.\nProcessing 2 patches from 1 bug.\nProcessing patch 197 from bug 42.\nProcessing patch 128 from bug 42.\n" 68 self.assert_execute_outputs(ApplyFromBug(), [42], options=options, expected_stderr=expected_stderr) 69 70 def test_land_diff(self): 71 expected_stderr = "Building WebKit\nRunning Python unit tests\nRunning Perl unit tests\nRunning JavaScriptCore tests\nRunning run-webkit-tests\nUpdating bug 42\n" 72 self.assert_execute_outputs(Land(), [42], options=self._default_options(), expected_stderr=expected_stderr) 73 74 def test_check_style(self): 75 expected_stderr = "Processing 1 patch from 1 bug.\nUpdating working directory\nProcessing patch 197 from bug 42.\nRunning check-webkit-style\n" 76 self.assert_execute_outputs(CheckStyle(), [197], options=self._default_options(), expected_stderr=expected_stderr) 77 78 def test_build_attachment(self): 79 expected_stderr = "Processing 1 patch from 1 bug.\nUpdating working directory\nProcessing patch 197 from bug 42.\nBuilding WebKit\n" 80 self.assert_execute_outputs(BuildAttachment(), [197], options=self._default_options(), expected_stderr=expected_stderr) 81 82 def test_land_attachment(self): 83 # FIXME: This expected result is imperfect, notice how it's seeing the same patch as still there after it thought it would have cleared the flags. 84 expected_stderr = """Processing 1 patch from 1 bug. 85 Updating working directory 86 Processing patch 197 from bug 42. 87 Building WebKit 88 Running Python unit tests 89 Running Perl unit tests 90 Running JavaScriptCore tests 91 Running run-webkit-tests 92 Not closing bug 42 as attachment 197 has review=+. Assuming there are more patches to land from this bug. 93 """ 94 self.assert_execute_outputs(LandAttachment(), [197], options=self._default_options(), expected_stderr=expected_stderr) 95 96 def test_land_patches(self): 97 # FIXME: This expected result is imperfect, notice how it's seeing the same patch as still there after it thought it would have cleared the flags. 98 expected_stderr = """2 reviewed patches found on bug 42. 99 Processing 2 patches from 1 bug. 100 Updating working directory 101 Processing patch 197 from bug 42. 102 Building WebKit 103 Running Python unit tests 104 Running Perl unit tests 105 Running JavaScriptCore tests 106 Running run-webkit-tests 107 Not closing bug 42 as attachment 197 has review=+. Assuming there are more patches to land from this bug. 108 Updating working directory 109 Processing patch 128 from bug 42. 110 Building WebKit 111 Running Python unit tests 112 Running Perl unit tests 113 Running JavaScriptCore tests 114 Running run-webkit-tests 115 Not closing bug 42 as attachment 197 has review=+. Assuming there are more patches to land from this bug. 116 """ 117 self.assert_execute_outputs(LandFromBug(), [42], options=self._default_options(), expected_stderr=expected_stderr) 118 119 def test_rollout(self): 120 expected_stderr = "Updating working directory\nRunning prepare-ChangeLog\n\nNOTE: Rollout support is experimental.\nPlease verify the rollout diff and use \"webkit-patch land 12345\" to commit the rollout.\n" 121 self.assert_execute_outputs(Rollout(), [852, "Reason"], options=self._default_options(), expected_stderr=expected_stderr) 122 123 def test_complete_rollout(self): 124 options = self._default_options() 125 options.complete_rollout = True 126 expected_stderr = "Will re-open bug 12345 after rollout.\nUpdating working directory\nRunning prepare-ChangeLog\nBuilding WebKit\n" 127 self.assert_execute_outputs(Rollout(), [852, "Reason"], options=options, expected_stderr=expected_stderr) 128