Skip to content

Commit ec2ccb1

Browse files
authored
Merge pull request #1418 from timkpaine/tkp/tags
Add TAGS as range parameter, fixes #488 fixes #1027
2 parents 7ecc55d + 8b2a653 commit ec2ccb1

File tree

3 files changed

+33
-12
lines changed

3 files changed

+33
-12
lines changed

asv/commands/run.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,18 @@ def _setup_arguments(cls, parser, env_default_same=False):
7979
rev-list``; or Mercurial log command. See 'specifying ranges'
8080
section of the `gitrevisions` manpage, or 'hg help revisions',
8181
for more info. Also accepts the
82-
special values 'NEW', 'ALL', 'EXISTING', and 'HASHFILE:xxx'.
82+
special values 'NEW', 'ALL', 'EXISTING', 'TAGS', and
83+
'HASHFILE:xxx'.
8384
'NEW' will benchmark all commits since the latest
84-
benchmarked on this machine. 'ALL' will benchmark all
85-
commits in the project. 'EXISTING' will benchmark against
86-
all commits for which there are existing benchmarks on any
87-
machine. 'HASHFILE:xxx' will benchmark only a specific set
88-
of hashes given in the file named 'xxx' ('-' means stdin),
89-
which must have one hash per line. By default, will benchmark
85+
benchmarked on this machine.
86+
'ALL' will benchmark all commits in the project.
87+
'EXISTING' will benchmark against all commits for which there
88+
are existing benchmarks on any machine.
89+
'TAGS' will benchmark against all tags in the project.
90+
'HASHFILE:xxx' will benchmark only a specific set of hashes
91+
given in the file named 'xxx' ('-' means stdin), which must
92+
have one hash per line.
93+
By default, will benchmark
9094
the head of each configured of the branches.""")
9195
parser.add_argument(
9296
"--date-period", type=common_args.time_period, default=None,
@@ -232,12 +236,15 @@ def run(cls, conf, range_spec=None, steps=None, date_period=None,
232236
branch in conf.branches]))
233237
except NoSuchNameError as exc:
234238
raise util.UserError(f'Unknown branch {exc} in configuration')
235-
elif range_spec == 'EXISTING':
239+
elif range_spec == "EXISTING":
236240
commit_hashes = get_existing_hashes(conf.results_dir)
237241
elif range_spec == "NEW":
238242
# New commits on each configured branches
239243
old_commit_hashes = get_existing_hashes(conf.results_dir)
240244
commit_hashes = repo.get_new_branch_commits(conf.branches, old_commit_hashes)
245+
elif range_spec == "TAGS":
246+
# All tags on each configured branches
247+
commit_hashes = list(reversed(list(repo.get_tags().keys())))
241248
elif range_spec == "ALL":
242249
# All commits on each configured branches
243250
commit_hashes = repo.get_new_branch_commits(conf.branches, [])

test/test_run.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ def test_run_spec(basic_conf_2):
4242
conf.build_cache_size = 5
4343

4444
extra_branches = [(f'{util.git_default_branch()}~1', 'some-branch', [12])]
45+
tags = (2, 12)
4546
dvcs_path = os.path.join(tmpdir, 'test_repo2')
4647
dvcs = tools.generate_test_repo(dvcs_path, [1, 2],
47-
extra_branches=extra_branches)
48+
extra_branches=extra_branches,
49+
tags=tags)
4850
conf.repo = dvcs.path
4951

5052
initial_commit = dvcs.get_hash(f"{util.git_default_branch()}~1")
@@ -103,6 +105,9 @@ def _test_run(range_spec, branches, expected_commits):
103105
for range_spec in (None, "NEW", "ALL"):
104106
_test_run(range_spec, branches, expected_commits)
105107

108+
expected_tag_runs = (initial_commit, "tag2", "tag12")
109+
_test_run("TAGS", [None], expected_tag_runs)
110+
106111
# test the HASHFILE version of range_spec'ing
107112
expected_commits = (initial_commit, branch_commit)
108113
with open(os.path.join(tmpdir, 'hashes_to_benchmark'), 'w') as f:

test/tools.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@ def copy_template(src, dst, dvcs, values):
352352

353353

354354
def generate_test_repo(tmpdir, values=[0], dvcs_type='git',
355-
extra_branches=(), subdir=''):
355+
extra_branches=(), tags=(),
356+
subdir=''):
356357
"""
357358
Generate a test repository
358359
@@ -369,6 +370,8 @@ def generate_test_repo(tmpdir, values=[0], dvcs_type='git',
369370
For branch start commits, use relative references, e.g.,
370371
the format 'main~10' or 'default~10' works both for Hg
371372
and Git.
373+
tags: list
374+
List of of values from `values` to tag in the repository.
372375
subdir
373376
A relative subdirectory inside the repository to copy the
374377
test project into.
@@ -406,7 +409,11 @@ def generate_test_repo(tmpdir, values=[0], dvcs_type='git',
406409
copy_template(template_path, project_path, dvcs, mapping)
407410

408411
dvcs.commit(f"Revision {i}")
409-
dvcs.tag(i)
412+
if tags:
413+
if value in tags:
414+
dvcs.tag(value)
415+
else:
416+
dvcs.tag(i)
410417

411418
if extra_branches:
412419
for start_commit, branch_name, values in extra_branches:
@@ -418,7 +425,9 @@ def generate_test_repo(tmpdir, values=[0], dvcs_type='git',
418425
}
419426
copy_template(template_path, project_path, dvcs, mapping)
420427
dvcs.commit(f"Revision {branch_name}.{i}")
421-
428+
if tags:
429+
if value in tags:
430+
dvcs.tag(value)
422431
return dvcs
423432

424433

0 commit comments

Comments
 (0)