dex_test.py (2430B)
1 #!/usr/bin/env python3 2 # Copyright 2022 The Chromium Authors 3 # Use of this source code is governed by a BSD-style license that can be 4 # found in the LICENSE file. 5 6 import unittest 7 8 import dex 9 10 11 class DexTest(unittest.TestCase): 12 def testStdErrFilter(self): 13 # pylint: disable=line-too-long 14 output = """\ 15 some initial message 16 Warning in ../../clank/third_party/google3/pg_confs/java_com_google_protobuf_lite_proguard.pgcfg: 17 Rule matches the static final field `java.lang.String com.google.protobuf.BaseGeneratedExtensionRegistryLite.CONTAINING_TYPE_0`, which may have been inlined: -identifiernamestring class com.google.protobuf.*GeneratedExtensionRegistryLite { 18 static java.lang.String CONTAINING_TYPE_*; 19 } 20 Warning: some message 21 Warning in gen/.../Foo.jar:Bar.class: 22 Type `libcore.io.Memory` was not found, it is required for default or static interface methods desugaring of `void Bar.a(long, byte)` 23 Warning: Missing class com.google.android.apps.gsa.search.shared.service.proto.PublicStopClientEvent (referenced from: com.google.protobuf.GeneratedMessageLite$GeneratedExtension com.google.protobuf.BaseGeneratedExtensionRegistryLite.findLiteExtensionByNumber(com.google.protobuf.MessageLite, int)) 24 Missing class com.google.android.gms.feedback.ApplicationProperties (referenced from: com.google.protobuf.GeneratedMessageLite$GeneratedExtension com.google.protobuf.BaseGeneratedExtensionRegistryLite.findLiteExtensionByNumber(com.google.protobuf.MessageLite, int)) 25 """ 26 expected = """\ 27 some initial message 28 Warning: some message 29 Missing class com.google.android.gms.feedback.ApplicationProperties (referenced from: com.google.protobuf.GeneratedMessageLite$GeneratedExtension com.google.protobuf.BaseGeneratedExtensionRegistryLite.findLiteExtensionByNumber(com.google.protobuf.MessageLite, int)) 30 """ 31 # pylint: enable=line-too-long 32 filters = (dex.DEFAULT_IGNORE_WARNINGS + 33 ('CONTAINING_TYPE_', 'libcore', 'PublicStopClientEvent')) 34 filter_func = dex.CreateStderrFilter(filters) 35 self.assertEqual(filter_func(output), expected) 36 37 # Test no preamble, not filtered. 38 output = """Warning: hi""" 39 expected = output 40 self.assertEqual(filter_func(output), expected) 41 42 # Test no preamble, filtered 43 output = """\ 44 Warning: PublicStopClientEvent is hungry. 45 """ 46 expected = '' 47 self.assertEqual(filter_func(output), expected) 48 49 50 if __name__ == '__main__': 51 unittest.main()