1*6777b538SAndroid Build Coastguard Worker#!/usr/bin/env python3 2*6777b538SAndroid Build Coastguard Worker# Copyright 2022 The Chromium Authors 3*6777b538SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be 4*6777b538SAndroid Build Coastguard Worker# found in the LICENSE file. 5*6777b538SAndroid Build Coastguard Worker 6*6777b538SAndroid Build Coastguard Workerimport unittest 7*6777b538SAndroid Build Coastguard Worker 8*6777b538SAndroid Build Coastguard Workerimport dex 9*6777b538SAndroid Build Coastguard Worker 10*6777b538SAndroid Build Coastguard Worker 11*6777b538SAndroid Build Coastguard Workerclass DexTest(unittest.TestCase): 12*6777b538SAndroid Build Coastguard Worker def testStdErrFilter(self): 13*6777b538SAndroid Build Coastguard Worker # pylint: disable=line-too-long 14*6777b538SAndroid Build Coastguard Worker output = """\ 15*6777b538SAndroid Build Coastguard Workersome initial message 16*6777b538SAndroid Build Coastguard WorkerWarning in ../../clank/third_party/google3/pg_confs/java_com_google_protobuf_lite_proguard.pgcfg: 17*6777b538SAndroid Build Coastguard WorkerRule 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*6777b538SAndroid Build Coastguard Worker static java.lang.String CONTAINING_TYPE_*; 19*6777b538SAndroid Build Coastguard Worker} 20*6777b538SAndroid Build Coastguard WorkerWarning: some message 21*6777b538SAndroid Build Coastguard WorkerWarning in gen/.../Foo.jar:Bar.class: 22*6777b538SAndroid Build Coastguard Worker Type `libcore.io.Memory` was not found, it is required for default or static interface methods desugaring of `void Bar.a(long, byte)` 23*6777b538SAndroid Build Coastguard WorkerWarning: 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*6777b538SAndroid Build Coastguard WorkerMissing 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*6777b538SAndroid Build Coastguard Worker""" 26*6777b538SAndroid Build Coastguard Worker expected = """\ 27*6777b538SAndroid Build Coastguard Workersome initial message 28*6777b538SAndroid Build Coastguard WorkerWarning: some message 29*6777b538SAndroid Build Coastguard WorkerMissing 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*6777b538SAndroid Build Coastguard Worker""" 31*6777b538SAndroid Build Coastguard Worker # pylint: enable=line-too-long 32*6777b538SAndroid Build Coastguard Worker filters = (dex.DEFAULT_IGNORE_WARNINGS + 33*6777b538SAndroid Build Coastguard Worker ('CONTAINING_TYPE_', 'libcore', 'PublicStopClientEvent')) 34*6777b538SAndroid Build Coastguard Worker filter_func = dex.CreateStderrFilter(filters) 35*6777b538SAndroid Build Coastguard Worker self.assertEqual(filter_func(output), expected) 36*6777b538SAndroid Build Coastguard Worker 37*6777b538SAndroid Build Coastguard Worker # Test no preamble, not filtered. 38*6777b538SAndroid Build Coastguard Worker output = """Warning: hi""" 39*6777b538SAndroid Build Coastguard Worker expected = output 40*6777b538SAndroid Build Coastguard Worker self.assertEqual(filter_func(output), expected) 41*6777b538SAndroid Build Coastguard Worker 42*6777b538SAndroid Build Coastguard Worker # Test no preamble, filtered 43*6777b538SAndroid Build Coastguard Worker output = """\ 44*6777b538SAndroid Build Coastguard WorkerWarning: PublicStopClientEvent is hungry. 45*6777b538SAndroid Build Coastguard Worker""" 46*6777b538SAndroid Build Coastguard Worker expected = '' 47*6777b538SAndroid Build Coastguard Worker self.assertEqual(filter_func(output), expected) 48*6777b538SAndroid Build Coastguard Worker 49*6777b538SAndroid Build Coastguard Worker 50*6777b538SAndroid Build Coastguard Workerif __name__ == '__main__': 51*6777b538SAndroid Build Coastguard Worker unittest.main() 52