Merge "Remove member signature and inner classes from signature-patterns.csv"
This commit is contained in:
@@ -30,11 +30,21 @@ def produce_patterns_from_file(file):
|
||||
return produce_patterns_from_stream(f)
|
||||
|
||||
def produce_patterns_from_stream(stream):
|
||||
patterns = []
|
||||
allFlagsReader = dict_reader(stream)
|
||||
for row in allFlagsReader:
|
||||
# Read in all the signatures into a list and remove member names.
|
||||
patterns = set()
|
||||
for row in dict_reader(stream):
|
||||
signature = row['signature']
|
||||
patterns.append(signature)
|
||||
text = signature.removeprefix("L")
|
||||
# Remove the class specific member signature
|
||||
pieces = text.split(";->")
|
||||
qualifiedClassName = pieces[0]
|
||||
# Remove inner class names as they cannot be separated from the containing outer class.
|
||||
pieces = qualifiedClassName.split("$", maxsplit=1)
|
||||
pattern = pieces[0]
|
||||
patterns.add(pattern)
|
||||
|
||||
patterns = list(patterns)
|
||||
patterns.sort()
|
||||
return patterns
|
||||
|
||||
def main(args):
|
||||
|
@@ -28,12 +28,15 @@ class TestGeneratedPatterns(unittest.TestCase):
|
||||
|
||||
def test_generate(self):
|
||||
patterns = self.produce_patterns_from_string('''
|
||||
Ljava/lang/ProcessBuilder$Redirect$1;-><init>()V,blocked
|
||||
Ljava/lang/Character$UnicodeScript;->of(I)Ljava/lang/Character$UnicodeScript;,public-api
|
||||
Ljava/lang/Object;->hashCode()I,public-api,system-api,test-api
|
||||
Ljava/lang/Object;->toString()Ljava/lang/String;,blocked
|
||||
''')
|
||||
expected = [
|
||||
"Ljava/lang/Object;->hashCode()I",
|
||||
"Ljava/lang/Object;->toString()Ljava/lang/String;",
|
||||
"java/lang/Character",
|
||||
"java/lang/Object",
|
||||
"java/lang/ProcessBuilder",
|
||||
]
|
||||
self.assertEqual(expected, patterns)
|
||||
|
||||
|
Reference in New Issue
Block a user