diff --git a/asv/commands/run.py b/asv/commands/run.py index 7e1cb4e64..35ed5cc2d 100644 --- a/asv/commands/run.py +++ b/asv/commands/run.py @@ -79,14 +79,18 @@ def _setup_arguments(cls, parser, env_default_same=False): rev-list``; or Mercurial log command. See 'specifying ranges' section of the `gitrevisions` manpage, or 'hg help revisions', for more info. Also accepts the - special values 'NEW', 'ALL', 'EXISTING', and 'HASHFILE:xxx'. + special values 'NEW', 'ALL', 'EXISTING', 'TAGS', and + 'HASHFILE:xxx'. 'NEW' will benchmark all commits since the latest - benchmarked on this machine. 'ALL' will benchmark all - commits in the project. 'EXISTING' will benchmark against - all commits for which there are existing benchmarks on any - machine. 'HASHFILE:xxx' will benchmark only a specific set - of hashes given in the file named 'xxx' ('-' means stdin), - which must have one hash per line. By default, will benchmark + benchmarked on this machine. + 'ALL' will benchmark all commits in the project. + 'EXISTING' will benchmark against all commits for which there + are existing benchmarks on any machine. + 'TAGS' will benchmark against all tags in the project. + 'HASHFILE:xxx' will benchmark only a specific set of hashes + given in the file named 'xxx' ('-' means stdin), which must + have one hash per line. + By default, will benchmark the head of each configured of the branches.""") parser.add_argument( "--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, branch in conf.branches])) except NoSuchNameError as exc: raise util.UserError(f'Unknown branch {exc} in configuration') - elif range_spec == 'EXISTING': + elif range_spec == "EXISTING": commit_hashes = get_existing_hashes(conf.results_dir) elif range_spec == "NEW": # New commits on each configured branches old_commit_hashes = get_existing_hashes(conf.results_dir) commit_hashes = repo.get_new_branch_commits(conf.branches, old_commit_hashes) + elif range_spec == "TAGS": + # All tags on each configured branches + commit_hashes = list(reversed(list(repo.get_tags().keys()))) elif range_spec == "ALL": # All commits on each configured branches commit_hashes = repo.get_new_branch_commits(conf.branches, []) diff --git a/test/test_run.py b/test/test_run.py index e48815618..0194c4d63 100644 --- a/test/test_run.py +++ b/test/test_run.py @@ -42,9 +42,11 @@ def test_run_spec(basic_conf_2): conf.build_cache_size = 5 extra_branches = [(f'{util.git_default_branch()}~1', 'some-branch', [12])] + tags = (2, 12) dvcs_path = os.path.join(tmpdir, 'test_repo2') dvcs = tools.generate_test_repo(dvcs_path, [1, 2], - extra_branches=extra_branches) + extra_branches=extra_branches, + tags=tags) conf.repo = dvcs.path initial_commit = dvcs.get_hash(f"{util.git_default_branch()}~1") @@ -103,6 +105,9 @@ def _test_run(range_spec, branches, expected_commits): for range_spec in (None, "NEW", "ALL"): _test_run(range_spec, branches, expected_commits) + expected_tag_runs = (initial_commit, "tag2", "tag12") + _test_run("TAGS", [None], expected_tag_runs) + # test the HASHFILE version of range_spec'ing expected_commits = (initial_commit, branch_commit) with open(os.path.join(tmpdir, 'hashes_to_benchmark'), 'w') as f: diff --git a/test/tools.py b/test/tools.py index dd6eb2eb3..0f98cba03 100644 --- a/test/tools.py +++ b/test/tools.py @@ -346,7 +346,8 @@ def copy_template(src, dst, dvcs, values): def generate_test_repo(tmpdir, values=[0], dvcs_type='git', - extra_branches=(), subdir=''): + extra_branches=(), tags=(), + subdir=''): """ Generate a test repository @@ -363,6 +364,8 @@ def generate_test_repo(tmpdir, values=[0], dvcs_type='git', For branch start commits, use relative references, e.g., the format 'main~10' or 'default~10' works both for Hg and Git. + tags: list + List of of values from `values` to tag in the repository. subdir A relative subdirectory inside the repository to copy the test project into. @@ -400,7 +403,11 @@ def generate_test_repo(tmpdir, values=[0], dvcs_type='git', copy_template(template_path, project_path, dvcs, mapping) dvcs.commit(f"Revision {i}") - dvcs.tag(i) + if tags: + if value in tags: + dvcs.tag(value) + else: + dvcs.tag(i) if extra_branches: for start_commit, branch_name, values in extra_branches: @@ -412,7 +419,9 @@ def generate_test_repo(tmpdir, values=[0], dvcs_type='git', } copy_template(template_path, project_path, dvcs, mapping) dvcs.commit(f"Revision {branch_name}.{i}") - + if tags: + if value in tags: + dvcs.tag(value) return dvcs