Merge pull request #4589 from MiniRML/fix/tools-cut-helper-accounting
fix(tools): exclude cut helpers from NID accounting
This commit is contained in:
commit
a56c905df6
|
|
@ -109,7 +109,7 @@ class Check:
|
|||
if core and TITLE.search(text):
|
||||
self.report("title-specific", path, number, TITLE.search(text).group(0))
|
||||
match = EXPORT.search(bare)
|
||||
if match and path.startswith("core/libs/prx/") and not match.group(1).endswith("_nid_no_patch"):
|
||||
if match and path.startswith("core/libs/prx/") and not match.group(1).endswith(("_nid_no_patch", "_nid_no_patch_cut")):
|
||||
source = source or self.show(path).splitlines()
|
||||
body = function_body(source, number - 1)
|
||||
if body is None:
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ def exports(diff):
|
|||
lines = diff.splitlines()
|
||||
for i, line in enumerate(lines):
|
||||
m = EXPORT.match(line)
|
||||
if not m or m.group(1).endswith("_nid_no_patch"):
|
||||
if not m or m.group(1).endswith(("_nid_no_patch", "_nid_no_patch_cut")):
|
||||
continue
|
||||
text = line[1:]
|
||||
for nxt in lines[i + 1:]:
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ def scan_library(path):
|
|||
wrappers = inert_wrappers(text)
|
||||
for match in DEFINITION.finditer(text):
|
||||
name = match.group(1)
|
||||
if name.endswith("_nid_no_patch"):
|
||||
if name.endswith(("_nid_no_patch", "_nid_no_patch_cut")):
|
||||
continue
|
||||
body = text[match.end() - 1:body_end(text, match.end() - 1)]
|
||||
if any(call.group(1) in calls for call in CALL.finditer(body)):
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ DEFINITION = "int APS5_VABI sceFooBar(int a, int b) { return a + b; }\n"
|
|||
|
||||
|
||||
class WrappedDeclarationTests(unittest.TestCase):
|
||||
def check(self, first_file, first_text):
|
||||
def check(self, first_file, first_text, second_text=DEFINITION):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ class WrappedDeclarationTests(unittest.TestCase):
|
|||
git("commit", "-qm", "feat: add library a")
|
||||
second = root / "core/libs/prx/libSceB/Export.cpp"
|
||||
second.parent.mkdir(parents=True)
|
||||
second.write_text(DEFINITION, encoding="utf-8")
|
||||
second.write_text(second_text, encoding="utf-8")
|
||||
git("add", ".")
|
||||
git("commit", "-qm", "feat: add library b")
|
||||
env = {key: value for key, value in os.environ.items()
|
||||
|
|
@ -47,6 +47,12 @@ class WrappedDeclarationTests(unittest.TestCase):
|
|||
self.assertNotIn("duplicate-export", result.stdout, result.stdout + result.stderr)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
|
||||
def test_cut_helpers_in_different_libraries_are_not_duplicate_nids(self):
|
||||
helper = "int APS5_VABI Support_nid_no_patch_cut() { return 3; }\n"
|
||||
result = self.check("Export.cpp", helper, helper)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
self.assertNotIn("[duplicate-export]", result.stdout)
|
||||
|
||||
def test_wrapped_definition_is_a_duplicate(self):
|
||||
result = self.check("Export.cpp", "int APS5_VABI sceFooBar(int a,\n int b) {\n return 0;\n}\n")
|
||||
self.assertEqual(result.returncode, 1, result.stdout + result.stderr)
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ class ExportTests(unittest.TestCase):
|
|||
def test_added_definitions_are_exports(self):
|
||||
self.assertEqual(pr_overlap.exports(DIFF), {"mlock_nid_postfix", "sceKernelRead", "getpid_nid_postfix", "sceNpUniversalDataSystemCreateEvent"})
|
||||
|
||||
def test_cut_helpers_are_not_export_overlaps(self):
|
||||
diff = DIFF + '+void APS5_VABI Helper_nid_no_patch_cut() {\n'
|
||||
self.assertEqual(pr_overlap.exports(diff), pr_overlap.exports(DIFF))
|
||||
|
||||
def test_declarations_are_not_exports(self):
|
||||
self.assertTrue(TRAILING.endswith("; \n"))
|
||||
found = pr_overlap.exports(DIFF)
|
||||
|
|
|
|||
|
|
@ -244,6 +244,19 @@ class ProgressTests(unittest.TestCase):
|
|||
self.assertIn("| libSceExample | `A` |", report)
|
||||
self.assertIn("<summary>⚪ 1 behaviourally empty (constant return or throw)</summary>", report)
|
||||
|
||||
def test_cut_helpers_are_not_system_exports(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
library = Path(directory) / "libSceExample"
|
||||
library.mkdir()
|
||||
(library / "Export.cpp").write_text(
|
||||
"int APS5_VABI Ready_nid_no_patch_cut() { return 1; }\n"
|
||||
"int APS5_VABI Pending_nid_no_patch_cut() { NotImplemented_nid_no_patch(__func__); }\n"
|
||||
"int APS5_VABI Real() { return 2; }\n", encoding="utf-8")
|
||||
group = progress.scan_library(library)
|
||||
self.assertEqual(group["done_names"], ["Real"])
|
||||
self.assertEqual(group["todo_names"], [])
|
||||
self.assertEqual(group["inert_names"], ["Real"])
|
||||
|
||||
def test_empty_libraries(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
|
|
|
|||
Loading…
Reference in New Issue