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