Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option for bypassing commit filtering for asv publish. #748

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions asv/commands/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -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""")
Expand All @@ -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):
Expand All @@ -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 = {}
Expand Down Expand Up @@ -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)
Expand Down
57 changes: 57 additions & 0 deletions test/test_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -188,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])
Expand Down