Skip to content

Instantly share code, notes, and snippets.

@cjerdonek
Created December 20, 2011 01:42
Show Gist options
  • Save cjerdonek/1499834 to your computer and use it in GitHub Desktop.
Save cjerdonek/1499834 to your computer and use it in GitHub Desktop.
a git-bisect script to find where pystache issue #53 was fixed
#!/usr/bin/env python
# coding: utf-8
"""
A script to use in conjunction with git-bisect to find the point
in pystache's development branch at which issue #53 was fixed:
https://github.com/defunkt/pystache/pull/53
Because git-bisect expects the "bad" outcome to come after the "good"
outcome, we take "bad" to mean the issue has been fixed, and "good" to
mean that the issue still exists.
For the initial "good" outcome, we can take the current HEAD of master:
7ccb55fd95f0d16cde6e46774ef80f35c3a3068f
To use git-bisect:
git checkout development
git bisect start HEAD 7ccb55fd95f0d16cde6e46774ef80f35c3a3068f
git bisect run test_issue_53.py
"""
import time
# Slow things down a bit: not adding a sleep causes test flakiness,
# for some reason.
time.sleep(1)
import pystache
template = """{{#r1}}<div class='twopeat'></div>
{{/r1}}{{#r2}}<div class='threepeat'></div>
{{/r2}}"""
context = {'r1': [True, True], 'r2': [True, True, True]}
actual = pystache.render(template, context)
expected = """<div class='twopeat'></div>
<div class='twopeat'></div>
<div class='threepeat'></div>
<div class='threepeat'></div>
<div class='threepeat'></div>
"""
if actual == expected:
# Then this is "bad" for git-bisect purposes.
print "**match"
exit(1)
print "**no match"
print repr(actual)
print repr(expected)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment