-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add directories-to-download flag for Android Args
Support downloading directories after test run from the result bucket
- Loading branch information
1 parent
2f85d08
commit 430c9e8
Showing
8 changed files
with
101 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
package ftl.util | ||
|
||
import com.google.common.annotations.VisibleForTesting | ||
import ftl.json.SavedMatrix | ||
|
||
object ArtifactRegex { | ||
|
||
@VisibleForTesting | ||
val testResultRgx = Regex(".*test_result_\\d+\\.xml$") | ||
@VisibleForTesting | ||
val screenshotRgx = Regex(".*\\.png$") | ||
|
||
/** | ||
* @return a list of regex's that should be downloaded | ||
*/ | ||
fun artifactsToDownload(matrix: SavedMatrix, directoriesToDownload: List<String>): List<Regex> { | ||
val directoriesRegexToDownload = directoriesToDownload | ||
.map { "^${Regex.escape(matrix.gcsPathWithoutRootBucket)}/.*/artifacts${Regex.escape(it)}/.*" } | ||
.map { Regex(it) } | ||
return listOf(testResultRgx, screenshotRgx) + directoriesRegexToDownload | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,50 @@ | ||
package ftl.util | ||
|
||
import com.google.common.truth.Truth.assertThat | ||
import ftl.json.SavedMatrix | ||
import org.junit.Test | ||
import org.mockito.Mockito.`when` | ||
import org.mockito.Mockito.mock | ||
|
||
class ArtifactRegexTest { | ||
|
||
private companion object { | ||
const val TO_DOWNLOAD_1 = "/sdcard/screenshots" | ||
const val TO_DOWNLOAD_2 = "/sdcard/test" | ||
|
||
val TO_DOWNLOAD_REGEX_1 = "^2018-12-21_11:24:44\\.608000_UpOC/shard_0/.*/artifacts/sdcard/screenshots.*" | ||
val TO_DOWNLOAD_REGEX_2 = "^2018-12-21_11:24:44\\.608000_UpOC/shard_0/.*/artifacts/sdcard/test.*" | ||
|
||
const val MATRIX_GCS_PATH_WITHOUT_ROOT_BUCKET = "2018-12-21_11:24:44.608000_UpOC/shard_0" | ||
} | ||
|
||
private val matrix = mock(SavedMatrix::class.java) | ||
|
||
@Test | ||
fun regexExists() { | ||
assertThat(ArtifactRegex.testResultRgx).isNotNull() | ||
assertThat(ArtifactRegex.screenshotRgx).isNotNull() | ||
} | ||
|
||
@Test | ||
fun `artifactsToDownload should return just testResult and screenshot regex if no directoriesToDownload`() { | ||
assertThat(ArtifactRegex.artifactsToDownload(matrix, emptyList()).map { it.pattern }) | ||
.containsExactly(ArtifactRegex.testResultRgx, ArtifactRegex.screenshotRgx) | ||
} | ||
|
||
@Test | ||
fun `artifactsToDownload should return testResult, screenshot regex and directoriesToDownload regex if one`() { | ||
`when`(matrix.gcsPathWithoutRootBucket).thenReturn(MATRIX_GCS_PATH_WITHOUT_ROOT_BUCKET) | ||
|
||
assertThat(ArtifactRegex.artifactsToDownload(matrix, listOf(TO_DOWNLOAD_1)).map { it.pattern }) | ||
.containsExactly(ArtifactRegex.testResultRgx.pattern, ArtifactRegex.screenshotRgx.pattern, TO_DOWNLOAD_REGEX_1) | ||
} | ||
|
||
@Test | ||
fun `artifactsToDownload should return testResult, screenshot regex and directoriesToDownload regex if multiple`() { | ||
`when`(matrix.gcsPathWithoutRootBucket).thenReturn(MATRIX_GCS_PATH_WITHOUT_ROOT_BUCKET) | ||
|
||
assertThat(ArtifactRegex.artifactsToDownload(matrix, listOf(TO_DOWNLOAD_1, TO_DOWNLOAD_2)).map { it.pattern }) | ||
.containsExactly(ArtifactRegex.testResultRgx.pattern, ArtifactRegex.screenshotRgx.pattern, TO_DOWNLOAD_REGEX_1, TO_DOWNLOAD_REGEX_2) | ||
} | ||
} |