• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Guava Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.common.base;
18 
19 import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
20 import static java.lang.annotation.ElementType.CONSTRUCTOR;
21 import static java.lang.annotation.ElementType.FIELD;
22 import static java.lang.annotation.ElementType.METHOD;
23 import static java.lang.annotation.ElementType.TYPE;
24 import static java.lang.annotation.RetentionPolicy.CLASS;
25 
26 import com.google.common.annotations.GwtCompatible;
27 import java.lang.annotation.Retention;
28 import java.lang.annotation.Target;
29 
30 /**
31  * Signifies that a test should not be run under Android. This annotation is respected only by our
32  * Google-internal Android suite generators. Note that those generators also suppress any test
33  * annotated with MediumTest or LargeTest.
34  *
35  *
36  * <p>Why use a custom annotation instead of {@code android.test.suitebuilder.annotation.Suppress}?
37  * I'm not completely sure that this is the right choice, but it has various advantages:
38  *
39  * <ul>
40  *   <li>An annotation named just "Suppress" might someday be treated by a non-Android tool as a
41  *       suppression. This would follow the precedent of many of our annotation processors, which
42  *       look for any annotation named, e.g., "GwtIncompatible," regardless of package.
43  *   <li>An annotation named just "Suppress" might suggest to users that the test is suppressed
44  *       under all environments. We could fight this by fully qualifying the annotation, but the
45  *       result will be verbose and attention-grabbing.
46  *   <li>We need to be careful about how we suppress {@code suite()} methods in {@code common.io}.
47  *       The generated suite for {@code FooTest} ends up containing {@code FooTest} itself plus some
48  *       other tests. We want to exclude the other tests (which Android can't handle) while
49  *       continuing to run {@code FooTest} itself. This is exactly what happens with {@code
50  *       AndroidIncompatible}. But I'm not sure what would happen if we annotated the {@code
51  *       suite()} method with {@code Suppress}. Would {@code FooTest} itself be suppressed, too?
52  *   <li>In at least one case, a use of {@code sun.misc.FpUtils}, the test will not even
53  *       <i>compile</i> against Android. Now, this might be an artifact of our build system, one
54  *       that we could probably work around. Or we could manually strip the test from open-source
55  *       Guava while continuing to run it internally, as we do with many other tests. This would
56  *       suffice because we our Android users and tests are using the open-source version, which
57  *       would no longer have the problematic test. But why bother when we can instead strip it with
58  *       a more precisely named annotation?
59  *   <li>While a dependency on Android ought to be easy if it's for annotations only, it will
60  *       probably require adding the dep to various ACLs, license files, and Proguard
61  *       configurations, and there's always the potential that something will go wrong. It
62  *       <i>probably</i> won't, since the deps are needed only in tests (and maybe someday in
63  *       testlib), but why bother?
64  *   <li>Stripping code entirely might help us keep under the method limit someday. Even if it never
65  *       comes to that, it may at least help with build and startup times.
66  * </ul>
67  */
68 @Retention(CLASS)
69 @Target({ANNOTATION_TYPE, CONSTRUCTOR, FIELD, METHOD, TYPE})
70 @GwtCompatible
71 @interface AndroidIncompatible {}
72