xref: /aosp_15_r20/libcore/ojluni/src/test/Android.bp (revision 89a6322812dc8573315e60046e7959c50dad91d4)
1// Copyright (C) 2022 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package {
16    default_visibility: ["//visibility:private"],
17    default_applicable_licenses: ["libcore_ojluni_src_test_license"],
18}
19
20license {
21    name: "libcore_ojluni_src_test_license",
22    visibility: [":__subpackages__"],
23    license_kinds: [
24        "SPDX-license-identifier-Apache-2.0",
25        "SPDX-license-identifier-GPL-2.0",
26    ],
27    license_text: [
28        "LICENSE",
29    ],
30}
31
32// Builds the core-ojtests library that contains test code from OpenJDK.
33java_test {
34    name: "core-ojtests",
35    defaults: ["libcore_java_defaults"],
36    hostdex: true,
37
38    srcs: [
39        "java/**/*.java",
40        "javax/**/*.java",
41        "sun/**/*.java",
42    ],
43    java_resource_dirs: [
44        "resources",
45    ],
46
47    java_resources: [
48        ":core-ojtests-java-resources",
49        ":core-ojtests-javax-resources",
50    ],
51
52    sdk_version: "none",
53    system_modules: "core-all-system-modules",
54    libs: [
55        "okhttp",
56        "bouncycastle",
57    ],
58
59    static_libs: [
60        "core-test-rules",
61        "junit",
62        "core-compat-test-rules",
63        "mockwebserver",
64        "testng",
65    ],
66
67    // ojluni/src/test/java/util/stream/{bootlib,boottest}
68    // contains tests that are in packages from java.base;
69    // By default, OpenJDK 9's javac will only compile such
70    // code if it's declared to also be in java.base at
71    // compile time.
72    //
73    // For now, we use patch_module to put all sources
74    // and dependencies from this make target into java.base;
75    // other source directories in this make target are in
76    // packages not from java.base; if this becomes a problem
77    // in future, this could be addressed eg. by splitting
78    // boot{lib,test} out into a separate make target,
79    // deleting those tests or moving them to a different
80    // package.
81    patch_module: "java.base",
82
83    errorprone: {
84        javacflags: [
85            "-Xep:AlwaysThrows:OFF",
86            "-Xep:DoNotCall:OFF",
87            "-Xep:ArrayToString:WARN",
88            "-Xep:ReturnValueIgnored:WARN",
89            "-Xep:MathRoundIntLong:WARN",
90            "-Xep:FormatString:WARN",
91            "-Xep:IdentityBinaryExpression:WARN",
92            "-Xep:RandomModInteger:WARN",
93            "-Xep:SelfEquals:WARN",
94            "-Xep:DurationTemporalUnit:WARN",
95            "-Xep:DurationFrom:WARN",
96            "-Xep:InstantTemporalUnit:WARN",
97            "-Xep:SelfComparison:WARN",
98            "-Xep:PeriodFrom:WARN",
99            "-Xep:BoxedPrimitiveEquality:WARN",
100            "-Xep:IdentityHashMapBoxing:WARN",
101            "-Xep:DoubleBraceInitialization:WARN",
102            "-Xep:ComparableType:WARN",
103            "-Xep:ModifyingCollectionWithItself:WARN",
104            "-Xep:InvalidZoneId:WARN",
105            "-Xep:HashtableContains:WARN",
106            "-Xep:EqualsNull:WARN",
107        ],
108    },
109}
110
111// Builds the core-ojtests-public library. Excludes any private API tests.
112// Like core-ojtests but smaller.
113java_test {
114    name: "core-ojtests-public",
115    visibility: [
116        "//art/build/sdk",
117        "//cts/tests/libcore/ojluni",
118    ],
119    defaults: ["libcore_java_defaults"],
120    srcs: [
121        "java/**/*.java",
122        "javax/**/*.java",
123        "sun/**/*.java",
124    ],
125    // Filter out the following:
126    // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
127    //     and won't actually run, and
128    // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
129    //     excluding them means we don't need patch_module: "java.base"
130    exclude_srcs: [
131        "**/DeserializeMethodTest.java",
132        "**/SerializedLambdaTest.java",
133        "java/util/stream/boot*/**/*",
134    ],
135    java_resource_dirs: [
136        "resources",
137        // Include source code as part of JAR
138        "dist",
139    ],
140
141    java_resources: [
142        ":core-ojtests-java-resources",
143        ":core-ojtests-javax-resources",
144    ],
145
146    sdk_version: "none",
147    system_modules: "core-all-system-modules",
148    libs: [
149        "bouncycastle",
150        "core-test-rules",
151        "junit",
152        "okhttp",
153        "testng",
154    ],
155
156    static_libs: [
157        "core-compat-test-rules",
158        "mockwebserver",
159    ],
160
161    errorprone: {
162        javacflags: [
163            "-Xep:AlwaysThrows:OFF",
164            "-Xep:DoNotCall:OFF",
165            "-Xep:ArrayToString:WARN",
166            "-Xep:ReturnValueIgnored:WARN",
167            "-Xep:MathRoundIntLong:WARN",
168            "-Xep:FormatString:WARN",
169            "-Xep:IdentityBinaryExpression:WARN",
170            "-Xep:RandomModInteger:WARN",
171            "-Xep:SelfEquals:WARN",
172            "-Xep:DurationTemporalUnit:WARN",
173            "-Xep:DurationFrom:WARN",
174            "-Xep:InstantTemporalUnit:WARN",
175            "-Xep:SelfComparison:WARN",
176            "-Xep:PeriodFrom:WARN",
177            "-Xep:BoxedPrimitiveEquality:WARN",
178            "-Xep:IdentityHashMapBoxing:WARN",
179            "-Xep:DoubleBraceInitialization:WARN",
180            "-Xep:ComparableType:WARN",
181            "-Xep:ModifyingCollectionWithItself:WARN",
182            "-Xep:InvalidZoneId:WARN",
183            "-Xep:HashtableContains:WARN",
184            "-Xep:EqualsNull:WARN",
185        ],
186    },
187}
188