Skip to content

Commit 1b4a3ce

Browse files
committed
Test cleanup
1 parent a79a93f commit 1b4a3ce

File tree

5 files changed

+87
-324
lines changed

5 files changed

+87
-324
lines changed

test/rules/android_binary/r8_integration/BUILD

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ build_test(
3232
)
3333

3434
sh_library(
35-
name = "r8_desugaring_helper",
35+
name = "r8_integration_helper",
3636
testonly = True,
37-
srcs = ["r8_desugaring_helper.sh"],
37+
srcs = ["r8_integration_helper.sh"],
3838
data = [
3939
"//:MODULE.bazel",
4040
"//rules:bzl",
@@ -55,22 +55,7 @@ script_test(
5555
tags = ["manual"],
5656
timeout = "eternal",
5757
deps = [
58-
":r8_desugaring_helper",
59-
"//test/bashunit",
60-
"@rules_shell//shell/runfiles",
61-
],
62-
)
63-
64-
sh_library(
65-
name = "r8_java_resources_helper",
66-
testonly = True,
67-
srcs = ["r8_java_resources_helper.sh"],
68-
data = [
69-
"//:MODULE.bazel",
70-
"//rules:bzl",
71-
],
72-
visibility = ["//visibility:private"],
73-
deps = [
58+
":r8_integration_helper",
7459
"//test/bashunit",
7560
"@rules_shell//shell/runfiles",
7661
],
@@ -85,7 +70,7 @@ script_test(
8570
tags = ["manual"],
8671
timeout = "eternal",
8772
deps = [
88-
":r8_java_resources_helper",
73+
":r8_integration_helper",
8974
"//test/bashunit",
9075
"@rules_shell//shell/runfiles",
9176
],

test/rules/android_binary/r8_integration/r8_desugaring_helper.sh

Lines changed: 0 additions & 236 deletions
This file was deleted.

test/rules/android_binary/r8_integration/r8_desugaring_integration_test.sh

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@
1515
# limitations under the License.
1616

1717
# Integration tests for R8 desugaring with and without --desugar_java8_libs.
18-
#
19-
# These tests verify that:
20-
# 1. When --desugar_java8_libs is enabled, R8 rewrites java.* calls to j$.*
21-
# backports AND the j$.* implementation classes are included in the APK.
22-
# 2. When --nodesugar_java8_libs is set, no j$.* classes appear in the APK
23-
# and java.* calls remain as-is.
24-
# 3. DurationUser is retained in both cases (proguard keep rule).
2518

2619
# --- begin runfiles.bash initialization v2 ---
2720
# Copy-pasted from the Bazel Bash runfiles library v2.
@@ -34,50 +27,36 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
3427
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
3528
# --- end runfiles.bash initialization v2 ---
3629

37-
source "$(rlocation rules_android/test/bashunit/unittest.bash)" || \
38-
(echo >&2 "Failed to locate bashunit.sh" && exit 1)
39-
40-
source "$(rlocation rules_android/test/rules/android_binary/r8_integration/r8_desugaring_helper.sh)" || \
41-
(echo >&2 "Failed to locate r8_desugaring_helper.sh" && exit 1)
30+
source "$(rlocation rules_android/test/rules/android_binary/r8_integration/r8_integration_helper.sh)" || \
31+
(echo >&2 "Failed to locate r8_integration_helper.sh" && exit 1)
4232

4333
# Test: with --desugar_java8_libs enabled, R8 desugars java.time APIs and the
4434
# backport implementation classes (j$.*) are included in the APK.
4535
function test_desugaring_enabled() {
46-
build_desugaring_app --desugar_java8_libs
36+
build_app --desugar_java8_libs
4737

48-
# DurationUser must be retained by proguard keep rules.
49-
apk_dex_contains 'Lcom/desugaring/test/DurationUser;' || \
38+
apk_dex_contains 'Lcom/test/app/DurationUser;' || \
5039
fail "DurationUser class not found in DEX"
5140

52-
# Duration.toSeconds() (API 31) must be desugared: the raw java.time
53-
# invocation is rewritten to a j$.time backport, so the original
54-
# method reference should not appear in the constant pool.
5541
if apk_dex_contains 'java/time/Duration;.*toSeconds'; then
5642
fail "Expected Duration.toSeconds() to be desugared but raw java/time reference found"
5743
fi
5844

59-
# The j$.* backport implementation classes must be present. Without them
60-
# the app crashes at runtime with NoClassDefFoundError (e.g. j$/net/URLEncoder).
6145
apk_dex_contains 'Lj\$/' || \
6246
fail "Expected j\$.* desugared library classes in the APK"
6347
}
6448

6549
# Test: with --nodesugar_java8_libs, R8 does not rewrite java.* references
6650
# and no desugared library DEX is appended.
6751
function test_desugaring_disabled() {
68-
build_desugaring_app --nodesugar_java8_libs
52+
build_app --nodesugar_java8_libs
6953

70-
# DurationUser must still be retained regardless of the desugaring flag.
71-
apk_dex_contains 'Lcom/desugaring/test/DurationUser;' || \
54+
apk_dex_contains 'Lcom/test/app/DurationUser;' || \
7255
fail "DurationUser class not found in DEX"
7356

74-
# Without desugaring, java.time.Duration.toSeconds() remains as a direct
75-
# call in the DEX. (It will crash on API < 31 devices, but the reference
76-
# should be present.)
7757
apk_dex_contains 'java/time/Duration' || \
7858
fail "Expected raw java/time/Duration reference when desugaring is disabled"
7959

80-
# No j$.* classes should be present.
8160
if apk_dex_contains 'Lj\$/'; then
8261
fail "Unexpected j\$.* desugared library classes when desugaring is disabled"
8362
fi

0 commit comments

Comments
 (0)