From e25016a4141d1fc51c1a69fb67b52604abe26457 Mon Sep 17 00:00:00 2001 From: Joe Ryan Date: Sun, 30 Sep 2018 20:45:26 -0700 Subject: [PATCH 1/4] Add "no-commit-filtering" command line option for asv publish. The "no-commit-filtering" option will ensure that every commit that has a corresponding benchmark will appear in the output graphs, instead of just commits that are reachable via "git rev-parse --first-parent" from one of the listed branches. --- asv/commands/publish.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/asv/commands/publish.py b/asv/commands/publish.py index b617a872e..359050de6 100644 --- a/asv/commands/publish.py +++ b/asv/commands/publish.py @@ -59,6 +59,9 @@ def setup_arguments(cls, subparsers): parser.add_argument( '--no-pull', action='store_true', dest='no_pull', help="Do not pull the repository") + parser.add_argument( + '--no-commit-filtering', action='store_true', dest='no_commit_filtering', + help="Include all commits, instead of filtering. Default is 'False'.") parser.add_argument( 'range', nargs='?', default=None, help="""Optional commit range to consider""") @@ -75,7 +78,9 @@ def setup_arguments(cls, subparsers): def run_from_conf_args(cls, conf, args): if args.html_dir is not None: conf.html_dir = args.html_dir - return cls.run(conf=conf, range_spec=args.range, pull=not args.no_pull) + + return cls.run(conf=conf, range_spec=args.range, pull=not args.no_pull, + no_commit_filtering=args.no_commit_filtering) @staticmethod def iter_results(conf, repo, range_spec=None): @@ -91,7 +96,7 @@ def iter_results(conf, repo, range_spec=None): yield result @classmethod - def run(cls, conf, range_spec=None, pull=True): + def run(cls, conf, range_spec=None, pull=True, no_commit_filtering=False): params = {} graphs = GraphSet() machines = {} @@ -182,7 +187,7 @@ def copy_ignore(src, names): for branch in [ branch for branch, commits in branches.items() - if results.commit_hash in commits + if no_commit_filtering or results.commit_hash in commits ]: cur_params = dict(results.params) cur_params['branch'] = repo.get_branch_name(branch) From 5456ed081394c3735e6dc74ed0d789c50cff0b0d Mon Sep 17 00:00:00 2001 From: Joe Ryan Date: Sun, 30 Sep 2018 20:50:50 -0700 Subject: [PATCH 2/4] Add alternate fixture to test_publish.py for working with a branching repo. The commit structure is from test_repo.py, which also has a nice diagram of it. --- test/test_publish.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/test/test_publish.py b/test/test_publish.py index 06b681320..37a365560 100644 --- a/test/test_publish.py +++ b/test/test_publish.py @@ -168,9 +168,53 @@ def _generate_result_dir(values, commits_without_result=None): commit_values[commit] = value conf = tools.generate_result_dir(tmpdir, dvcs, commit_values) repo = get_repo(conf) + return conf, repo, commits return _generate_result_dir +@pytest.fixture(params=[ + "git", + pytest.param("hg", marks=pytest.mark.skipif(hglib is None, reason="needs hglib")), +]) +def generate_branched_result_dir(request, tmpdir): + tmpdir = six.text_type(tmpdir) + dvcs_type = request.param + + def _generate_branched_result_dir(): + if dvcs_type == "git": + master = "master" + elif dvcs_type == "hg": + master = "default" + + # from test_repo.py + dvcs = tools.generate_repo_from_ops(tmpdir, dvcs_type, [ + ("commit", 1), + ("checkout", "stable", master), + ("commit", 2), + ("checkout", master), + ("commit", 3), + ("merge", "stable"), + ("commit", 4), + ("checkout", "stable"), + ("merge", master, "Merge master"), + ("commit", 5), + ("checkout", master), + ("commit", 6), + ]) + + commits = list(reversed(dvcs.get_branch_hashes())) + commit_values = {} + for i, commit in enumerate(commits): + commit_values[commit] = i + + conf = tools.generate_result_dir(tmpdir, dvcs, commit_values) + conf.branches = ['master'] + repo = get_repo(conf) + + return conf, repo, commits + return _generate_branched_result_dir + + def _graph_path(dvcs_type): if dvcs_type == "git": master = "master" From 0776e6140e13e81a5211dfb9b289135806efccd5 Mon Sep 17 00:00:00 2001 From: Joe Ryan Date: Sun, 30 Sep 2018 20:52:41 -0700 Subject: [PATCH 3/4] Add test for --no-commit-filtering to test_publish.py --- test/test_publish.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/test_publish.py b/test/test_publish.py index 37a365560..2e62aaf98 100644 --- a/test/test_publish.py +++ b/test/test_publish.py @@ -232,8 +232,21 @@ def test_publish_range_spec(generate_result_dir): ): tools.run_asv_with_conf(conf, "publish", range_spec) data = util.load_json(join(conf.html_dir, 'index.json')) + assert set(data['revision_to_hash'].values()) == expected +@pytest.mark.parametrize('filter_commits', (False, True)) +def test_publish_filtered(filter_commits, generate_branched_result_dir): + conf, repo, commits = generate_branched_result_dir() + + args = [] if filter_commits else ['--no-commit-filtering'] + tools.run_asv_with_conf(conf, "publish", *args) + + data = util.load_json(join(conf.html_dir, _graph_path(repo.dvcs))) + if filter_commits: + assert len(data) == 5 + else: + assert len(data) == 6 def test_regression_simple(generate_result_dir): conf, repo, commits = generate_result_dir(5 * [1] + 5 * [10]) From c72025039f9e73496c42a9d122e0b660a372b193 Mon Sep 17 00:00:00 2001 From: germanjoey Date: Mon, 1 Oct 2018 10:24:46 -0700 Subject: [PATCH 4/4] Correctly use default for master on hg. --- test/test_publish.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_publish.py b/test/test_publish.py index 2e62aaf98..d282da17c 100644 --- a/test/test_publish.py +++ b/test/test_publish.py @@ -208,7 +208,7 @@ def _generate_branched_result_dir(): commit_values[commit] = i conf = tools.generate_result_dir(tmpdir, dvcs, commit_values) - conf.branches = ['master'] + conf.branches = [master] repo = get_repo(conf) return conf, repo, commits