diff options
author | Eric Holk <eholk@google.com> | 2019-03-07 12:22:02 -0800 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-03-07 12:22:02 -0800 |
commit | 6e613c85d4a012ef86abcc0843a45e118d24047c (patch) | |
tree | 455cd141f629467bad9ced23b90a71383db15e36 | |
parent | 06ef1c2c23782d9dbd696e729cef8e48009a55aa (diff) | |
parent | df98d2521558ec25eba6b6fab3a46348101d0af3 (diff) | |
download | trebuchet-6e613c85d4a012ef86abcc0843a45e118d24047c.tar.gz |
Fix presubmit tests am: acfb58a5f7
am: df98d25215
Change-Id: I014af722c90154301c6fde42f9b54acd5eb80005
-rw-r--r-- | Android.bp | 1 | ||||
-rw-r--r-- | TEST_MAPPING | 8 | ||||
-rw-r--r-- | core/common/src/test/kotlin/trebuchet/extractors/ZlibExtractorTest.kt | 9 | ||||
-rw-r--r-- | core/common/src/test/kotlin/trebuchet/io/StringStreamTest.kt | 4 | ||||
-rw-r--r-- | core/common/src/test/kotlin/trebuchet/task/ImportTaskTest.kt | 10 | ||||
-rw-r--r-- | core/common/src/test/kotlin/trebuchet/testutils/Annotations.kt | 23 |
6 files changed, 46 insertions, 9 deletions
@@ -58,6 +58,7 @@ java_test_host { "junit", "kotlin-reflect", ], + test_suites: ["general-tests"], } java_binary_host { diff --git a/TEST_MAPPING b/TEST_MAPPING index 4d79668..97a5fde 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,7 +1,13 @@ { "presubmit": [ { - "name": "trebuchet-core-tests" + "name": "trebuchet-core-tests", + "host": true, + "options": [ + { + "exclude-annotation": "trebuchet.testutils.NeedsSampleData" + } + ] } ] } diff --git a/core/common/src/test/kotlin/trebuchet/extractors/ZlibExtractorTest.kt b/core/common/src/test/kotlin/trebuchet/extractors/ZlibExtractorTest.kt index d773f77..0f92089 100644 --- a/core/common/src/test/kotlin/trebuchet/extractors/ZlibExtractorTest.kt +++ b/core/common/src/test/kotlin/trebuchet/extractors/ZlibExtractorTest.kt @@ -22,6 +22,7 @@ import trebuchet.extras.findSampleData import trebuchet.importers.FatalImportFeedback import trebuchet.io.BufferProducer import trebuchet.io.StreamingReader +import trebuchet.testutils.NeedsSampleData import java.io.File import kotlin.test.assertEquals import kotlin.test.assertNotNull @@ -29,28 +30,28 @@ import kotlin.test.assertNull import kotlin.test.assertTrue class ZlibExtractorTest { - @Test + @Test @NeedsSampleData fun testFactorySuccess() { val reader = StreamingReader(openSample()) reader.loadIndex(reader.keepLoadedSize.toLong()) assertNotNull(ZlibExtractor.Factory.extractorFor(reader, FatalImportFeedback)) } - @Test + @Test @NeedsSampleData fun testFactoryNotDeflated() { val reader = StreamingReader(openSample("sample.ftrace")) reader.loadIndex(reader.keepLoadedSize.toLong()) assertNull(ZlibExtractor.Factory.extractorFor(reader, FatalImportFeedback)) } - @Test + @Test @NeedsSampleData fun testFactoryNoHeader() { val reader = StreamingReader(openSample("caltrace1.html")) reader.loadIndex(reader.keepLoadedSize.toLong()) assertNull(ZlibExtractor.Factory.extractorFor(reader, FatalImportFeedback)) } - @Test + @Test @NeedsSampleData fun testExtractInitial() { val expected = "# tracer: nop\n#\n# ent" val extractor = ZlibExtractor(FatalImportFeedback) diff --git a/core/common/src/test/kotlin/trebuchet/io/StringStreamTest.kt b/core/common/src/test/kotlin/trebuchet/io/StringStreamTest.kt index 9b17206..ee149c9 100644 --- a/core/common/src/test/kotlin/trebuchet/io/StringStreamTest.kt +++ b/core/common/src/test/kotlin/trebuchet/io/StringStreamTest.kt @@ -24,6 +24,7 @@ import trebuchet.importers.DummyImportFeedback import trebuchet.model.Model import trebuchet.task.ImportTask import trebuchet.testutils.makeReader +import trebuchet.testutils.NeedsSampleData import java.io.BufferedReader import java.io.File import java.io.FileReader @@ -38,7 +39,8 @@ class StringStreamTest { expect1_20_300("1\r\n20\r\n300") } - @Test fun testLineReaderOnFile() { + @Test @NeedsSampleData + fun testLineReaderOnFile() { val file = File("${findSampleData()}/sample.ftrace") Assert.assertTrue(file.exists()) val expected = BufferedReader(FileReader(file)) diff --git a/core/common/src/test/kotlin/trebuchet/task/ImportTaskTest.kt b/core/common/src/test/kotlin/trebuchet/task/ImportTaskTest.kt index 0bd1946..dc75571 100644 --- a/core/common/src/test/kotlin/trebuchet/task/ImportTaskTest.kt +++ b/core/common/src/test/kotlin/trebuchet/task/ImportTaskTest.kt @@ -26,10 +26,12 @@ import trebuchet.io.asSlice import trebuchet.model.Model import trebuchet.model.fragments.AsyncSlice import trebuchet.queries.SliceQueries +import trebuchet.testutils.NeedsSampleData import java.io.File class ImportTaskTest { - @Test fun testImportCameraTrace() { + @Test @NeedsSampleData + fun testImportCameraTrace() { val model = import("hdr-0608-4-trace.html") val slices = SliceQueries.selectAll(model) { it.name.startsWith("MergeShot")} assertEquals(2, slices.size) @@ -37,7 +39,8 @@ class ImportTaskTest { assertEquals(0.866, slices[1].duration, .001) } - @Test fun testImportCalTrace1() { + @Test @NeedsSampleData + fun testImportCalTrace1() { val model = import("caltrace1.html") val counterName = "com.google.android.apps.nexuslauncher/com.google.android.apps.nexuslauncher.NexusLauncherActivity#1" val process = model.processes.values.find { it.name == "surfaceflinger" }!! @@ -54,7 +57,8 @@ class ImportTaskTest { assertFalse(counter.events.any { it.count < 0 || it.count > 2}) } - @Test fun testImportSample() { + @Test @NeedsSampleData + fun testImportSample() { val model = import("sample.ftrace") val process = model.processes[6381]!! val thread = process.threads.find { it.name == "RenderThread" }!! diff --git a/core/common/src/test/kotlin/trebuchet/testutils/Annotations.kt b/core/common/src/test/kotlin/trebuchet/testutils/Annotations.kt new file mode 100644 index 0000000..b9aeb0d --- /dev/null +++ b/core/common/src/test/kotlin/trebuchet/testutils/Annotations.kt @@ -0,0 +1,23 @@ +/* + * Copyright 2019 Google Inc. + * + * 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 + * + * https://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 trebuchet.testutils + +/** + Indicates that a test needs access to sample data, which is not included in + the repository. This is used to skip these tests on presubmit checks. + */ +annotation class NeedsSampleData |