full.py 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # Copyright 2014 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. DEPS = [
  5. 'gitiles',
  6. 'recipe_engine/json',
  7. 'recipe_engine/step',
  8. 'recipe_engine/path',
  9. 'recipe_engine/properties',
  10. ]
  11. def RunSteps(api):
  12. url = 'https://chromium.googlesource.com/chromium/src'
  13. for ref in api.gitiles.refs(url):
  14. _, cursor = api.gitiles.log(url, ref)
  15. if cursor:
  16. api.gitiles.log(url, ref, limit=10, cursor=cursor)
  17. api.gitiles.commit_log(url, api.properties['commit_log_hash'])
  18. data = api.gitiles.download_file(url, 'OWNERS', attempts=5)
  19. assert data == 'foobar'
  20. data = api.gitiles.download_file(url, 'NONEXISTENT', attempts=1,
  21. accept_statuses=[404])
  22. api.gitiles.download_archive(url, api.path['start_dir'].join('archive'))
  23. try:
  24. api.gitiles.download_archive(url, api.path['start_dir'].join('archive2'))
  25. assert False # pragma: no cover
  26. except api.step.StepFailure as ex:
  27. assert '/root' in ex.gitiles_skipped_files
  28. def GenTests(api):
  29. yield (
  30. api.test('basic')
  31. + api.properties(
  32. commit_log_hash=api.gitiles.make_hash('commit'),
  33. )
  34. + api.step_data('refs', api.gitiles.make_refs_test_data(
  35. 'HEAD',
  36. 'refs/heads/A',
  37. 'refs/tags/B',
  38. ))
  39. + api.step_data(
  40. 'gitiles log: HEAD',
  41. api.gitiles.make_log_test_data('HEAD', cursor='deadbeaf'),
  42. )
  43. + api.step_data(
  44. 'gitiles log: HEAD from deadbeaf',
  45. api.gitiles.make_log_test_data('HEAD'),
  46. )
  47. + api.step_data(
  48. 'gitiles log: refs/heads/A',
  49. api.gitiles.make_log_test_data('A'),
  50. )
  51. + api.step_data(
  52. 'gitiles log: refs/tags/B',
  53. api.gitiles.make_log_test_data('B')
  54. )
  55. + api.step_data(
  56. 'commit log: %s' % (api.gitiles.make_hash('commit')),
  57. api.gitiles.make_commit_test_data('commit', 'C', new_files=[
  58. 'foo/bar',
  59. 'baz/qux',
  60. ])
  61. )
  62. + api.step_data(
  63. 'fetch master:OWNERS',
  64. api.gitiles.make_encoded_file('foobar')
  65. )
  66. + api.step_data(
  67. 'fetch master:NONEXISTENT',
  68. api.json.output({'value': None})
  69. )
  70. + api.step_data(
  71. ('download https://chromium.googlesource.com/chromium/src @ '
  72. 'refs/heads/master (2)'),
  73. api.json.output({
  74. 'extracted': {
  75. 'filecount': 10,
  76. 'bytes': 14925,
  77. },
  78. 'skipped': {
  79. 'filecount': 4,
  80. 'bytes': 7192345,
  81. 'names': ['/root', '../relative', 'sneaky/../../relative'],
  82. },
  83. })
  84. )
  85. )