blob: 992fd4308fbf9bc1dac35029adec0a909e1686e5 [file] [log] [blame]
# -*- coding: utf-8 -*-
# Copyright 2020 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Copied from
# https://chromium.googlesource.com/chromiumos/infra/recipes/+/HEAD/recipe_modules/repo/
# pylint: disable=missing-module-docstring
DEPS = [
'fuchsia/status_check',
'pigweed/repo',
'recipe_engine/assertions',
'recipe_engine/context',
'recipe_engine/path',
]
PYTHON_VERSION_COMPATIBILITY = "PY3"
def RunSteps(api): # pylint: disable=missing-function-docstring
with api.context(cwd=api.path['cleanup']):
api.assertions.assertIsNone(
api.repo._find_root()
) # pylint: disable=protected-access
checkout = api.path['start_dir'].join('checkout')
with api.context(cwd=checkout):
api.repo.init('http://manifest_url')
api.repo.init(
'http://manifest_url',
manifest_branch='mybranch',
manifest_name='pigweed.xml',
reference='/preload/chromeos',
groups=['group1', 'group2'],
depth=10,
repo_url='http://repo_url',
repo_branch='next',
)
api.repo.sync()
api.repo.sync(
force_sync=True,
detach=True,
current_branch=True,
jobs=99,
manifest_name='snapshot.xml',
no_tags=True,
optimized_fetch=True,
cache_dir='/tmp/cache',
)
api.repo.sync_manifest('<manifest></manifest>')
infos = api.repo.project_infos()
api.assertions.assertEqual(len(infos), 3)
api.assertions.assertEqual(infos[0].path, 'src/a')
info = api.repo.project_info(project='foo')
api.assertions.assertEqual(info.name, 'foo')
api.assertions.assertEqual(
api.repo.manifest_snapshot(), '<manifest></manifest>'
)
api.assertions.assertEqual(
api.repo.manifest_snapshot('some_manifest_file'),
'<manifest></manifest>',
)
snapshot_a = checkout.join('snapshot_a.xml')
snapshot_b = checkout.join('snapshot_b.xml')
with api.context(cwd=api.path['cleanup']):
api.repo.diff_manifests_informational(snapshot_a, snapshot_b)
repo_root = api.path['start_dir'].join('repo')
api.path.mock_add_paths(repo_root.join('.repo'))
with api.context(cwd=repo_root.join('subdir')):
api.repo.diff_manifests_informational(snapshot_a, snapshot_b)
from_manifest = """
<manifest>
<project name="NAME" path="PATH" revision="FROM_REV"/>
<project name="NO_CHANGE" revision="NO_CHANGE_REV"/>
<project name="DELETED" revision="REV"/>
</manifest>
"""
to_manifest = """
<manifest>
<project name="NAME" path="PATH" revision="TO_REV"/>
<project name="NO_CHANGE" revision="NO_CHANGE_REV"/>
</manifest>
"""
[diff] = api.repo.diff_manifests(from_manifest, to_manifest)
api.assertions.assertEqual(diff.name, 'NAME')
api.assertions.assertEqual(diff.path, 'PATH')
api.assertions.assertEqual(diff.from_rev, 'FROM_REV')
api.assertions.assertEqual(diff.to_rev, 'TO_REV')
api.repo.ensure_synced_checkout(
api.path['cleanup'].join('ensure'), 'http://manifest_url'
)
api.repo.start('no-projects')
api.repo.start('with-projects', projects=['project'])
def GenTests(api):
yield api.status_check.test('setup_repo')