From 87df372535cb8bb71111ca9303208f97c5d9a3e8 Mon Sep 17 00:00:00 2001 From: Chalard Jean Date: Fri, 9 May 2025 13:19:11 +0900 Subject: [PATCH 1/2] Don't warn in tests for deprecation This change removes hundreds of lines of useless warnings, since tests must check the continued working of old and deprecated methods. Test: build manually and observe the warnings are gone Flag: EXEMPT test-only Change-Id: Ie50b2f35b09041e8e201b30b1e575e66e045bc44 --- tests/common/Android.bp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/common/Android.bp b/tests/common/Android.bp index 60a02fb7be..1600a6a0ec 100644 --- a/tests/common/Android.bp +++ b/tests/common/Android.bp @@ -155,6 +155,9 @@ java_defaults { // if sdk_version="" this gets automatically included, but here we need to add manually. "framework-res", ], + // Tests must check a large number of deprecated methods and warning about it + // sends hundreds of warning lines flooding the useful warnings. + kotlincflags: ["-Xsuppress-warning=DEPRECATION"], } // defaults for tests that need to build against framework-connectivity's @hide APIs, but also @@ -178,6 +181,9 @@ java_defaults { // if sdk_version="" this gets automatically included, but here we need to add manually. "framework-res", ], + // Tests must check a large number of deprecated methods and warning about it + // sends hundreds of warning lines flooding the useful warnings. + kotlincflags: ["-Xsuppress-warning=DEPRECATION"], defaults_visibility: ["//packages/modules/Connectivity/tests:__subpackages__"], } From ebaef1230baf06c84bcfc33faff7d2636727b110 Mon Sep 17 00:00:00 2001 From: Chalard Jean Date: Fri, 9 May 2025 13:20:31 +0900 Subject: [PATCH 2/2] Don't ignore exceptions in NsdManagerDownstreamTetheringTest tryTest{} catches and returns and must be ended with a cleanup{} block to throw. That is why it's marked with @CheckReturnValue. The IDE marks the entire block as a huge warning. Ideally this should really be an error, but that flag only exists in Kotlin 2.2 and above, which is not out of beta yet, so add a TODO in the bp file Test: NsdManagerDownstreamTetheringTest Flag: EXEMPT test-only Change-Id: I62a9d0a16926574eb286d45b61d4d5d2e8c870ab --- tests/common/Android.bp | 2 ++ .../src/android/net/cts/NsdManagerDownstreamTetheringTest.kt | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/common/Android.bp b/tests/common/Android.bp index 1600a6a0ec..4ecb23c043 100644 --- a/tests/common/Android.bp +++ b/tests/common/Android.bp @@ -158,6 +158,7 @@ java_defaults { // Tests must check a large number of deprecated methods and warning about it // sends hundreds of warning lines flooding the useful warnings. kotlincflags: ["-Xsuppress-warning=DEPRECATION"], + // TODO: add "-Xwarning-level=CheckResult:error" when Kotlin 2.2.0 is out } // defaults for tests that need to build against framework-connectivity's @hide APIs, but also @@ -184,6 +185,7 @@ java_defaults { // Tests must check a large number of deprecated methods and warning about it // sends hundreds of warning lines flooding the useful warnings. kotlincflags: ["-Xsuppress-warning=DEPRECATION"], + // TODO: add "-Xwarning-level=CheckResult:error" when Kotlin 2.2.0 is out defaults_visibility: ["//packages/modules/Connectivity/tests:__subpackages__"], } diff --git a/tests/cts/net/src/android/net/cts/NsdManagerDownstreamTetheringTest.kt b/tests/cts/net/src/android/net/cts/NsdManagerDownstreamTetheringTest.kt index 19a40f9502..97556f54a2 100644 --- a/tests/cts/net/src/android/net/cts/NsdManagerDownstreamTetheringTest.kt +++ b/tests/cts/net/src/android/net/cts/NsdManagerDownstreamTetheringTest.kt @@ -104,7 +104,7 @@ class NsdManagerDownstreamTetheringTest : EthernetTetheringTestBase() { nsdManager.discoverServices(serviceType, NsdManager.PROTOCOL_DNS_SD, discoveryRecord) discoveryRecord.expectCallback() assertNotNull(downstreamReader.pollForQuery("$serviceType.local", 12 /* type PTR */)) - } cleanupStep { + } cleanup { nsdManager.stopServiceDiscovery(discoveryRecord) discoveryRecord.expectCallback() } @@ -137,7 +137,7 @@ class NsdManagerDownstreamTetheringTest : EthernetTetheringTestBase() { val downstreamReader = downstreamIface.packetReader assertNotNull(downstreamReader.pollForQuery("$serviceType.local", 12 /* type PTR */)) // TODO: Add another test to check packet reply can trigger serviceFound. - } cleanupStep { + } cleanup { nsdManager.stopServiceDiscovery(discoveryRecord) discoveryRecord.expectCallback() }