Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mattst88 committed Jun 6, 2024
1 parent 50bfe19 commit a255686
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions pym/gentoolkit/merge_driver_ekeyword/test_merge_driver_ekeyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@


TESTDIR = pathlib.Path(__file__).parent / "tests"
TESTDIRS = [os.path.dirname(x) for x in TESTDIR.rglob("expected.ebuild")]


def file_contents(filename):
Expand All @@ -26,25 +27,30 @@ class TestMain(unittest.TestCase):
"""Tests for the main entry point"""

def testMerge(self):
for ebuild in TESTDIR.rglob("expected.ebuild"):
with tempfile.TemporaryDirectory() as tmpdir:
shutil.copytree(os.path.dirname(ebuild), tmpdir, dirs_exist_ok=True)

O = os.path.join(tmpdir, "common-ancestor.ebuild")
A = os.path.join(tmpdir, "A.ebuild")
B = os.path.join(tmpdir, "B.ebuild")
P = ebuild
expected = os.path.join(tmpdir, P)

print(f"O = {O}")
print(f"A = {A}")
print(f"B = {B}")
print(f"P = {P}")

result = merge_driver_ekeyword.main([O, A, B, P])
self.assertEqual(0, result)
self.assertTrue(file_contents(expected), file_contents(A))
self.assertTrue(filecmp.cmp(expected, A))
for dir in TESTDIRS:
for reverse in (False, True):
with self.subTest(dir=dir, reverse=reverse), tempfile.TemporaryDirectory() as tmpdir:
shutil.copytree(dir, tmpdir, dirs_exist_ok=True)

O = os.path.join(tmpdir, "common-ancestor.ebuild")
if not reverse:
A = os.path.join(tmpdir, "A.ebuild")
B = os.path.join(tmpdir, "B.ebuild")
else:
A = os.path.join(tmpdir, "B.ebuild")
B = os.path.join(tmpdir, "A.ebuild")
P = "expected.ebuild"
expected = os.path.join(tmpdir, P)

print(f"O = {O}")
print(f"A = {A}")
print(f"B = {B}")
print(f"P = {P}")

result = merge_driver_ekeyword.main([O, A, B, P])
self.assertEqual(0, result)
self.assertTrue(file_contents(expected), file_contents(A))
self.assertTrue(filecmp.cmp(expected, A))

# def testEmptyString(self):
# with self.assertRaises(SystemExit) as e:
Expand Down

0 comments on commit a255686

Please sign in to comment.