Skip to content

Commit 9876b60

Browse files
committed
Suppresses tests around classes not in T
Test: presubmit Bug: 297732367 Change-Id: Ifcd79a35464a95187caad82636eb86a7d39df83d
1 parent 63a341a commit 9876b60

7 files changed

Lines changed: 22 additions & 3 deletions

File tree

‎appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/DocumentIdUtilCtsTest.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.junit.Test;
2525

26+
/*@exportToFramework:SdkSuppress(minSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)*/
2627
public class DocumentIdUtilCtsTest {
2728

2829
@Test

‎appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/JoinSpecCtsTest.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.junit.Test;
2525

26+
/*@exportToFramework:SdkSuppress(minSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)*/
2627
public class JoinSpecCtsTest {
2728

2829
@Test

‎appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/PropertyPathCtsTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package androidx.appsearch.cts.app;
1818

1919
import static androidx.appsearch.app.PropertyPath.PathSegment.NON_REPEATED_CARDINALITY;
20-
2120
import static com.google.common.truth.Truth.assertThat;
2221

2322
import androidx.appsearch.app.PropertyPath;
@@ -30,6 +29,7 @@
3029
import java.util.Iterator;
3130
import java.util.List;
3231

32+
/*@exportToFramework:SdkSuppress(minSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)*/
3333
public class PropertyPathCtsTest {
3434
@Test
3535
public void testPropertyPathInvalid() {

‎appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/SearchResultCtsTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package androidx.appsearch.cts.app;
1818

1919
import static com.google.common.truth.Truth.assertThat;
20-
2120
import static org.junit.Assert.assertThrows;
2221

2322
import androidx.appsearch.app.PropertyPath;
@@ -107,6 +106,7 @@ public void testSubmatchRangeNotSet() {
107106
}
108107

109108
@Test
109+
/*@exportToFramework:SdkSuppress(minSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)*/
110110
public void testJoinedDocument() {
111111
AppSearchEmail email = new AppSearchEmail.Builder("namespace1", "id1")
112112
.setBody("Hello World.")

‎appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/SearchSuggestionResultCtsTest.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import org.junit.Test;
2424

25+
/*@exportToFramework:SdkSuppress(minSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)*/
2526
public class SearchSuggestionResultCtsTest {
2627
@Test
2728
public void testBuildDefaultSearchSuggestionResult() {

‎appsearch/appsearch/src/androidTest/java/androidx/appsearch/cts/app/SearchSuggestionSpecCtsTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package androidx.appsearch.cts.app;
1818

1919
import static com.google.common.truth.Truth.assertThat;
20-
2120
import static org.junit.Assert.assertThrows;
2221

2322
import androidx.appsearch.app.SearchSuggestionSpec;
@@ -26,6 +25,7 @@
2625

2726
import org.junit.Test;
2827

28+
/*@exportToFramework:SdkSuppress(minSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)*/
2929
public class SearchSuggestionSpecCtsTest {
3030
@Test
3131
public void testBuildDefaultSearchSuggestionSpec() throws Exception {

‎appsearch/exportToFramework.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ def _TransformCommonCode(self, contents):
189189
return contents
190190

191191
def _TransformTestCode(self, contents):
192+
# Add imports used in tests
193+
imports_to_add = []
194+
if '@exportToFramework:SdkSuppress' in contents:
195+
imports_to_add.append('androidx.test.filters.SdkSuppress')
196+
imports_to_add.append('android.os.Build')
197+
192198
contents = (contents
193199
.replace('androidx.appsearch.testutil.', 'android.app.appsearch.testutil.')
194200
.replace(
@@ -199,8 +205,18 @@ def _TransformTestCode(self, contents):
199205
'android.app.appsearch.AppSearchManager')
200206
.replace('LocalStorage.', 'AppSearchManager.')
201207
)
208+
contents = re.sub(
209+
r'/\*@exportToFramework:SdkSuppress\(minSdkVersion = (.*?)\)\*/',
210+
r'@SdkSuppress(minSdkVersion = \1)',
211+
contents)
202212
for shim in ['AppSearchSession', 'GlobalSearchSession', 'SearchResults']:
203213
contents = re.sub(r"([^a-zA-Z])(%s)([^a-zA-Z0-9])" % shim, r'\1\2Shim\3', contents)
214+
215+
for import_to_add in imports_to_add:
216+
contents = re.sub(
217+
r'^(\s*package [^;]+;\s*)$', r'\1\nimport %s;\n' % import_to_add, contents,
218+
flags=re.MULTILINE)
219+
204220
return self._TransformCommonCode(contents)
205221

206222
def _TransformAndCopyFolder(self, source_dir, dest_dir, transform_func=None):

0 commit comments

Comments
 (0)