sapling/eden/integration/hg/absorb_test.py
Adam Simpkins ef04ccf546 replace a bunch of pyre-fixme comments with pyre-ignoree
Summary:
D17135557 added a bunch of `pyre-fixme` comments to the EdenFS integration
tests for cases where Pyre cannot detect that some attributes are initialized
by the test case `setUp()` method.

It looks like Pyre's handling of `setUp()` is somewhat incorrect: it looks
like if a class has a `setUp()` method this currently suppresses all
uninitialized attribute errors (even if some attributes really are never
initialized).  However, Pyre does not detect `setUp()` methods inherited from
parent classes, and always warns about uninitialized attributes in this case
even they are initialized.

Lets change these comments from `pyre-fixme` to `pyre-ignore` since this
appears to be an issue with Pyre rather than with this code.  T62487924 is
open to track adding support for annotating custom constructor methods, which
might help here.  I've also posted in Pyre Q&A about incorrect handling of
`setUp()` in derived classes.

Reviewed By: grievejia

Differential Revision: D19963118

fbshipit-source-id: 9fd13fc8665367e0780f871a5a0d9a8fe50cc687
2020-02-24 18:55:19 -08:00

136 lines
3.3 KiB
Python

#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2.
import logging
from eden.integration.lib import hgrepo
from .lib.hg_extension_test_base import EdenHgTestCase, hg_test
log = logging.getLogger("eden.test.absorb")
@hg_test
# pyre-ignore[13]: T62487924
class AbsorbTest(EdenHgTestCase):
commit1: str
def populate_backing_repo(self, repo: hgrepo.HgRepository) -> None:
repo.write_file("readme.txt", "readme\n")
repo.write_file(
"src/test.c",
"""\
start of the file
line 1
line 2
line 3
end of the file
""",
)
self.commit1 = repo.commit("Initial commit.")
repo.hg("phase", "--public", self.commit1)
log.debug("commit1: %s", self.commit1)
def test_absorb(self) -> None:
self.assert_status_empty()
# Update src/test.c in our first draft commit
self.write_file(
"src/test.c",
"""\
start of the file
line 1
new line a
line 2
new line b
line 3
end of the file
""",
)
self.assert_status({"src/test.c": "M"})
commit2 = self.repo.commit("new lines in test.c\n")
self.assert_status_empty()
log.debug("commit2: %s", commit2)
# Update src/new.c in our second draft commit
self.write_file(
"src/new.c",
"""\
this is a brand new file
with some new contents
last line
""",
)
self.hg("add", "src/new.c")
self.assert_status({"src/new.c": "A"})
commit3 = self.repo.commit("add new.c\n")
self.assert_status_empty()
log.debug("commit2: %s", commit3)
# Now modify test.c and new.c in the working copy
self.write_file(
"src/test.c",
"""\
start of the file
line 1
new line abc
testing
line 2
new line b
line 3
end of the file
""",
)
self.write_file(
"src/new.c",
"""\
this is a brand new file
with some enhanced new contents
last line
""",
)
self.assert_status({"src/new.c": "M", "src/test.c": "M"})
old_commits = self.repo.log()
# Run "hg absorb" to fold these changes into their respective commits
out = self.hg("absorb", "-ap")
log.debug("absorb output:\n%s" % (out,))
self.assert_status_empty()
# Verify the results are what we expect
new_commits = self.repo.log()
files_changed = self.repo.log(template="{files}")
self.assertEqual(len(old_commits), len(new_commits))
self.assertEqual(old_commits[0], new_commits[0])
self.assertNotEqual(old_commits[1], new_commits[1])
self.assertNotEqual(old_commits[2], new_commits[2])
self.assertEqual(files_changed[0], "readme.txt src/test.c")
self.assertEqual(files_changed[1], "src/test.c")
self.assertEqual(files_changed[2], "src/new.c")
self.assertEqual(
self.read_file("src/test.c"),
"""\
start of the file
line 1
new line abc
testing
line 2
new line b
line 3
end of the file
""",
)
self.assertEqual(
self.read_file("src/new.c"),
"""\
this is a brand new file
with some enhanced new contents
last line
""",
)