Skip to content

Commit

Permalink
Mark test-suite-builder suites and related code as `@AndroidIncompati…
Browse files Browse the repository at this point in the history
…ble`.

(I did also sneak in one change to the backport copy of `IteratorsTest`. It resolve a diff that we accidentally introduced in cl/613629330.)

Such code is already not run when we run our tests under Android emulators. (The Android JUnit 3 runner just ignores `suite()` methods, I want to say?) However, it's still _built_ for them. Besides being a waste, this requires pulling in the whole suite-builder ecosystem, which is again causing problems when I try to bump various things related to Android versions. By adding `@AndroidIncompatible`, I configure our Android test build to strip the code altogether.

RELNOTES=n/a
PiperOrigin-RevId: 719363315
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Jan 24, 2025
1 parent fd9d7ae commit 72ae179
Show file tree
Hide file tree
Showing 170 changed files with 679 additions and 283 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2015 The Guava Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.common.collect.testing;

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.CLASS;

import com.google.common.annotations.GwtCompatible;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
* Signifies that a test should not be run under Android. This annotation is respected only by our
* Google-internal Android suite generators. Note that those generators also suppress any test
* annotated with MediumTest or LargeTest.
*
* <p>For more discussion, see {@linkplain com.google.common.base.AndroidIncompatible the
* documentation on another copy of this annotation}.
*/
@Retention(CLASS)
@Target({ANNOTATION_TYPE, CONSTRUCTOR, FIELD, METHOD, TYPE})
@GwtCompatible
@interface AndroidIncompatible {}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
/**
* @author Max Ross
*/
@AndroidIncompatible // test-suite builders
public class FeatureSpecificTestSuiteBuilderTest extends TestCase {
private static final class MyTestSuiteBuilder
extends FeatureSpecificTestSuiteBuilder<MyTestSuiteBuilder, String> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
*
* @author George van den Driessche
*/
@AndroidIncompatible // test-suite builders
public final class MapTestSuiteBuilderTests extends TestCase {
private MapTestSuiteBuilderTests() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*
* @author Kevin Bourrillion
*/
@AndroidIncompatible // test-suite builders
public class MinimalCollectionTest extends TestCase {
public static Test suite() {
return CollectionTestSuiteBuilder.using(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*
* @author Regina O'Dell
*/
@AndroidIncompatible // test-suite builders
public class MinimalSetTest extends TestCase {
public static Test suite() {
return SetTestSuiteBuilder.using(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
*
* @author Kevin Bourrillion
*/
@AndroidIncompatible // test-suite builders
public class OpenJdk6ListTests extends TestsForListsInJavaUtil {
public static Test suite() {
return new OpenJdk6ListTests().allTests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
* @author Kevin Bourrillion
*/
// TODO(cpovirk): consider renaming this class in light of our now running it under newer JDKs.
@AndroidIncompatible // test-suite builders
public class OpenJdk6MapTests extends TestsForMapsInJavaUtil {
public static Test suite() {
return new OpenJdk6MapTests().allTests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
*
* @author Kevin Bourrillion
*/
@AndroidIncompatible // test-suite builders
public class OpenJdk6QueueTests extends TestsForQueuesInJavaUtil {
public static Test suite() {
return new OpenJdk6QueueTests().allTests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
*
* @author Kevin Bourrillion
*/
@AndroidIncompatible // test-suite builders
public class OpenJdk6SetTests extends TestsForSetsInJavaUtil {
public static Test suite() {
return new OpenJdk6SetTests().allTests();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*
* @author Kevin Bourrillion
*/
@AndroidIncompatible // test-suite builders
public class OpenJdk6Tests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
* @author Louis Wasserman
*/
public class SafeTreeMapTest extends TestCase {
@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(SafeTreeMapTest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import junit.framework.TestSuite;

public class SafeTreeSetTest extends TestCase {
@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(SafeTreeSetTest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
@NullUnmarked
public class LocalCacheTest extends TestCase {
@AndroidIncompatible
private static class TestStringCacheGenerator extends TestStringMapGenerator {
private final CacheBuilder<? super String, ? super String> builder;

Expand All @@ -112,6 +113,7 @@ protected Map<String, String> create(Entry<String, String>[] entries) {
}
}

@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(LocalCacheTest.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class ArrayListMultimapTest extends TestCase {

@GwtIncompatible // suite
@J2ktIncompatible
@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
public class Collections2Test extends TestCase {
@J2ktIncompatible
@GwtIncompatible // suite
@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite(Collections2Test.class.getSimpleName());
suite.addTest(testsForFilter());
Expand All @@ -73,6 +74,7 @@ public static Test suite() {

@J2ktIncompatible
@GwtIncompatible // suite
@AndroidIncompatible // test-suite builders
private static Test testsForFilter() {
return CollectionTestSuiteBuilder.using(
new TestStringCollectionGenerator() {
Expand All @@ -97,6 +99,7 @@ public Collection<String> create(String[] elements) {

@J2ktIncompatible
@GwtIncompatible // suite
@AndroidIncompatible // test-suite builders
private static Test testsForFilterAll() {
return CollectionTestSuiteBuilder.using(
new TestStringCollectionGenerator() {
Expand All @@ -119,6 +122,7 @@ public Collection<String> create(String[] elements) {

@J2ktIncompatible
@GwtIncompatible // suite
@AndroidIncompatible // test-suite builders
private static Test testsForFilterLinkedList() {
return CollectionTestSuiteBuilder.using(
new TestStringCollectionGenerator() {
Expand All @@ -143,6 +147,7 @@ public Collection<String> create(String[] elements) {

@J2ktIncompatible
@GwtIncompatible // suite
@AndroidIncompatible // test-suite builders
private static Test testsForFilterNoNulls() {
return CollectionTestSuiteBuilder.using(
new TestStringCollectionGenerator() {
Expand All @@ -167,6 +172,7 @@ public Collection<String> create(String[] elements) {

@J2ktIncompatible
@GwtIncompatible // suite
@AndroidIncompatible // test-suite builders
private static Test testsForFilterFiltered() {
return CollectionTestSuiteBuilder.using(
new TestStringCollectionGenerator() {
Expand All @@ -192,6 +198,7 @@ public Collection<String> create(String[] elements) {

@J2ktIncompatible
@GwtIncompatible // suite
@AndroidIncompatible // test-suite builders
private static Test testsForTransform() {
return CollectionTestSuiteBuilder.using(
new TestStringCollectionGenerator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
*/
@NullUnmarked
public class CompactHashMapTest extends TestCase {
@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
@GwtIncompatible // java.util.Arrays#copyOf(Object[], int), java.lang.reflect.Array
@NullUnmarked
public class CompactHashSetTest extends TestCase {
@AndroidIncompatible // test-suite builders
public static Test suite() {
List<Feature<?>> allFeatures =
Arrays.<Feature<?>>asList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
*/
@NullUnmarked
public class CompactLinkedHashMapTest extends TestCase {
@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
@GwtIncompatible // java.util.Arrays#copyOf(Object[], int), java.lang.reflect.Array
@NullUnmarked
public class CompactLinkedHashSetTest extends TestCase {
@AndroidIncompatible // test-suite builders
public static Test suite() {
List<Feature<?>> allFeatures =
Arrays.<Feature<?>>asList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
@NullUnmarked
public class ConcurrentHashMultisetTest extends TestCase {

@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Expand All @@ -76,6 +77,7 @@ public static Test suite() {
return suite;
}

@AndroidIncompatible // test-suite builders
private static TestStringMultisetGenerator concurrentHashMultisetGenerator() {
return new TestStringMultisetGenerator() {
@Override
Expand All @@ -85,6 +87,7 @@ protected Multiset<String> create(String[] elements) {
};
}

@AndroidIncompatible // test-suite builders
private static TestStringMultisetGenerator concurrentSkipListMultisetGenerator() {
return new TestStringMultisetGenerator() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ public void testAsList() {

@J2ktIncompatible
@GwtIncompatible // suite
@AndroidIncompatible // test-suite builders
public static class BuiltTests extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private enum Country {
UK
}

@AndroidIncompatible // test-suite builders
public static final class EnumBiMapGenerator implements TestBiMapGenerator<Country, Currency> {
@SuppressWarnings("unchecked")
@Override
Expand Down Expand Up @@ -116,6 +117,7 @@ public Currency[] createValueArray(int length) {

@J2ktIncompatible
@GwtIncompatible // suite
@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ private enum Country {
UK
}

@AndroidIncompatible // test-suite builders
public static final class EnumHashBiMapGenerator implements TestBiMapGenerator<Country, String> {
@SuppressWarnings("unchecked")
@Override
Expand Down Expand Up @@ -111,6 +112,7 @@ public String[] createValueArray(int length) {

@J2ktIncompatible
@GwtIncompatible // suite
@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class EnumMultisetTest extends TestCase {

@J2ktIncompatible
@GwtIncompatible // suite
@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
Expand All @@ -69,6 +70,7 @@ public static Test suite() {
return suite;
}

@AndroidIncompatible // test-suite builders
private static TestEnumMultisetGenerator enumMultisetGenerator() {
return new TestEnumMultisetGenerator() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public String toString() {
}
}

@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ public List<T> subList(int fromIndex, int toIndex) {
}
}

@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public boolean isEmpty() {
}
}

@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public int size() {
}
}

@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ protected NavigableMap<K, V> delegate() {
}
}

@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public SortedSet<T> tailSet(T fromElement) {
}
}

@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public boolean offer(T o) {
}
}

@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public String toString() {
}
}

@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public SortedMap<K, V> subMap(K fromKey, K toKey) {
}
}

@AndroidIncompatible // test-suite builders
public static Test suite() {
TestSuite suite = new TestSuite();

Expand Down
Loading

0 comments on commit 72ae179

Please sign in to comment.