Skip to content

Commit 5b59b07

Browse files
committed
Test mercurial edge cases to lock down current behavior
1 parent 632b02b commit 5b59b07

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

testing/test_mercurial.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,40 @@ def test_version_in_merge(wd):
108108
def test_parse_no_worktree(tmpdir):
109109
ret = parse(str(tmpdir))
110110
assert ret is None
111+
112+
113+
@pytest.fixture
114+
def version_1_0(wd):
115+
wd('hg branch default')
116+
wd.commit_testfile()
117+
wd('hg tag 1.0 -u test -d "0 0"')
118+
return wd
119+
120+
121+
@pytest.fixture
122+
def pre_merge_commit_after_tag(wd, version_1_0):
123+
wd('hg branch testbranch')
124+
wd.write('branchfile', 'branchtext')
125+
wd(wd.add_command)
126+
wd.commit()
127+
wd('hg update default')
128+
wd('hg merge testbranch')
129+
return wd
130+
131+
132+
@pytest.mark.usefixtures("pre_merge_commit_after_tag")
133+
def test_version_bump_before_merge_commit(wd):
134+
assert wd.version.startswith('1.1.dev1+')
135+
136+
137+
@pytest.mark.usefixtures("version_1_0")
138+
def test_version_bump_from_commit_including_hgtag_mods(wd):
139+
""" Test the case where a commit includes changes to .hgtags and other files
140+
"""
141+
with wd.cwd.join('.hgtags').open('a') as tagfile:
142+
tagfile.write('0 0\n')
143+
wd.write('branchfile', 'branchtext')
144+
wd(wd.add_command)
145+
assert wd.version.startswith('1.1.dev1+') # bump from dirty version
146+
wd.commit() # commits both the testfile _and_ .hgtags
147+
assert wd.version.startswith('1.1.dev2+')

0 commit comments

Comments
 (0)