libv8 6.7.288.46.1 → 7.3.492.27.0beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (408) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -0
  3. data/CHANGELOG.md +4 -0
  4. data/README.md +2 -0
  5. data/ext/libv8/builder.rb +6 -2
  6. data/lib/libv8/version.rb +1 -1
  7. data/vendor/depot_tools/.gitattributes +1 -0
  8. data/vendor/depot_tools/.gitignore +7 -0
  9. data/vendor/depot_tools/CROS_OWNERS +5 -0
  10. data/vendor/depot_tools/OWNERS +12 -1
  11. data/vendor/depot_tools/PRESUBMIT.py +16 -9
  12. data/vendor/depot_tools/README.md +9 -2
  13. data/vendor/depot_tools/autoninja +14 -6
  14. data/vendor/depot_tools/autoninja.bat +11 -1
  15. data/vendor/depot_tools/autoninja.py +40 -18
  16. data/vendor/depot_tools/bb +12 -0
  17. data/vendor/depot_tools/bb.bat +7 -0
  18. data/vendor/depot_tools/bootstrap/win/manifest.txt +1 -1
  19. data/vendor/depot_tools/bootstrap/win/manifest_bleeding_edge.txt +1 -1
  20. data/vendor/depot_tools/bootstrap/win/win_tools.py +2 -1
  21. data/vendor/depot_tools/buildbucket.py +57 -4
  22. data/vendor/depot_tools/cipd +157 -44
  23. data/vendor/depot_tools/cipd.bat +51 -14
  24. data/vendor/depot_tools/cipd.ps1 +104 -42
  25. data/vendor/depot_tools/cipd_client_version +1 -1
  26. data/vendor/depot_tools/cipd_client_version.digests +21 -0
  27. data/vendor/depot_tools/cipd_manifest.txt +19 -6
  28. data/vendor/depot_tools/cipd_manifest.versions +318 -0
  29. data/vendor/depot_tools/clang_format.py +4 -4
  30. data/vendor/depot_tools/cpplint.py +44 -199
  31. data/vendor/depot_tools/dart_format.py +2 -2
  32. data/vendor/depot_tools/detect_host_arch.py +8 -3
  33. data/vendor/depot_tools/download_from_google_storage.py +47 -39
  34. data/vendor/depot_tools/fetch.py +30 -18
  35. data/vendor/depot_tools/fetch_configs/android_internal.py +34 -0
  36. data/vendor/depot_tools/fetch_configs/chromium.py +18 -1
  37. data/vendor/depot_tools/fetch_configs/config_util.py +4 -2
  38. data/vendor/depot_tools/fetch_configs/inspector_protocol.py +40 -0
  39. data/vendor/depot_tools/fetch_configs/node-ci.py +41 -0
  40. data/vendor/depot_tools/fix_encoding.py +3 -3
  41. data/vendor/depot_tools/gclient +1 -1
  42. data/vendor/depot_tools/gclient.py +415 -198
  43. data/vendor/depot_tools/gclient_eval.py +220 -171
  44. data/vendor/depot_tools/gclient_paths.py +142 -0
  45. data/vendor/depot_tools/gclient_scm.py +200 -51
  46. data/vendor/depot_tools/gclient_utils.py +88 -191
  47. data/vendor/depot_tools/gerrit_client.py +13 -0
  48. data/vendor/depot_tools/gerrit_util.py +158 -23
  49. data/vendor/depot_tools/git-nav-upstream +1 -1
  50. data/vendor/depot_tools/git_cache.py +77 -24
  51. data/vendor/depot_tools/git_cl.py +705 -1099
  52. data/vendor/depot_tools/git_common.py +9 -6
  53. data/vendor/depot_tools/git_map_branches.py +19 -2
  54. data/vendor/depot_tools/git_nav_downstream.py +3 -4
  55. data/vendor/depot_tools/git_rebase_update.py +14 -0
  56. data/vendor/depot_tools/git_reparent_branch.py +8 -2
  57. data/vendor/depot_tools/gn.py +38 -3
  58. data/vendor/depot_tools/gsutil.py +8 -3
  59. data/vendor/depot_tools/gsutil.py.bat +15 -0
  60. data/vendor/depot_tools/gsutil.vpython +16 -0
  61. data/vendor/depot_tools/infra/config/OWNERS +0 -1
  62. data/vendor/depot_tools/infra/config/recipes.cfg +3 -2
  63. data/vendor/depot_tools/lucicfg +12 -0
  64. data/vendor/depot_tools/lucicfg.bat +7 -0
  65. data/vendor/depot_tools/man/html/git-map-branches.html +34 -2
  66. data/vendor/depot_tools/man/html/git-new-branch.html +40 -32
  67. data/vendor/depot_tools/man/man1/git-map-branches.1 +24 -5
  68. data/vendor/depot_tools/man/man1/git-new-branch.1 +35 -27
  69. data/vendor/depot_tools/man/src/git-map-branches.demo.1.sh +1 -0
  70. data/vendor/depot_tools/man/src/git-map-branches.txt +10 -0
  71. data/vendor/depot_tools/man/src/git-new-branch.demo.1.sh +9 -4
  72. data/vendor/depot_tools/man/src/git-new-branch.txt +1 -1
  73. data/vendor/depot_tools/metrics.README.md +98 -0
  74. data/vendor/depot_tools/metrics.py +296 -0
  75. data/vendor/depot_tools/metrics_utils.py +303 -0
  76. data/vendor/depot_tools/my_activity.py +91 -29
  77. data/vendor/depot_tools/ninja +1 -1
  78. data/vendor/depot_tools/ninjalog.README.md +64 -0
  79. data/vendor/depot_tools/ninjalog_uploader.py +232 -0
  80. data/vendor/depot_tools/ninjalog_uploader_wrapper.py +116 -0
  81. data/vendor/depot_tools/owners.py +30 -13
  82. data/vendor/depot_tools/owners_finder.py +5 -2
  83. data/vendor/depot_tools/presubmit_canned_checks.py +188 -29
  84. data/vendor/depot_tools/presubmit_support.py +18 -41
  85. data/vendor/depot_tools/pylintrc +23 -19
  86. data/vendor/depot_tools/recipes/OWNERS +2 -0
  87. data/vendor/depot_tools/recipes/README.recipes.md +344 -151
  88. data/vendor/depot_tools/recipes/recipe_modules/bot_update/OWNERS +2 -0
  89. data/vendor/depot_tools/recipes/recipe_modules/bot_update/__init__.py +2 -16
  90. data/vendor/depot_tools/recipes/recipe_modules/bot_update/api.py +141 -99
  91. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic.json +5 -8
  92. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_luci.json +5 -8
  93. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_with_branch_heads.json +6 -98
  94. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/clobber.json +4 -9
  95. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/deprecated_got_revision_mapping.json +45 -5
  96. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_rebase_patch_ref.json +4 -9
  97. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_reset.json +4 -9
  98. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{tryjob.json → input_commit_with_id_without_repo.json} +6 -11
  99. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{tryjob_empty_revision.json → multiple_patch_refs.json} +8 -9
  100. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_apply_patch_on_gclient.json +19 -29
  101. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{trychange.json → refs.json} +4 -9
  102. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/reset_root_solution_revision.json +4 -9
  103. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json +51 -6
  104. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json +50 -6
  105. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json +51 -6
  106. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle.json +17 -25
  107. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_branch_heads.json +17 -25
  108. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_feature_branch.json +18 -26
  109. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8_feature_branch.json +18 -26
  110. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_webrtc.json +26 -28
  111. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8.json +45 -5
  112. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8_head_by_default.json +17 -25
  113. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/unrecognized_commit_repo.json +13 -0
  114. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_manifest_name.json +13 -152
  115. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_tags.json +4 -9
  116. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.py +185 -202
  117. data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/bot_update.py +52 -157
  118. data/vendor/depot_tools/recipes/recipe_modules/bot_update/test_api.py +5 -14
  119. data/vendor/depot_tools/recipes/recipe_modules/bot_update/tests/ensure_checkout.py +34 -0
  120. data/vendor/depot_tools/recipes/recipe_modules/cipd/api.py +14 -2
  121. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic.json +4 -5
  122. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic_pkg.json +4 -5
  123. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-failed.json +7 -5
  124. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-many-instances.json +4 -5
  125. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/mac64.json +4 -5
  126. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_file.json +9 -3
  127. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_mode.json +9 -3
  128. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_verfile.json +9 -3
  129. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/win64.json +4 -5
  130. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk arch.json +2 -3
  131. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk bits.json +2 -3
  132. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_32.json +2 -3
  133. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_64.json +2 -3
  134. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_32.json +2 -3
  135. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_64.json +2 -3
  136. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_mips_64.json +2 -3
  137. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/mac_intel_64.json +2 -3
  138. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_32.json +2 -3
  139. data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_64.json +2 -3
  140. data/vendor/depot_tools/recipes/recipe_modules/depot_tools/api.py +13 -8
  141. data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic.json +18 -12
  142. data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic_luci.json +18 -12
  143. data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/win.json +18 -12
  144. data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.py +3 -0
  145. data/vendor/depot_tools/recipes/recipe_modules/gclient/__init__.py +1 -0
  146. data/vendor/depot_tools/recipes/recipe_modules/gclient/api.py +58 -46
  147. data/vendor/depot_tools/recipes/recipe_modules/gclient/config.py +65 -22
  148. data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/basic.json +20 -21
  149. data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/buildbot.json +20 -21
  150. data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/revision.json +20 -21
  151. data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/tryserver.json +20 -21
  152. data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.py +5 -2
  153. data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/patch_project.py +62 -14
  154. data/vendor/depot_tools/recipes/recipe_modules/gerrit/api.py +24 -38
  155. data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +56 -50
  156. data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.py +15 -9
  157. data/vendor/depot_tools/recipes/recipe_modules/git/__init__.py +4 -1
  158. data/vendor/depot_tools/recipes/recipe_modules/git/api.py +34 -22
  159. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic.json +5 -6
  160. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_branch.json +5 -6
  161. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_file_name.json +5 -6
  162. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_hash.json +5 -6
  163. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_luci.json +222 -0
  164. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_ref.json +5 -6
  165. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_submodule_update_force.json +5 -6
  166. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_tags.json +224 -0
  167. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/can_fail_build.json +10 -6
  168. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cannot_fail_build.json +5 -7
  169. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cat-file_test.json +5 -6
  170. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_delta.json +5 -6
  171. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_failed.json +5 -7
  172. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output.json +5 -6
  173. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output_fails_build.json +10 -5
  174. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/curl_trace_file.json +5 -6
  175. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/git-cache-checkout.json +8 -9
  176. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/platform_win.json +5 -6
  177. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/rebase_failed.json +12 -8
  178. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/remote_not_origin.json +5 -6
  179. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/set_got_revision.json +5 -6
  180. data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.py +27 -11
  181. data/vendor/depot_tools/recipes/recipe_modules/git_cl/api.py +1 -1
  182. data/vendor/depot_tools/recipes/recipe_modules/git_cl/examples/full.expected/basic.json +12 -13
  183. data/vendor/depot_tools/recipes/recipe_modules/gitiles/__init__.py +5 -0
  184. data/vendor/depot_tools/recipes/recipe_modules/gitiles/api.py +120 -5
  185. data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.expected/basic.json +45 -3
  186. data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.py +25 -0
  187. data/vendor/depot_tools/recipes/recipe_modules/gitiles/resources/gerrit_client.py +56 -4
  188. data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/basic.json +6 -0
  189. data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.py +49 -0
  190. data/vendor/depot_tools/recipes/recipe_modules/gsutil/api.py +24 -13
  191. data/vendor/depot_tools/recipes/recipe_modules/gsutil/examples/full.expected/basic.json +13 -14
  192. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/basic.json +2 -3
  193. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_linux.json +2 -3
  194. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_mac.json +2 -3
  195. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_win.json +2 -3
  196. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_linux.json +2 -3
  197. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_mac.json +2 -3
  198. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_win.json +2 -3
  199. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_linux.json +2 -3
  200. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_mac.json +2 -3
  201. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_win.json +2 -3
  202. data/vendor/depot_tools/recipes/recipe_modules/infra_paths/path_config.py +1 -2
  203. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/__init__.py +35 -0
  204. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/api.py +116 -0
  205. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/linux.json +22 -0
  206. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/mac.json +82 -0
  207. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/win.json +22 -0
  208. data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.py +23 -0
  209. data/vendor/depot_tools/recipes/recipe_modules/presubmit/__init__.py +1 -0
  210. data/vendor/depot_tools/recipes/recipe_modules/presubmit/api.py +2 -7
  211. data/vendor/depot_tools/recipes/recipe_modules/presubmit/examples/full.expected/basic.json +7 -6
  212. data/vendor/depot_tools/recipes/recipe_modules/tryserver/__init__.py +1 -0
  213. data/vendor/depot_tools/recipes/recipe_modules/tryserver/api.py +117 -8
  214. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/basic_tags.json +4 -5
  215. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/set_failure_hash_with_no_steps.json +7 -4
  216. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json +98 -7
  217. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch_and_target_ref.json +147 -0
  218. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch.json +8 -5
  219. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch_luci.json +8 -5
  220. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch.json +9 -6
  221. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch_new.json +9 -6
  222. data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.py +27 -2
  223. data/vendor/depot_tools/recipes/recipe_modules/tryserver/test_api.py +14 -0
  224. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/__init__.py +25 -0
  225. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/api.py +137 -0
  226. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/linux.json +22 -0
  227. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/mac.json +22 -0
  228. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/win.json +107 -0
  229. data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.py +26 -0
  230. data/vendor/depot_tools/recipes/recipes.py +37 -27
  231. data/vendor/depot_tools/recipes/recipes/fetch_end_to_end_test.expected/basic.json +7 -10
  232. data/vendor/depot_tools/repo +34 -8
  233. data/vendor/depot_tools/roll_dep.py +52 -49
  234. data/vendor/depot_tools/scm.py +38 -23
  235. data/vendor/depot_tools/setup_color.py +4 -2
  236. data/vendor/depot_tools/split_cl.py +32 -4
  237. data/vendor/depot_tools/subprocess2.py +22 -4
  238. data/vendor/depot_tools/third_party/httplib2/README.chromium +2 -2
  239. data/vendor/depot_tools/third_party/httplib2/__init__.py +242 -158
  240. data/vendor/depot_tools/third_party/httplib2/cacerts.txt +57 -44
  241. data/vendor/depot_tools/third_party/httplib2/socks.py +15 -5
  242. data/vendor/depot_tools/third_party/logilab/README.chromium +2 -4
  243. data/vendor/depot_tools/third_party/logilab/astroid/README.chromium +2 -1
  244. data/vendor/depot_tools/third_party/logilab/astroid/__init__.py +10 -5
  245. data/vendor/depot_tools/third_party/logilab/astroid/__pkginfo__.py +5 -5
  246. data/vendor/depot_tools/third_party/logilab/astroid/arguments.py +233 -0
  247. data/vendor/depot_tools/third_party/logilab/astroid/as_string.py +82 -33
  248. data/vendor/depot_tools/third_party/logilab/astroid/bases.py +137 -153
  249. data/vendor/depot_tools/third_party/logilab/astroid/brain/{builtin_inference.py → brain_builtin_inference.py} +117 -26
  250. data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_dateutil.py +15 -0
  251. data/vendor/depot_tools/third_party/logilab/astroid/brain/{py2gi.py → brain_gi.py} +48 -8
  252. data/vendor/depot_tools/third_party/logilab/astroid/brain/{py2mechanize.py → brain_mechanize.py} +0 -0
  253. data/vendor/depot_tools/third_party/logilab/astroid/brain/{pynose.py → brain_nose.py} +4 -1
  254. data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_numpy.py +62 -0
  255. data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_pytest.py +76 -0
  256. data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_qt.py +44 -0
  257. data/vendor/depot_tools/third_party/logilab/astroid/brain/{pysix_moves.py → brain_six.py} +28 -1
  258. data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_ssl.py +65 -0
  259. data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_stdlib.py +473 -0
  260. data/vendor/depot_tools/third_party/logilab/astroid/builder.py +104 -81
  261. data/vendor/depot_tools/third_party/logilab/astroid/context.py +81 -0
  262. data/vendor/depot_tools/third_party/logilab/astroid/decorators.py +75 -0
  263. data/vendor/depot_tools/third_party/logilab/astroid/exceptions.py +20 -0
  264. data/vendor/depot_tools/third_party/logilab/astroid/inference.py +137 -183
  265. data/vendor/depot_tools/third_party/logilab/astroid/manager.py +45 -169
  266. data/vendor/depot_tools/third_party/logilab/astroid/mixins.py +37 -14
  267. data/vendor/depot_tools/third_party/logilab/astroid/modutils.py +112 -41
  268. data/vendor/depot_tools/third_party/logilab/astroid/node_classes.py +243 -156
  269. data/vendor/depot_tools/third_party/logilab/astroid/nodes.py +35 -22
  270. data/vendor/depot_tools/third_party/logilab/astroid/objects.py +186 -0
  271. data/vendor/depot_tools/third_party/logilab/astroid/protocols.py +157 -102
  272. data/vendor/depot_tools/third_party/logilab/astroid/raw_building.py +32 -8
  273. data/vendor/depot_tools/third_party/logilab/astroid/rebuilder.py +372 -309
  274. data/vendor/depot_tools/third_party/logilab/astroid/scoped_nodes.py +652 -420
  275. data/vendor/depot_tools/third_party/logilab/astroid/test_utils.py +4 -21
  276. data/vendor/depot_tools/third_party/logilab/astroid/transforms.py +96 -0
  277. data/vendor/depot_tools/third_party/logilab/astroid/util.py +89 -0
  278. data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/LICENSE +19 -0
  279. data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/README.chromium +11 -0
  280. data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/__init__.py +20 -0
  281. data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/cext.c +1421 -0
  282. data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/compat.py +9 -0
  283. data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/simple.py +246 -0
  284. data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/slots.py +414 -0
  285. data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/utils.py +13 -0
  286. data/vendor/depot_tools/third_party/logilab/wrapt/LICENSE +24 -0
  287. data/vendor/depot_tools/third_party/logilab/wrapt/README.chromium +11 -0
  288. data/vendor/depot_tools/third_party/logilab/wrapt/__init__.py +19 -0
  289. data/vendor/depot_tools/third_party/logilab/wrapt/_wrappers.c +2729 -0
  290. data/vendor/depot_tools/third_party/logilab/wrapt/arguments.py +96 -0
  291. data/vendor/depot_tools/third_party/logilab/wrapt/decorators.py +512 -0
  292. data/vendor/depot_tools/third_party/logilab/wrapt/importer.py +228 -0
  293. data/vendor/depot_tools/third_party/logilab/wrapt/wrappers.py +901 -0
  294. data/vendor/depot_tools/third_party/pylint/README.chromium +2 -25
  295. data/vendor/depot_tools/third_party/pylint/__pkginfo__.py +13 -3
  296. data/vendor/depot_tools/third_party/pylint/checkers/__init__.py +1 -2
  297. data/vendor/depot_tools/third_party/pylint/checkers/async.py +82 -0
  298. data/vendor/depot_tools/third_party/pylint/checkers/base.py +893 -119
  299. data/vendor/depot_tools/third_party/pylint/checkers/classes.py +342 -204
  300. data/vendor/depot_tools/third_party/pylint/checkers/design_analysis.py +51 -34
  301. data/vendor/depot_tools/third_party/pylint/checkers/exceptions.py +84 -47
  302. data/vendor/depot_tools/third_party/pylint/checkers/format.py +55 -30
  303. data/vendor/depot_tools/third_party/pylint/checkers/imports.py +314 -73
  304. data/vendor/depot_tools/third_party/pylint/checkers/logging.py +10 -8
  305. data/vendor/depot_tools/third_party/pylint/checkers/misc.py +2 -1
  306. data/vendor/depot_tools/third_party/pylint/checkers/newstyle.py +45 -48
  307. data/vendor/depot_tools/third_party/pylint/checkers/python3.py +31 -21
  308. data/vendor/depot_tools/third_party/pylint/checkers/raw_metrics.py +3 -3
  309. data/vendor/depot_tools/third_party/pylint/checkers/similar.py +4 -5
  310. data/vendor/depot_tools/third_party/pylint/checkers/spelling.py +24 -10
  311. data/vendor/depot_tools/third_party/pylint/checkers/stdlib.py +120 -56
  312. data/vendor/depot_tools/third_party/pylint/checkers/strings.py +38 -35
  313. data/vendor/depot_tools/third_party/pylint/checkers/typecheck.py +485 -138
  314. data/vendor/depot_tools/third_party/pylint/checkers/utils.py +319 -142
  315. data/vendor/depot_tools/third_party/pylint/checkers/variables.py +329 -207
  316. data/vendor/depot_tools/third_party/pylint/config.py +739 -76
  317. data/vendor/depot_tools/third_party/pylint/epylint.py +9 -5
  318. data/vendor/depot_tools/third_party/pylint/extensions/__init__.py +0 -0
  319. data/vendor/depot_tools/third_party/pylint/extensions/check_docs.py +311 -0
  320. data/vendor/depot_tools/third_party/pylint/extensions/check_elif.py +62 -0
  321. data/vendor/depot_tools/third_party/{logilab/common → pylint}/graph.py +30 -133
  322. data/vendor/depot_tools/third_party/pylint/gui.py +2 -2
  323. data/vendor/depot_tools/third_party/pylint/interfaces.py +21 -3
  324. data/vendor/depot_tools/third_party/pylint/lint.py +123 -140
  325. data/vendor/depot_tools/third_party/pylint/pyreverse/diadefslib.py +10 -13
  326. data/vendor/depot_tools/third_party/pylint/pyreverse/diagrams.py +15 -4
  327. data/vendor/depot_tools/third_party/pylint/pyreverse/inspector.py +372 -0
  328. data/vendor/depot_tools/third_party/pylint/pyreverse/main.py +30 -7
  329. data/vendor/depot_tools/third_party/pylint/pyreverse/utils.py +80 -2
  330. data/vendor/depot_tools/third_party/{logilab/common → pylint/pyreverse}/vcgutils.py +19 -37
  331. data/vendor/depot_tools/third_party/pylint/pyreverse/writer.py +3 -4
  332. data/vendor/depot_tools/third_party/pylint/reporters/__init__.py +34 -18
  333. data/vendor/depot_tools/third_party/pylint/reporters/guireporter.py +1 -1
  334. data/vendor/depot_tools/third_party/pylint/reporters/html.py +10 -3
  335. data/vendor/depot_tools/third_party/pylint/reporters/json.py +10 -4
  336. data/vendor/depot_tools/third_party/pylint/reporters/text.py +94 -3
  337. data/vendor/depot_tools/third_party/pylint/reporters/ureports/__init__.py +106 -0
  338. data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/html_writer.py +17 -57
  339. data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/nodes.py +52 -74
  340. data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/text_writer.py +14 -60
  341. data/vendor/depot_tools/third_party/pylint/testutils.py +22 -20
  342. data/vendor/depot_tools/third_party/pylint/utils.py +268 -44
  343. data/vendor/depot_tools/third_party/repo/progress.py +42 -0
  344. data/vendor/depot_tools/update_depot_tools +1 -1
  345. data/vendor/depot_tools/upload_metrics.py +25 -0
  346. data/vendor/depot_tools/win_toolchain/get_toolchain_if_necessary.py +45 -15
  347. data/vendor/depot_tools/win_toolchain/package_from_installed.py +71 -24
  348. data/vendor/depot_tools/yapf +1 -1
  349. data/vendor/depot_tools/yapf.bat +1 -1
  350. metadata +92 -77
  351. data/vendor/depot_tools/git-crsync +0 -3
  352. data/vendor/depot_tools/infra/config/cq.cfg +0 -32
  353. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref.json +0 -29
  354. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref_custom.json +0 -29
  355. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/buildbot.json +0 -105
  356. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/shallow.json +0 -195
  357. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle_deprecated.json +0 -248
  358. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8.json +0 -248
  359. data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_manifest_name_no_patch.json +0 -105
  360. data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/apply_gerrit.py +0 -33
  361. data/vendor/depot_tools/third_party/logilab/astroid/brain/py2pytest.py +0 -31
  362. data/vendor/depot_tools/third_party/logilab/astroid/brain/py2qt4.py +0 -22
  363. data/vendor/depot_tools/third_party/logilab/astroid/brain/py2stdlib.py +0 -334
  364. data/vendor/depot_tools/third_party/logilab/astroid/inspector.py +0 -273
  365. data/vendor/depot_tools/third_party/logilab/astroid/utils.py +0 -239
  366. data/vendor/depot_tools/third_party/logilab/common/LICENSE.txt +0 -339
  367. data/vendor/depot_tools/third_party/logilab/common/README.chromium +0 -11
  368. data/vendor/depot_tools/third_party/logilab/common/__init__.py +0 -175
  369. data/vendor/depot_tools/third_party/logilab/common/__pkginfo__.py +0 -57
  370. data/vendor/depot_tools/third_party/logilab/common/cache.py +0 -114
  371. data/vendor/depot_tools/third_party/logilab/common/changelog.py +0 -238
  372. data/vendor/depot_tools/third_party/logilab/common/clcommands.py +0 -334
  373. data/vendor/depot_tools/third_party/logilab/common/cli.py +0 -211
  374. data/vendor/depot_tools/third_party/logilab/common/compat.py +0 -78
  375. data/vendor/depot_tools/third_party/logilab/common/configuration.py +0 -1105
  376. data/vendor/depot_tools/third_party/logilab/common/contexts.py +0 -5
  377. data/vendor/depot_tools/third_party/logilab/common/corbautils.py +0 -117
  378. data/vendor/depot_tools/third_party/logilab/common/daemon.py +0 -101
  379. data/vendor/depot_tools/third_party/logilab/common/date.py +0 -335
  380. data/vendor/depot_tools/third_party/logilab/common/dbf.py +0 -231
  381. data/vendor/depot_tools/third_party/logilab/common/debugger.py +0 -214
  382. data/vendor/depot_tools/third_party/logilab/common/decorators.py +0 -281
  383. data/vendor/depot_tools/third_party/logilab/common/deprecation.py +0 -189
  384. data/vendor/depot_tools/third_party/logilab/common/fileutils.py +0 -404
  385. data/vendor/depot_tools/third_party/logilab/common/interface.py +0 -71
  386. data/vendor/depot_tools/third_party/logilab/common/logging_ext.py +0 -195
  387. data/vendor/depot_tools/third_party/logilab/common/modutils.py +0 -702
  388. data/vendor/depot_tools/third_party/logilab/common/optik_ext.py +0 -392
  389. data/vendor/depot_tools/third_party/logilab/common/optparser.py +0 -92
  390. data/vendor/depot_tools/third_party/logilab/common/proc.py +0 -277
  391. data/vendor/depot_tools/third_party/logilab/common/pyro_ext.py +0 -180
  392. data/vendor/depot_tools/third_party/logilab/common/pytest.py +0 -1199
  393. data/vendor/depot_tools/third_party/logilab/common/registry.py +0 -1119
  394. data/vendor/depot_tools/third_party/logilab/common/shellutils.py +0 -462
  395. data/vendor/depot_tools/third_party/logilab/common/sphinx_ext.py +0 -87
  396. data/vendor/depot_tools/third_party/logilab/common/sphinxutils.py +0 -122
  397. data/vendor/depot_tools/third_party/logilab/common/table.py +0 -929
  398. data/vendor/depot_tools/third_party/logilab/common/tasksqueue.py +0 -101
  399. data/vendor/depot_tools/third_party/logilab/common/testlib.py +0 -1392
  400. data/vendor/depot_tools/third_party/logilab/common/textutils.py +0 -537
  401. data/vendor/depot_tools/third_party/logilab/common/tree.py +0 -369
  402. data/vendor/depot_tools/third_party/logilab/common/umessage.py +0 -194
  403. data/vendor/depot_tools/third_party/logilab/common/ureports/__init__.py +0 -172
  404. data/vendor/depot_tools/third_party/logilab/common/ureports/docbook_writer.py +0 -140
  405. data/vendor/depot_tools/third_party/logilab/common/urllib2ext.py +0 -89
  406. data/vendor/depot_tools/third_party/logilab/common/visitor.py +0 -109
  407. data/vendor/depot_tools/third_party/logilab/common/xmlrpcutils.py +0 -131
  408. data/vendor/depot_tools/third_party/logilab/common/xmlutils.py +0 -61
