testlib: adds drawdag support

Summary: Adds a drawdag function for easily creating a repository.

Differential Revision: D35683763

fbshipit-source-id: 23d9faa28b4519b13bca07a029169043bc84eece
This commit is contained in:
Durham Goode 2022-04-21 19:06:14 -07:00 committed by Facebook GitHub Bot
parent d3df270dff
commit 51a527b7b3
3 changed files with 27 additions and 0 deletions

View File

@ -27,6 +27,7 @@ class BaseTest(unittest.TestCase):
f.write(
f"""
[commitcloud]
enablestatus = False
hostname = testhost
remotebookmarkssync = True
servicetype = local

View File

@ -71,3 +71,6 @@ class Repo:
remote, name = name.split("/", 1)
bookmarks[name] = Commit(self, entry["node"])
return bookmarks
def drawdag(self, text: str) -> None:
self.hg.debugdrawdag(stdin=text)

View File

@ -99,6 +99,29 @@ class TestLibTests(BaseTest):
wc.hg.bookmark("foo")
self.assertEqual(repo.bookmarks()["foo"], commit)
@hgtest
def test_drawdag(self, repo: Repo, wc: WorkingCopy) -> None:
repo.drawdag(
"""
C
|
B
|
A
"""
)
self.assertEqual(
repo.hg.smartlog(template="{desc}").stdout,
"""o C
o B
o A
""",
)
if __name__ == "__main__":
import unittest