PageRenderTime 46ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/src/qt/qtwebkit/Tools/Scripts/webkitpy/tool/steps/haslanded_unittest.py

https://gitlab.com/x33n/phantomjs
Python | 299 lines | 266 code | 5 blank | 28 comment | 0 complexity | 1666a73e8b183fc582946372b3733faa MD5 | raw file
  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. import unittest2 as unittest
  29. import subprocess
  30. from webkitpy.tool.steps.haslanded import HasLanded
  31. class HasLandedTest(unittest.TestCase):
  32. maxDiff = None
  33. @unittest.skipUnless(subprocess.call('which interdiff', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0, "requires interdiff")
  34. def test_run(self):
  35. # These patches require trailing whitespace to remain valid patches.
  36. diff1 = """\
  37. Index: a.py
  38. ===================================================================
  39. --- a.py
  40. +++ a.py
  41. @@ -1,3 +1,5 @@
  42. A
  43. B
  44. C
  45. +D
  46. +E
  47. Index: b.py
  48. ===================================================================
  49. --- b.py 2013-01-21 15:20:59.693887185 +1100
  50. +++ b.py 2013-01-21 15:22:24.382555711 +1100
  51. @@ -1,3 +1,5 @@
  52. 1
  53. 2
  54. 3
  55. +4
  56. +5
  57. """
  58. diff1_add_line = """\
  59. Index: a.py
  60. ===================================================================
  61. --- a.py
  62. +++ a.py
  63. @@ -1,3 +1,6 @@
  64. A
  65. B
  66. C
  67. +D
  68. +E
  69. +F
  70. Index: b.py
  71. ===================================================================
  72. --- b.py
  73. +++ b.py
  74. @@ -1,3 +1,5 @@
  75. 1
  76. 2
  77. 3
  78. +4
  79. +5
  80. """
  81. diff1_remove_line = """\
  82. Index: a.py
  83. ===================================================================
  84. --- a.py
  85. +++ a.py
  86. @@ -1,3 +1,4 @@
  87. A
  88. B
  89. C
  90. +D
  91. Index: b.py
  92. ===================================================================
  93. --- b.py
  94. +++ b.py
  95. @@ -1,3 +1,5 @@
  96. 1
  97. 2
  98. 3
  99. +4
  100. +5
  101. """
  102. diff1_add_file = diff1 + """\
  103. Index: c.py
  104. ===================================================================
  105. --- c.py
  106. +++ c.py
  107. @@ -1,3 +1,5 @@
  108. 1
  109. 2
  110. 3
  111. +4
  112. +5
  113. """
  114. diff1_remove_file = """\
  115. Index: a.py
  116. ===================================================================
  117. --- a.py
  118. +++ a.py
  119. @@ -1,3 +1,5 @@
  120. A
  121. B
  122. C
  123. +D
  124. +E
  125. """
  126. self.assertMultiLineEqual(
  127. HasLanded.diff_diff(diff1, diff1_add_line, '', 'add-line'),
  128. """\
  129. diff -u a.py a.py
  130. --- a.py
  131. +++ a.py
  132. @@ -5,0 +6 @@
  133. +F
  134. """)
  135. self.assertMultiLineEqual(
  136. HasLanded.diff_diff(diff1, diff1_remove_line, '', 'remove-line'),
  137. """\
  138. diff -u a.py a.py
  139. --- a.py
  140. +++ a.py
  141. @@ -5 +4,0 @@
  142. -E
  143. """)
  144. self.assertMultiLineEqual(
  145. HasLanded.diff_diff(diff1, diff1_add_file, '', 'add-file'),
  146. """\
  147. only in patch2:
  148. unchanged:
  149. --- c.py
  150. +++ c.py
  151. @@ -1,3 +1,5 @@
  152. 1
  153. 2
  154. 3
  155. +4
  156. +5
  157. """)
  158. self.assertMultiLineEqual(
  159. HasLanded.diff_diff(diff1, diff1_remove_file, '', 'remove-file'),
  160. """\
  161. reverted:
  162. --- b.py 2013-01-21 15:22:24.382555711 +1100
  163. +++ b.py 2013-01-21 15:20:59.693887185 +1100
  164. @@ -1,5 +1,3 @@
  165. 1
  166. 2
  167. 3
  168. -4
  169. -5
  170. """)
  171. def test_convert_to_svn_and_strip_change_log(self):
  172. # These patches require trailing whitespace to remain valid patches.
  173. testbefore1 = HasLanded.convert_to_svn("""\
  174. diff --git a/Tools/ChangeLog b/Tools/ChangeLog
  175. index 219ba72..0390b73 100644
  176. --- a/Tools/ChangeLog
  177. +++ b/Tools/ChangeLog
  178. @@ -1,3 +1,32 @@
  179. +2013-01-17 Tim 'mithro' Ansell <mithro@mithis.com>
  180. +
  181. + Adding "has-landed" command to webkit-patch which allows a person to
  182. + Reviewed by NOBODY (OOPS!).
  183. +
  184. 2013-01-20 Tim 'mithro' Ansell <mithro@mithis.com>
  185. Extend diff_parser to support the --full-index output.
  186. diff --git a/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py b/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
  187. index 4bf8ec6..3a128cb 100644
  188. --- a/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
  189. +++ b/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
  190. @@ -28,6 +28,8 @@
  191. +import re
  192. +
  193. from .attachment import Attachment
  194. """)
  195. testafter1 = HasLanded.convert_to_svn("""\
  196. diff --git a/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py b/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
  197. index 4bf8ec6..3a128cb 100644
  198. --- a/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
  199. +++ b/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
  200. @@ -28,6 +28,8 @@
  201. +import re
  202. +
  203. from .attachment import Attachment
  204. diff --git a/Tools/ChangeLog b/Tools/ChangeLog
  205. index 219ba72..0390b73 100644
  206. --- a/Tools/ChangeLog
  207. +++ b/Tools/ChangeLog
  208. @@ -1,3 +1,32 @@
  209. +2013-01-17 Tim 'mithro' Ansell <mithro@mithis.com>
  210. +
  211. + Adding "has-landed" command to webkit-patch which allows a person to
  212. + Reviewed by NOBODY (OOPS!).
  213. +
  214. 2013-01-20 Tim 'mithro' Ansell <mithro@mithis.com>
  215. Extend diff_parser to support the --full-index output.
  216. """)
  217. testexpected1 = """\
  218. Index: Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
  219. ===================================================================
  220. --- Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
  221. +++ Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
  222. @@ -28,6 +28,8 @@
  223. +import re
  224. +
  225. from .attachment import Attachment
  226. """
  227. testmiddle1 = HasLanded.convert_to_svn("""\
  228. diff --git a/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py b/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
  229. index 4bf8ec6..3a128cb 100644
  230. --- a/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
  231. +++ b/Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
  232. @@ -28,6 +28,8 @@
  233. +import re
  234. +
  235. from .attachment import Attachment
  236. diff --git a/ChangeLog b/ChangeLog
  237. index 219ba72..0390b73 100644
  238. --- a/ChangeLog
  239. +++ b/ChangeLog
  240. @@ -1,3 +1,32 @@
  241. +2013-01-17 Tim 'mithro' Ansell <mithro@mithis.com>
  242. +
  243. + Adding "has-landed" command to webkit-patch which allows a person to
  244. + Reviewed by NOBODY (OOPS!).
  245. +
  246. 2013-01-20 Tim 'mithro' Ansell <mithro@mithis.com>
  247. Extend diff_parser to support the --full-index output.
  248. diff --git a/Tools/Scripts/webkitpy/common/other.py b/Tools/Scripts/webkitpy/common/other.py
  249. index 4bf8ec6..3a128cb 100644
  250. --- a/Tools/Scripts/webkitpy/common/other.py
  251. +++ b/Tools/Scripts/webkitpy/common/other.py
  252. @@ -28,6 +28,8 @@
  253. +import re
  254. +
  255. from .attachment import Attachment
  256. """)
  257. testexpected2 = """\
  258. Index: Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
  259. ===================================================================
  260. --- Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
  261. +++ Tools/Scripts/webkitpy/common/net/bugzilla/bug.py
  262. @@ -28,6 +28,8 @@
  263. +import re
  264. +
  265. from .attachment import Attachment
  266. Index: Tools/Scripts/webkitpy/common/other.py
  267. ===================================================================
  268. --- Tools/Scripts/webkitpy/common/other.py
  269. +++ Tools/Scripts/webkitpy/common/other.py
  270. @@ -28,6 +28,8 @@
  271. +import re
  272. +
  273. from .attachment import Attachment
  274. """
  275. self.assertMultiLineEqual(testexpected1, HasLanded.strip_change_log(testbefore1))
  276. self.assertMultiLineEqual(testexpected1, HasLanded.strip_change_log(testafter1))
  277. self.assertMultiLineEqual(testexpected2, HasLanded.strip_change_log(testmiddle1))