@@ -1,1199 +0,0 @@
1
- # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
2
- # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
3
- #
4
- # This file is part of logilab-common.
5
- #
6
- # logilab-common is free software: you can redistribute it and/or modify it under
7
- # the terms of the GNU Lesser General Public License as published by the Free
8
- # Software Foundation, either version 2.1 of the License, or (at your option) any
9
- # later version.
10
- #
11
- # logilab-common is distributed in the hope that it will be useful, but WITHOUT
12
- # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
- # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14
- # details.
15
- #
16
- # You should have received a copy of the GNU Lesser General Public License along
17
- # with logilab-common. If not, see <http://www.gnu.org/licenses/>.
18
- """pytest is a tool that eases test running and debugging.
19
-
20
- To be able to use pytest, you should either write tests using
21
- the logilab.common.testlib's framework or the unittest module of the
22
- Python's standard library.
23
-
24
- You can customize pytest's behaviour by defining a ``pytestconf.py`` file
25
- somewhere in your test directory. In this file, you can add options or
26
- change the way tests are run.
27
-
28
- To add command line options, you must define a ``update_parser`` function in
29
- your ``pytestconf.py`` file. The function must accept a single parameter
30
- that will be the OptionParser's instance to customize.
31
-
32
- If you wish to customize the tester, you'll have to define a class named
33
- ``CustomPyTester``. This class should extend the default `PyTester` class
34
- defined in the pytest module. Take a look at the `PyTester` and `DjangoTester`
35
- classes for more information about what can be done.
36
-
37
- For instance, if you wish to add a custom -l option to specify a loglevel, you
38
- could define the following ``pytestconf.py`` file ::
39
-
40
- import logging
41
- from logilab.common.pytest import PyTester
42
-
43
- def update_parser(parser):
44
- parser.add_option('-l', '--loglevel', dest='loglevel', action='store',
45
- choices=('debug', 'info', 'warning', 'error', 'critical'),
46
- default='critical', help="the default log level possible choices are "
47
- "('debug', 'info', 'warning', 'error', 'critical')")
48
- return parser
49
-
50
-
51
- class CustomPyTester(PyTester):
52
- def __init__(self, cvg, options):
53
- super(CustomPyTester, self).__init__(cvg, options)
54
- loglevel = options.loglevel.upper()
55
- logger = logging.getLogger('erudi')
56
- logger.setLevel(logging.getLevelName(loglevel))
57
-
58
-
59
- In your TestCase class you can then get the value of a specific option with
60
- the ``optval`` method::
61
-
62
- class MyTestCase(TestCase):
63
- def test_foo(self):
64
- loglevel = self.optval('loglevel')
65
- # ...
66
-
67
-
68
- You can also tag your tag your test for fine filtering
69
-
70
- With those tag::
71
-
72
- from logilab.common.testlib import tag, TestCase
73
-
74
- class Exemple(TestCase):
75
-
76
- @tag('rouge', 'carre')
77
- def toto(self):
78
- pass
79
-
80
- @tag('carre', 'vert')
81
- def tata(self):
82
- pass
83
-
84
- @tag('rouge')
85
- def titi(test):
86
- pass
87
-
88
- you can filter the function with a simple python expression
89
-
90
- * ``toto`` and ``titi`` match ``rouge``
91
- * ``toto``, ``tata`` and ``titi``, match ``rouge or carre``
92
- * ``tata`` and ``titi`` match``rouge ^ carre``
93
- * ``titi`` match ``rouge and not carre``
94
- """
95
-
96
- from __future__ import print_function
97
-
98
- __docformat__ = "restructuredtext en"
99
-
100
- PYTEST_DOC = """%prog [OPTIONS] [testfile [testpattern]]
101
-
102
- examples:
103
-
104
- pytest path/to/mytests.py
105
- pytest path/to/mytests.py TheseTests
106
- pytest path/to/mytests.py TheseTests.test_thisone
107
- pytest path/to/mytests.py -m '(not long and database) or regr'
108
-
109
- pytest one (will run both test_thisone and test_thatone)
110
- pytest path/to/mytests.py -s not (will skip test_notthisone)
111
- """
112
-
113
- ENABLE_DBC = False
114
- FILE_RESTART = ".pytest.restart"
115
-
116
- import os, sys, re
117
- import os.path as osp
118
- from time import time, clock
119
- import warnings
120
- import types
121
- from inspect import isgeneratorfunction, isclass
122
- from contextlib import contextmanager
123
-
124
- from logilab.common.fileutils import abspath_listdir
125
- from logilab.common import textutils
126
- from logilab.common import testlib, STD_BLACKLIST
127
- # use the same unittest module as testlib
128
- from logilab.common.testlib import unittest, start_interactive_mode
129
- from logilab.common.deprecation import deprecated
130
- import doctest
131
-
132
- import unittest as unittest_legacy
133
- if not getattr(unittest_legacy, "__package__", None):
134
- try:
135
- import unittest2.suite as unittest_suite
136
- except ImportError:
137
- sys.exit("You have to install python-unittest2 to use this module")
138
- else:
139
- import unittest.suite as unittest_suite
140
-
141
- try:
142
- import django
143
- from logilab.common.modutils import modpath_from_file, load_module_from_modpath
144
- DJANGO_FOUND = True
145
- except ImportError:
146
- DJANGO_FOUND = False
147
-
148
- CONF_FILE = 'pytestconf.py'
149
-
150
- ## coverage pausing tools
151
-
152
- @contextmanager
153
- def replace_trace(trace=None):
154
- """A context manager that temporary replaces the trace function"""
155
- oldtrace = sys.gettrace()
156
- sys.settrace(trace)
157
- try:
158
- yield
159
- finally:
160
- # specific hack to work around a bug in pycoverage, see
161
- # https://bitbucket.org/ned/coveragepy/issue/123
162
- if (oldtrace is not None and not callable(oldtrace) and
163
- hasattr(oldtrace, 'pytrace')):
164
- oldtrace = oldtrace.pytrace
165
- sys.settrace(oldtrace)
166
-
167
-
168
- def pause_trace():
169
- """A context manager that temporary pauses any tracing"""
170
- return replace_trace()
171
-
172
- class TraceController(object):
173
- ctx_stack = []
174
-
175
- @classmethod
176
- @deprecated('[lgc 0.63.1] Use the pause_trace() context manager')
177
- def pause_tracing(cls):
178
- cls.ctx_stack.append(pause_trace())
179
- cls.ctx_stack[-1].__enter__()
180
-
181
- @classmethod
182
- @deprecated('[lgc 0.63.1] Use the pause_trace() context manager')
183
- def resume_tracing(cls):
184
- cls.ctx_stack.pop().__exit__(None, None, None)
185
-
186
-
187
- pause_tracing = TraceController.pause_tracing
188
- resume_tracing = TraceController.resume_tracing
189
-
190
-
191
- def nocoverage(func):
192
- """Function decorator that pauses tracing functions"""
193
- if hasattr(func, 'uncovered'):
194
- return func
195
- func.uncovered = True
196
-
197
- def not_covered(*args, **kwargs):
198
- with pause_trace():
199
- return func(*args, **kwargs)
200
- not_covered.uncovered = True
201
- return not_covered
202
-
203
- ## end of coverage pausing tools
204
-
205
-
206
- TESTFILE_RE = re.compile("^((unit)?test.*|smoketest)\.py$")
207
- def this_is_a_testfile(filename):
208
- """returns True if `filename` seems to be a test file"""
209
- return TESTFILE_RE.match(osp.basename(filename))
210
-
211
- TESTDIR_RE = re.compile("^(unit)?tests?$")
212
- def this_is_a_testdir(dirpath):
213
- """returns True if `filename` seems to be a test directory"""
214
- return TESTDIR_RE.match(osp.basename(dirpath))
215
-
216
-
217
- def load_pytest_conf(path, parser):
218
- """loads a ``pytestconf.py`` file and update default parser
219
- and / or tester.
220
- """
221
- namespace = {}
222
- exec(open(path, 'rb').read(), namespace)
223
- if 'update_parser' in namespace:
224
- namespace['update_parser'](parser)
225
- return namespace.get('CustomPyTester', PyTester)
226
-
227
-
228
- def project_root(parser, projdir=os.getcwd()):
229
- """try to find project's root and add it to sys.path"""
230
- previousdir = curdir = osp.abspath(projdir)
231
- testercls = PyTester
232
- conf_file_path = osp.join(curdir, CONF_FILE)
233
- if osp.isfile(conf_file_path):
234
- testercls = load_pytest_conf(conf_file_path, parser)
235
- while this_is_a_testdir(curdir) or \
236
- osp.isfile(osp.join(curdir, '__init__.py')):
237
- newdir = osp.normpath(osp.join(curdir, os.pardir))
238
- if newdir == curdir:
239
- break
240
- previousdir = curdir
241
- curdir = newdir
242
- conf_file_path = osp.join(curdir, CONF_FILE)
243
- if osp.isfile(conf_file_path):
244
- testercls = load_pytest_conf(conf_file_path, parser)
245
- return previousdir, testercls
246
-
247
-
248
- class GlobalTestReport(object):
249
- """this class holds global test statistics"""
250
- def __init__(self):
251
- self.ran = 0
252
- self.skipped = 0
253
- self.failures = 0
254
- self.errors = 0
255
- self.ttime = 0
256
- self.ctime = 0
257
- self.modulescount = 0
258
- self.errmodules = []
259
-
260
- def feed(self, filename, testresult, ttime, ctime):
261
- """integrates new test information into internal statistics"""
262
- ran = testresult.testsRun
263
- self.ran += ran
264
- self.skipped += len(getattr(testresult, 'skipped', ()))
265
- self.failures += len(testresult.failures)
266
- self.errors += len(testresult.errors)
267
- self.ttime += ttime
268
- self.ctime += ctime
269
- self.modulescount += 1
270
- if not testresult.wasSuccessful():
271
- problems = len(testresult.failures) + len(testresult.errors)
272
- self.errmodules.append((filename[:-3], problems, ran))
273
-
274
- def failed_to_test_module(self, filename):
275
- """called when the test module could not be imported by unittest
276
- """
277
- self.errors += 1
278
- self.modulescount += 1
279
- self.ran += 1
280
- self.errmodules.append((filename[:-3], 1, 1))
281
-
282
- def skip_module(self, filename):
283
- self.modulescount += 1
284
- self.ran += 1
285
- self.errmodules.append((filename[:-3], 0, 0))
286
-
287
- def __str__(self):
288
- """this is just presentation stuff"""
289
- line1 = ['Ran %s test cases in %.2fs (%.2fs CPU)'
290
- % (self.ran, self.ttime, self.ctime)]
291
- if self.errors:
292
- line1.append('%s errors' % self.errors)
293
- if self.failures:
294
- line1.append('%s failures' % self.failures)
295
- if self.skipped:
296
- line1.append('%s skipped' % self.skipped)
297
- modulesok = self.modulescount - len(self.errmodules)
298
- if self.errors or self.failures:
299
- line2 = '%s modules OK (%s failed)' % (modulesok,
300
- len(self.errmodules))
301
- descr = ', '.join(['%s [%s/%s]' % info for info in self.errmodules])
302
- line3 = '\nfailures: %s' % descr
303
- elif modulesok:
304
- line2 = 'All %s modules OK' % modulesok
305
- line3 = ''
306
- else:
307
- return ''
308
- return '%s\n%s%s' % (', '.join(line1), line2, line3)
309
-
310
-
311
-
312
- def remove_local_modules_from_sys(testdir):
313
- """remove all modules from cache that come from `testdir`
314
-
315
- This is used to avoid strange side-effects when using the
316
- testall() mode of pytest.
317
- For instance, if we run pytest on this tree::
318
-
319
- A/test/test_utils.py
320
- B/test/test_utils.py
321
-
322
- we **have** to clean sys.modules to make sure the correct test_utils
323
- module is ran in B
324
- """
325
- for modname, mod in list(sys.modules.items()):
326
- if mod is None:
327
- continue
328
- if not hasattr(mod, '__file__'):
329
- # this is the case of some built-in modules like sys, imp, marshal
330
- continue
331
- modfile = mod.__file__
332
- # if modfile is not an absolute path, it was probably loaded locally
333
- # during the tests
334
- if not osp.isabs(modfile) or modfile.startswith(testdir):
335
- del sys.modules[modname]
336
-
337
-
338
-
339
- class PyTester(object):
340
- """encapsulates testrun logic"""
341
-
342
- def __init__(self, cvg, options):
343
- self.report = GlobalTestReport()
344
- self.cvg = cvg
345
- self.options = options
346
- self.firstwrite = True
347
- self._errcode = None
348
-
349
- def show_report(self):
350
- """prints the report and returns appropriate exitcode"""
351
- # everything has been ran, print report
352
- print("*" * 79)
353
- print(self.report)
354
-
355
- def get_errcode(self):
356
- # errcode set explicitly
357
- if self._errcode is not None:
358
- return self._errcode
359
- return self.report.failures + self.report.errors
360
-
361
- def set_errcode(self, errcode):
362
- self._errcode = errcode
363
- errcode = property(get_errcode, set_errcode)
364
-
365
- def testall(self, exitfirst=False):
366
- """walks through current working directory, finds something
367
- which can be considered as a testdir and runs every test there
368
- """
369
- here = os.getcwd()
370
- for dirname, dirs, _ in os.walk(here):
371
- for skipped in STD_BLACKLIST:
372
- if skipped in dirs:
373
- dirs.remove(skipped)
374
- basename = osp.basename(dirname)
375
- if this_is_a_testdir(basename):
376
- print("going into", dirname)
377
- # we found a testdir, let's explore it !
378
- if not self.testonedir(dirname, exitfirst):
379
- break
380
- dirs[:] = []
381
- if self.report.ran == 0:
382
- print("no test dir found testing here:", here)
383
- # if no test was found during the visit, consider
384
- # the local directory as a test directory even if
385
- # it doesn't have a traditional test directory name
386
- self.testonedir(here)
387
-
388
- def testonedir(self, testdir, exitfirst=False):
389
- """finds each testfile in the `testdir` and runs it
390
-
391
- return true when all tests has been executed, false if exitfirst and
392
- some test has failed.
393
- """
394
- for filename in abspath_listdir(testdir):
395
- if this_is_a_testfile(filename):
396
- if self.options.exitfirst and not self.options.restart:
397
- # overwrite restart file
398
- try:
399
- restartfile = open(FILE_RESTART, "w")
400
- restartfile.close()
401
- except Exception:
402
- print("Error while overwriting succeeded test file :",
403
- osp.join(os.getcwd(), FILE_RESTART),
404
- file=sys.__stderr__)
405
- raise
406
- # run test and collect information
407
- prog = self.testfile(filename, batchmode=True)
408
- if exitfirst and (prog is None or not prog.result.wasSuccessful()):
409
- return False
410
- self.firstwrite = True
411
- # clean local modules
412
- remove_local_modules_from_sys(testdir)
413
- return True
414
-
415
- def testfile(self, filename, batchmode=False):
416
- """runs every test in `filename`
417
-
418
- :param filename: an absolute path pointing to a unittest file
419
- """
420
- here = os.getcwd()
421
- dirname = osp.dirname(filename)
422
- if dirname:
423
- os.chdir(dirname)
424
- # overwrite restart file if it has not been done already
425
- if self.options.exitfirst and not self.options.restart and self.firstwrite:
426
- try:
427
- restartfile = open(FILE_RESTART, "w")
428
- restartfile.close()
429
- except Exception:
430
- print("Error while overwriting succeeded test file :",
431
- osp.join(os.getcwd(), FILE_RESTART), file=sys.__stderr__)
432
- raise
433
- modname = osp.basename(filename)[:-3]
434
- print((' %s ' % osp.basename(filename)).center(70, '='),
435
- file=sys.__stderr__)
436
- try:
437
- tstart, cstart = time(), clock()
438
- try:
439
- testprog = SkipAwareTestProgram(modname, batchmode=batchmode, cvg=self.cvg,
440
- options=self.options, outstream=sys.stderr)
441
- except KeyboardInterrupt:
442
- raise
443
- except SystemExit as exc:
444
- self.errcode = exc.code
445
- raise
446
- except testlib.SkipTest:
447
- print("Module skipped:", filename)
448
- self.report.skip_module(filename)
449
- return None
450
- except Exception:
451
- self.report.failed_to_test_module(filename)
452
- print('unhandled exception occurred while testing', modname,
453
- file=sys.stderr)
454
- import traceback
455
- traceback.print_exc(file=sys.stderr)
456
- return None
457
-
458
- tend, cend = time(), clock()
459
- ttime, ctime = (tend - tstart), (cend - cstart)
460
- self.report.feed(filename, testprog.result, ttime, ctime)
461
- return testprog
462
- finally:
463
- if dirname:
464
- os.chdir(here)
465
-
466
-
467
-
468
- class DjangoTester(PyTester):
469
-
470
- def load_django_settings(self, dirname):
471
- """try to find project's setting and load it"""
472
- curdir = osp.abspath(dirname)
473
- previousdir = curdir
474
- while not osp.isfile(osp.join(curdir, 'settings.py')) and \
475
- osp.isfile(osp.join(curdir, '__init__.py')):
476
- newdir = osp.normpath(osp.join(curdir, os.pardir))
477
- if newdir == curdir:
478
- raise AssertionError('could not find settings.py')
479
- previousdir = curdir
480
- curdir = newdir
481
- # late django initialization
482
- settings = load_module_from_modpath(modpath_from_file(osp.join(curdir, 'settings.py')))
483
- from django.core.management import setup_environ
484
- setup_environ(settings)
485
- settings.DEBUG = False
486
- self.settings = settings
487
- # add settings dir to pythonpath since it's the project's root
488
- if curdir not in sys.path:
489
- sys.path.insert(1, curdir)
490
-
491
- def before_testfile(self):
492
- # Those imports must be done **after** setup_environ was called
493
- from django.test.utils import setup_test_environment
494
- from django.test.utils import create_test_db
495
- setup_test_environment()
496
- create_test_db(verbosity=0)
497
- self.dbname = self.settings.TEST_DATABASE_NAME
498
-
499
- def after_testfile(self):
500
- # Those imports must be done **after** setup_environ was called
501
- from django.test.utils import teardown_test_environment
502
- from django.test.utils import destroy_test_db
503
- teardown_test_environment()
504
- print('destroying', self.dbname)
505
- destroy_test_db(self.dbname, verbosity=0)
506
-
507
- def testall(self, exitfirst=False):
508
- """walks through current working directory, finds something
509
- which can be considered as a testdir and runs every test there
510
- """
511
- for dirname, dirs, files in os.walk(os.getcwd()):
512
- for skipped in ('CVS', '.svn', '.hg'):
513
- if skipped in dirs:
514
- dirs.remove(skipped)
515
- if 'tests.py' in files:
516
- if not self.testonedir(dirname, exitfirst):
517
- break
518
- dirs[:] = []
519
- else:
520
- basename = osp.basename(dirname)
521
- if basename in ('test', 'tests'):
522
- print("going into", dirname)
523
- # we found a testdir, let's explore it !
524
- if not self.testonedir(dirname, exitfirst):
525
- break
526
- dirs[:] = []
527
-
528
- def testonedir(self, testdir, exitfirst=False):
529
- """finds each testfile in the `testdir` and runs it
530
-
531
- return true when all tests has been executed, false if exitfirst and
532
- some test has failed.
533
- """
534
- # special django behaviour : if tests are splitted in several files,
535
- # remove the main tests.py file and tests each test file separately
536
- testfiles = [fpath for fpath in abspath_listdir(testdir)
537
- if this_is_a_testfile(fpath)]
538
- if len(testfiles) > 1:
539
- try:
540
- testfiles.remove(osp.join(testdir, 'tests.py'))
541
- except ValueError:
542
- pass
543
- for filename in testfiles:
544
- # run test and collect information
545
- prog = self.testfile(filename, batchmode=True)
546
- if exitfirst and (prog is None or not prog.result.wasSuccessful()):
547
- return False
548
- # clean local modules
549
- remove_local_modules_from_sys(testdir)
550
- return True
551
-
552
- def testfile(self, filename, batchmode=False):
553
- """runs every test in `filename`
554
-
555
- :param filename: an absolute path pointing to a unittest file
556
- """
557
- here = os.getcwd()
558
- dirname = osp.dirname(filename)
559
- if dirname:
560
- os.chdir(dirname)
561
- self.load_django_settings(dirname)
562
- modname = osp.basename(filename)[:-3]
563
- print((' %s ' % osp.basename(filename)).center(70, '='),
564
- file=sys.stderr)
565
- try:
566
- try:
567
- tstart, cstart = time(), clock()
568
- self.before_testfile()
569
- testprog = SkipAwareTestProgram(modname, batchmode=batchmode, cvg=self.cvg)
570
- tend, cend = time(), clock()
571
- ttime, ctime = (tend - tstart), (cend - cstart)
572
- self.report.feed(filename, testprog.result, ttime, ctime)
573
- return testprog
574
- except SystemExit:
575
- raise
576
- except Exception as exc:
577
- import traceback
578
- traceback.print_exc()
579
- self.report.failed_to_test_module(filename)
580
- print('unhandled exception occurred while testing', modname)
581
- print('error: %s' % exc)
582
- return None
583
- finally:
584
- self.after_testfile()
585
- if dirname:
586
- os.chdir(here)
587
-
588
-
589
- def make_parser():
590
- """creates the OptionParser instance
591
- """
592
- from optparse import OptionParser
593
- parser = OptionParser(usage=PYTEST_DOC)
594
-
595
- parser.newargs = []
596
- def rebuild_cmdline(option, opt, value, parser):
597
- """carry the option to unittest_main"""
598
- parser.newargs.append(opt)
599
-
600
- def rebuild_and_store(option, opt, value, parser):
601
- """carry the option to unittest_main and store
602
- the value on current parser
603
- """
604
- parser.newargs.append(opt)
605
- setattr(parser.values, option.dest, True)
606
-
607
- def capture_and_rebuild(option, opt, value, parser):
608
- warnings.simplefilter('ignore', DeprecationWarning)
609
- rebuild_cmdline(option, opt, value, parser)
610
-
611
- # pytest options
612
- parser.add_option('-t', dest='testdir', default=None,
613
- help="directory where the tests will be found")
614
- parser.add_option('-d', dest='dbc', default=False,
615
- action="store_true", help="enable design-by-contract")
616
- # unittest_main options provided and passed through pytest
617
- parser.add_option('-v', '--verbose', callback=rebuild_cmdline,
618
- action="callback", help="Verbose output")
619
- parser.add_option('-i', '--pdb', callback=rebuild_and_store,
620
- dest="pdb", action="callback",
621
- help="Enable test failure inspection")
622
- parser.add_option('-x', '--exitfirst', callback=rebuild_and_store,
623
- dest="exitfirst", default=False,
624
- action="callback", help="Exit on first failure "
625
- "(only make sense when pytest run one test file)")
626
- parser.add_option('-R', '--restart', callback=rebuild_and_store,
627
- dest="restart", default=False,
628
- action="callback",
629
- help="Restart tests from where it failed (implies exitfirst) "
630
- "(only make sense if tests previously ran with exitfirst only)")
631
- parser.add_option('--color', callback=rebuild_cmdline,
632
- action="callback",
633
- help="colorize tracebacks")
634
- parser.add_option('-s', '--skip',
635
- # XXX: I wish I could use the callback action but it
636
- # doesn't seem to be able to get the value
637
- # associated to the option
638
- action="store", dest="skipped", default=None,
639
- help="test names matching this name will be skipped "
640
- "to skip several patterns, use commas")
641
- parser.add_option('-q', '--quiet', callback=rebuild_cmdline,
642
- action="callback", help="Minimal output")
643
- parser.add_option('-P', '--profile', default=None, dest='profile',
644
- help="Profile execution and store data in the given file")
645
- parser.add_option('-m', '--match', default=None, dest='tags_pattern',
646
- help="only execute test whose tag match the current pattern")
647
-
648
- if DJANGO_FOUND:
649
- parser.add_option('-J', '--django', dest='django', default=False,
650
- action="store_true",
651
- help='use pytest for django test cases')
652
- return parser
653
-
654
-
655
- def parseargs(parser):
656
- """Parse the command line and return (options processed), (options to pass to
657
- unittest_main()), (explicitfile or None).
658
- """
659
- # parse the command line
660
- options, args = parser.parse_args()
661
- filenames = [arg for arg in args if arg.endswith('.py')]
662
- if filenames:
663
- if len(filenames) > 1:
664
- parser.error("only one filename is acceptable")
665
- explicitfile = filenames[0]
666
- args.remove(explicitfile)
667
- else:
668
- explicitfile = None
669
- # someone wants DBC
670
- testlib.ENABLE_DBC = options.dbc
671
- newargs = parser.newargs
672
- if options.skipped:
673
- newargs.extend(['--skip', options.skipped])
674
- # restart implies exitfirst
675
- if options.restart:
676
- options.exitfirst = True
677
- # append additional args to the new sys.argv and let unittest_main
678
- # do the rest
679
- newargs += args
680
- return options, explicitfile
681
-
682
-
683
-
684
- def run():
685
- parser = make_parser()
686
- rootdir, testercls = project_root(parser)
687
- options, explicitfile = parseargs(parser)
688
- # mock a new command line
689
- sys.argv[1:] = parser.newargs
690
- cvg = None
691
- if not '' in sys.path:
692
- sys.path.insert(0, '')
693
- if DJANGO_FOUND and options.django:
694
- tester = DjangoTester(cvg, options)
695
- else:
696
- tester = testercls(cvg, options)
697
- if explicitfile:
698
- cmd, args = tester.testfile, (explicitfile,)
699
- elif options.testdir:
700
- cmd, args = tester.testonedir, (options.testdir, options.exitfirst)
701
- else:
702
- cmd, args = tester.testall, (options.exitfirst,)
703
- try:
704
- try:
705
- if options.profile:
706
- import hotshot
707
- prof = hotshot.Profile(options.profile)
708
- prof.runcall(cmd, *args)
709
- prof.close()
710
- print('profile data saved in', options.profile)
711
- else:
712
- cmd(*args)
713
- except SystemExit:
714
- raise
715
- except:
716
- import traceback
717
- traceback.print_exc()
718
- finally:
719
- tester.show_report()
720
- sys.exit(tester.errcode)
721
-
722
- class SkipAwareTestProgram(unittest.TestProgram):
723
- # XXX: don't try to stay close to unittest.py, use optparse
724
- USAGE = """\
725
- Usage: %(progName)s [options] [test] [...]
726
-
727
- Options:
728
- -h, --help Show this message
729
- -v, --verbose Verbose output
730
- -i, --pdb Enable test failure inspection
731
- -x, --exitfirst Exit on first failure
732
- -s, --skip skip test matching this pattern (no regexp for now)
733
- -q, --quiet Minimal output
734
- --color colorize tracebacks
735
-
736
- -m, --match Run only test whose tag match this pattern
737
-
738
- -P, --profile FILE: Run the tests using cProfile and saving results
739
- in FILE
740
-
741
- Examples:
742
- %(progName)s - run default set of tests
743
- %(progName)s MyTestSuite - run suite 'MyTestSuite'
744
- %(progName)s MyTestCase.testSomething - run MyTestCase.testSomething
745
- %(progName)s MyTestCase - run all 'test*' test methods
746
- in MyTestCase
747
- """
748
- def __init__(self, module='__main__', defaultTest=None, batchmode=False,
749
- cvg=None, options=None, outstream=sys.stderr):
750
- self.batchmode = batchmode
751
- self.cvg = cvg
752
- self.options = options
753
- self.outstream = outstream
754
- super(SkipAwareTestProgram, self).__init__(
755
- module=module, defaultTest=defaultTest,
756
- testLoader=NonStrictTestLoader())
757
-
758
- def parseArgs(self, argv):
759
- self.pdbmode = False
760
- self.exitfirst = False
761
- self.skipped_patterns = []
762
- self.test_pattern = None
763
- self.tags_pattern = None
764
- self.colorize = False
765
- self.profile_name = None
766
- import getopt
767
- try:
768
- options, args = getopt.getopt(argv[1:], 'hHvixrqcp:s:m:P:',
769
- ['help', 'verbose', 'quiet', 'pdb',
770
- 'exitfirst', 'restart',
771
- 'skip=', 'color', 'match=', 'profile='])
772
- for opt, value in options:
773
- if opt in ('-h', '-H', '--help'):
774
- self.usageExit()
775
- if opt in ('-i', '--pdb'):
776
- self.pdbmode = True
777
- if opt in ('-x', '--exitfirst'):
778
- self.exitfirst = True
779
- if opt in ('-r', '--restart'):
780
- self.restart = True
781
- self.exitfirst = True
782
- if opt in ('-q', '--quiet'):
783
- self.verbosity = 0
784
- if opt in ('-v', '--verbose'):
785
- self.verbosity = 2
786
- if opt in ('-s', '--skip'):
787
- self.skipped_patterns = [pat.strip() for pat in
788
- value.split(', ')]
789
- if opt == '--color':
790
- self.colorize = True
791
- if opt in ('-m', '--match'):
792
- #self.tags_pattern = value
793
- self.options["tag_pattern"] = value
794
- if opt in ('-P', '--profile'):
795
- self.profile_name = value
796
- self.testLoader.skipped_patterns = self.skipped_patterns
797
- if len(args) == 0 and self.defaultTest is None:
798
- suitefunc = getattr(self.module, 'suite', None)
799
- if isinstance(suitefunc, (types.FunctionType,
800
- types.MethodType)):
801
- self.test = self.module.suite()
802
- else:
803
- self.test = self.testLoader.loadTestsFromModule(self.module)
804
- return
805
- if len(args) > 0:
806
- self.test_pattern = args[0]
807
- self.testNames = args
808
- else:
809
- self.testNames = (self.defaultTest, )
810
- self.createTests()
811
- except getopt.error as msg:
812
- self.usageExit(msg)
813
-
814
- def runTests(self):
815
- if self.profile_name:
816
- import cProfile
817
- cProfile.runctx('self._runTests()', globals(), locals(), self.profile_name )
818
- else:
819
- return self._runTests()
820
-
821
- def _runTests(self):
822
- self.testRunner = SkipAwareTextTestRunner(verbosity=self.verbosity,
823
- stream=self.outstream,
824
- exitfirst=self.exitfirst,
825
- pdbmode=self.pdbmode,
826
- cvg=self.cvg,
827
- test_pattern=self.test_pattern,
828
- skipped_patterns=self.skipped_patterns,
829
- colorize=self.colorize,
830
- batchmode=self.batchmode,
831
- options=self.options)
832
-
833
- def removeSucceededTests(obj, succTests):
834
- """ Recursive function that removes succTests from
835
- a TestSuite or TestCase
836
- """
837
- if isinstance(obj, unittest.TestSuite):
838
- removeSucceededTests(obj._tests, succTests)
839
- if isinstance(obj, list):
840
- for el in obj[:]:
841
- if isinstance(el, unittest.TestSuite):
842
- removeSucceededTests(el, succTests)
843
- elif isinstance(el, unittest.TestCase):
844
- descr = '.'.join((el.__class__.__module__,
845
- el.__class__.__name__,
846
- el._testMethodName))
847
- if descr in succTests:
848
- obj.remove(el)
849
- # take care, self.options may be None
850
- if getattr(self.options, 'restart', False):
851
- # retrieve succeeded tests from FILE_RESTART
852
- try:
853
- restartfile = open(FILE_RESTART, 'r')
854
- try:
855
- succeededtests = list(elem.rstrip('\n\r') for elem in
856
- restartfile.readlines())
857
- removeSucceededTests(self.test, succeededtests)
858
- finally:
859
- restartfile.close()
860
- except Exception as ex:
861
- raise Exception("Error while reading succeeded tests into %s: %s"
862
- % (osp.join(os.getcwd(), FILE_RESTART), ex))
863
-
864
- result = self.testRunner.run(self.test)
865
- # help garbage collection: we want TestSuite, which hold refs to every
866
- # executed TestCase, to be gc'ed
867
- del self.test
868
- if getattr(result, "debuggers", None) and \
869
- getattr(self, "pdbmode", None):
870
- start_interactive_mode(result)
871
- if not getattr(self, "batchmode", None):
872
- sys.exit(not result.wasSuccessful())
873
- self.result = result
874
-
875
-
876
- class SkipAwareTextTestRunner(unittest.TextTestRunner):
877
-
878
- def __init__(self, stream=sys.stderr, verbosity=1,
879
- exitfirst=False, pdbmode=False, cvg=None, test_pattern=None,
880
- skipped_patterns=(), colorize=False, batchmode=False,
881
- options=None):
882
- super(SkipAwareTextTestRunner, self).__init__(stream=stream,
883
- verbosity=verbosity)
884
- self.exitfirst = exitfirst
885
- self.pdbmode = pdbmode
886
- self.cvg = cvg
887
- self.test_pattern = test_pattern
888
- self.skipped_patterns = skipped_patterns
889
- self.colorize = colorize
890
- self.batchmode = batchmode
891
- self.options = options
892
-
893
- def _this_is_skipped(self, testedname):
894
- return any([(pat in testedname) for pat in self.skipped_patterns])
895
-
896
- def _runcondition(self, test, skipgenerator=True):
897
- if isinstance(test, testlib.InnerTest):
898
- testname = test.name
899
- else:
900
- if isinstance(test, testlib.TestCase):
901
- meth = test._get_test_method()
902
- testname = '%s.%s' % (test.__name__, meth.__name__)
903
- elif isinstance(test, types.FunctionType):
904
- func = test
905
- testname = func.__name__
906
- elif isinstance(test, types.MethodType):
907
- cls = test.__self__.__class__
908
- testname = '%s.%s' % (cls.__name__, test.__name__)
909
- else:
910
- return True # Not sure when this happens
911
- if isgeneratorfunction(test) and skipgenerator:
912
- return self.does_match_tags(test) # Let inner tests decide at run time
913
- if self._this_is_skipped(testname):
914
- return False # this was explicitly skipped
915
- if self.test_pattern is not None:
916
- try:
917
- classpattern, testpattern = self.test_pattern.split('.')
918
- klass, name = testname.split('.')
919
- if classpattern not in klass or testpattern not in name:
920
- return False
921
- except ValueError:
922
- if self.test_pattern not in testname:
923
- return False
924
-
925
- return self.does_match_tags(test)
926
-
927
- def does_match_tags(self, test):
928
- if self.options is not None:
929
- tags_pattern = getattr(self.options, 'tags_pattern', None)
930
- if tags_pattern is not None:
931
- tags = getattr(test, 'tags', testlib.Tags())
932
- if tags.inherit and isinstance(test, types.MethodType):
933
- tags = tags | getattr(test.im_class, 'tags', testlib.Tags())
934
- return tags.match(tags_pattern)
935
- return True # no pattern
936
-
937
- def _makeResult(self):
938
- return testlib.SkipAwareTestResult(self.stream, self.descriptions,
939
- self.verbosity, self.exitfirst,
940
- self.pdbmode, self.cvg, self.colorize)
941
-
942
- def run(self, test):
943
- "Run the given test case or test suite."
944
- result = self._makeResult()
945
- startTime = time()
946
- test(result, runcondition=self._runcondition, options=self.options)
947
- stopTime = time()
948
- timeTaken = stopTime - startTime
949
- result.printErrors()
950
- if not self.batchmode:
951
- self.stream.writeln(result.separator2)
952
- run = result.testsRun
953
- self.stream.writeln("Ran %d test%s in %.3fs" %
954
- (run, run != 1 and "s" or "", timeTaken))
955
- self.stream.writeln()
956
- if not result.wasSuccessful():
957
- if self.colorize:
958
- self.stream.write(textutils.colorize_ansi("FAILED", color='red'))
959
- else:
960
- self.stream.write("FAILED")
961
- else:
962
- if self.colorize:
963
- self.stream.write(textutils.colorize_ansi("OK", color='green'))
964
- else:
965
- self.stream.write("OK")
966
- failed, errored, skipped = map(len, (result.failures,
967
- result.errors,
968
- result.skipped))
969
-
970
- det_results = []
971
- for name, value in (("failures", result.failures),
972
- ("errors",result.errors),
973
- ("skipped", result.skipped)):
974
- if value:
975
- det_results.append("%s=%i" % (name, len(value)))
976
- if det_results:
977
- self.stream.write(" (")
978
- self.stream.write(', '.join(det_results))
979
- self.stream.write(")")
980
- self.stream.writeln("")
981
- return result
982
-
983
- class NonStrictTestLoader(unittest.TestLoader):
984
- """
985
- Overrides default testloader to be able to omit classname when
986
- specifying tests to run on command line.
987
-
988
- For example, if the file test_foo.py contains ::
989
-
990
- class FooTC(TestCase):
991
- def test_foo1(self): # ...
992
- def test_foo2(self): # ...
993
- def test_bar1(self): # ...
994
-
995
- class BarTC(TestCase):
996
- def test_bar2(self): # ...
997
-
998
- 'python test_foo.py' will run the 3 tests in FooTC
999
- 'python test_foo.py FooTC' will run the 3 tests in FooTC
1000
- 'python test_foo.py test_foo' will run test_foo1 and test_foo2
1001
- 'python test_foo.py test_foo1' will run test_foo1
1002
- 'python test_foo.py test_bar' will run FooTC.test_bar1 and BarTC.test_bar2
1003
- """
1004
-
1005
- def __init__(self):
1006
- self.skipped_patterns = ()
1007
-
1008
- # some magic here to accept empty list by extending
1009
- # and to provide callable capability
1010
- def loadTestsFromNames(self, names, module=None):
1011
- suites = []
1012
- for name in names:
1013
- suites.extend(self.loadTestsFromName(name, module))
1014
- return self.suiteClass(suites)
1015
-
1016
- def _collect_tests(self, module):
1017
- tests = {}
1018
- for obj in vars(module).values():
1019
- if isclass(obj) and issubclass(obj, unittest.TestCase):
1020
- classname = obj.__name__
1021
- if classname[0] == '_' or self._this_is_skipped(classname):
1022
- continue
1023
- methodnames = []
1024
- # obj is a TestCase class
1025
- for attrname in dir(obj):
1026
- if attrname.startswith(self.testMethodPrefix):
1027
- attr = getattr(obj, attrname)
1028
- if callable(attr):
1029
- methodnames.append(attrname)
1030
- # keep track of class (obj) for convenience
1031
- tests[classname] = (obj, methodnames)
1032
- return tests
1033
-
1034
- def loadTestsFromSuite(self, module, suitename):
1035
- try:
1036
- suite = getattr(module, suitename)()
1037
- except AttributeError:
1038
- return []
1039
- assert hasattr(suite, '_tests'), \
1040
- "%s.%s is not a valid TestSuite" % (module.__name__, suitename)
1041
- # python2.3 does not implement __iter__ on suites, we need to return
1042
- # _tests explicitly
1043
- return suite._tests
1044
-
1045
- def loadTestsFromName(self, name, module=None):
1046
- parts = name.split('.')
1047
- if module is None or len(parts) > 2:
1048
- # let the base class do its job here
1049
- return [super(NonStrictTestLoader, self).loadTestsFromName(name)]
1050
- tests = self._collect_tests(module)
1051
- collected = []
1052
- if len(parts) == 1:
1053
- pattern = parts[0]
1054
- if callable(getattr(module, pattern, None)
1055
- ) and pattern not in tests:
1056
- # consider it as a suite
1057
- return self.loadTestsFromSuite(module, pattern)
1058
- if pattern in tests:
1059
- # case python unittest_foo.py MyTestTC
1060
- klass, methodnames = tests[pattern]
1061
- for methodname in methodnames:
1062
- collected = [klass(methodname)
1063
- for methodname in methodnames]
1064
- else:
1065
- # case python unittest_foo.py something
1066
- for klass, methodnames in tests.values():
1067
- # skip methodname if matched by skipped_patterns
1068
- for skip_pattern in self.skipped_patterns:
1069
- methodnames = [methodname
1070
- for methodname in methodnames
1071
- if skip_pattern not in methodname]
1072
- collected += [klass(methodname)
1073
- for methodname in methodnames
1074
- if pattern in methodname]
1075
- elif len(parts) == 2:
1076
- # case "MyClass.test_1"
1077
- classname, pattern = parts
1078
- klass, methodnames = tests.get(classname, (None, []))
1079
- for methodname in methodnames:
1080
- collected = [klass(methodname) for methodname in methodnames
1081
- if pattern in methodname]
1082
- return collected
1083
-
1084
- def _this_is_skipped(self, testedname):
1085
- return any([(pat in testedname) for pat in self.skipped_patterns])
1086
-
1087
- def getTestCaseNames(self, testCaseClass):
1088
- """Return a sorted sequence of method names found within testCaseClass
1089
- """
1090
- is_skipped = self._this_is_skipped
1091
- classname = testCaseClass.__name__
1092
- if classname[0] == '_' or is_skipped(classname):
1093
- return []
1094
- testnames = super(NonStrictTestLoader, self).getTestCaseNames(
1095
- testCaseClass)
1096
- return [testname for testname in testnames if not is_skipped(testname)]
1097
-
1098
-
1099
- # The 2 functions below are modified versions of the TestSuite.run method
1100
- # that is provided with unittest2 for python 2.6, in unittest2/suite.py
1101
- # It is used to monkeypatch the original implementation to support
1102
- # extra runcondition and options arguments (see in testlib.py)
1103
-
1104
- def _ts_run(self, result, runcondition=None, options=None):
1105
- self._wrapped_run(result, runcondition=runcondition, options=options)
1106
- self._tearDownPreviousClass(None, result)
1107
- self._handleModuleTearDown(result)
1108
- return result
1109
-
1110
- def _ts_wrapped_run(self, result, debug=False, runcondition=None, options=None):
1111
- for test in self:
1112
- if result.shouldStop:
1113
- break
1114
- if unittest_suite._isnotsuite(test):
1115
- self._tearDownPreviousClass(test, result)
1116
- self._handleModuleFixture(test, result)
1117
- self._handleClassSetUp(test, result)
1118
- result._previousTestClass = test.__class__
1119
- if (getattr(test.__class__, '_classSetupFailed', False) or
1120
- getattr(result, '_moduleSetUpFailed', False)):
1121
- continue
1122
-
1123
- # --- modifications to deal with _wrapped_run ---
1124
- # original code is:
1125
- #
1126
- # if not debug:
1127
- # test(result)
1128
- # else:
1129
- # test.debug()
1130
- if hasattr(test, '_wrapped_run'):
1131
- try:
1132
- test._wrapped_run(result, debug, runcondition=runcondition, options=options)
1133
- except TypeError:
1134
- test._wrapped_run(result, debug)
1135
- elif not debug:
1136
- try:
1137
- test(result, runcondition, options)
1138
- except TypeError:
1139
- test(result)
1140
- else:
1141
- test.debug()
1142
- # --- end of modifications to deal with _wrapped_run ---
1143
- return result
1144
-
1145
- if sys.version_info >= (2, 7):
1146
- # The function below implements a modified version of the
1147
- # TestSuite.run method that is provided with python 2.7, in
1148
- # unittest/suite.py
1149
- def _ts_run(self, result, debug=False, runcondition=None, options=None):
1150
- topLevel = False
1151
- if getattr(result, '_testRunEntered', False) is False:
1152
- result._testRunEntered = topLevel = True
1153
-
1154
- self._wrapped_run(result, debug, runcondition, options)
1155
-
1156
- if topLevel:
1157
- self._tearDownPreviousClass(None, result)
1158
- self._handleModuleTearDown(result)
1159
- result._testRunEntered = False
1160
- return result
1161
-
1162
-
1163
- def enable_dbc(*args):
1164
- """
1165
- Without arguments, return True if contracts can be enabled and should be
1166
- enabled (see option -d), return False otherwise.
1167
-
1168
- With arguments, return False if contracts can't or shouldn't be enabled,
1169
- otherwise weave ContractAspect with items passed as arguments.
1170
- """
1171
- if not ENABLE_DBC:
1172
- return False
1173
- try:
1174
- from logilab.aspects.weaver import weaver
1175
- from logilab.aspects.lib.contracts import ContractAspect
1176
- except ImportError:
1177
- sys.stderr.write(
1178
- 'Warning: logilab.aspects is not available. Contracts disabled.')
1179
- return False
1180
- for arg in args:
1181
- weaver.weave_module(arg, ContractAspect)
1182
- return True
1183
-
1184
-
1185
- # monkeypatch unittest and doctest (ouch !)
1186
- unittest._TextTestResult = testlib.SkipAwareTestResult
1187
- unittest.TextTestRunner = SkipAwareTextTestRunner
1188
- unittest.TestLoader = NonStrictTestLoader
1189
- unittest.TestProgram = SkipAwareTestProgram
1190
-
1191
- if sys.version_info >= (2, 4):
1192
- doctest.DocTestCase.__bases__ = (testlib.TestCase,)
1193
- # XXX check python2.6 compatibility
1194
- #doctest.DocTestCase._cleanups = []
1195
- #doctest.DocTestCase._out = []
1196
- else:
1197
- unittest.FunctionTestCase.__bases__ = (testlib.TestCase,)
1198
- unittest.TestSuite.run = _ts_run
1199
- unittest.TestSuite._wrapped_run = _ts_wrapped_run