-
Notifications
You must be signed in to change notification settings - Fork 117
#870 Added --directories-to-pull validation and avoid making request with empty toolStepResult #876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
piotradamczyk5
merged 5 commits into
master
from
#870-added-directories-to-pull-validation
Jul 6, 2020
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e86746c
#870 Added --directories-to-pull validation and avoid making request …
e02e7a3
Update release_notes.md
piotradamczyk5 8af6e52
#870 Detekt and tests fixes
ab808f6
Fix problem with paths contains / on last char, update tests
adamfilipow92 af17830
#870 added info for table about invalid matrix; remove duplicate tables
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -169,8 +169,7 @@ fun withGlobalExceptionHandling(block: () -> Int) { | |
| } | ||
|
|
||
| private fun SavedMatrix.logError() { | ||
| println("More details are available at [${this.webLink}]") | ||
| println(this.asPrintableTable()) | ||
| println("Matrix is $state") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There will be no table output if flank throw
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| fun <R : MutableMap<String, Any>, T> mutableMapProperty( | ||
|
|
||
This file contains hidden or 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 hidden or 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
99 changes: 99 additions & 0 deletions
99
test_runner/src/test/kotlin/ftl/args/ValidateDirectoriesToPullAndroidArgsTest.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| package ftl.args | ||
|
|
||
| import ftl.test.util.TestHelper | ||
| import org.junit.Assert.assertEquals | ||
| import org.junit.Test | ||
| import java.io.StringReader | ||
|
|
||
| class ValidateDirectoriesToPullAndroidArgsTest { | ||
|
|
||
| @Test | ||
| fun `should not throw any error with valid directoriesToPull`() { | ||
| // given | ||
| val testYaml = """ | ||
| gcloud: | ||
| app: ./src/test/kotlin/ftl/fixtures/tmp/apk/app-debug.apk | ||
| test: ./src/test/kotlin/ftl/fixtures/tmp/apk/app-single-success-debug-androidTest.apk | ||
| directories-to-pull: | ||
| - /sdcard/data/sample | ||
| - /data/local/tmp/sample | ||
| - /sdcard/ | ||
| flank: | ||
| disable-sharding: true | ||
| """.trimIndent() | ||
|
|
||
| // when | ||
| AndroidArgs.load(StringReader(testYaml)).validate() | ||
|
|
||
| // then | ||
| // no issues | ||
| } | ||
|
|
||
| @Test | ||
| fun `should not throw any error without directoriesToPull specific`() { | ||
| // given | ||
| val testYaml = """ | ||
| gcloud: | ||
| app: ./src/test/kotlin/ftl/fixtures/tmp/apk/app-debug.apk | ||
| test: ./src/test/kotlin/ftl/fixtures/tmp/apk/app-single-success-debug-androidTest.apk | ||
| flank: | ||
| disable-sharding: true | ||
| """.trimIndent() | ||
|
|
||
| // when | ||
| AndroidArgs.load(StringReader(testYaml)).validate() | ||
|
|
||
| // then | ||
| // no issues | ||
| } | ||
|
|
||
| @Test | ||
| fun `should throw error with bad prefixed paths in directoriesToPull`() { | ||
| // given | ||
| val expectedErrorMessage = getExpectedMessageForPaths(listOf("/sdcard/data/sample!", "/data/local/tmp/sample#")) | ||
| val testYaml = """ | ||
| gcloud: | ||
| app: ./src/test/kotlin/ftl/fixtures/tmp/apk/app-debug.apk | ||
| test: ./src/test/kotlin/ftl/fixtures/tmp/apk/app-single-success-debug-androidTest.apk | ||
| directories-to-pull: | ||
| - /sdcard/data/sample! | ||
| - /data/local/tmp/sample# | ||
| flank: | ||
| disable-sharding: true | ||
| """.trimIndent() | ||
|
|
||
| // when | ||
| val exception = TestHelper.getThrowable { AndroidArgs.load(StringReader(testYaml)).validate() } | ||
|
|
||
| // then | ||
| assertEquals(expectedErrorMessage, exception.message) | ||
| } | ||
|
|
||
| @Test | ||
| fun `should throw error with bad characters in paths in directoriesToPull`() { | ||
| // given | ||
| val expectedErrorMessage = getExpectedMessageForPaths(listOf("/app/", "/data/sample")) | ||
| val testYaml = """ | ||
| gcloud: | ||
| app: ./src/test/kotlin/ftl/fixtures/tmp/apk/app-debug.apk | ||
| test: ./src/test/kotlin/ftl/fixtures/tmp/apk/app-single-success-debug-androidTest.apk | ||
| directories-to-pull: | ||
| - /app/ | ||
| - /data/sample | ||
| - /sdcard/test | ||
| flank: | ||
| disable-sharding: true | ||
| """.trimIndent() | ||
|
|
||
| // when | ||
| val exception = TestHelper.getThrowable { AndroidArgs.load(StringReader(testYaml)).validate() } | ||
|
|
||
| // then | ||
| assertEquals(expectedErrorMessage, exception.message) | ||
| } | ||
|
|
||
| private fun getExpectedMessageForPaths(badPaths: List<String>) = | ||
| "Invalid value for [directories-to-pull]: Invalid path $badPaths.\n" + | ||
| "Path must be absolute paths under /sdcard or /data/local/tmp (for example, --directories-to-pull /sdcard/tempDir1,/data/local/tmp/tempDir2).\n" + | ||
| "Path names are restricted to the characters [a-zA-Z0-9_-./+]. " | ||
| } |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullfortoolResultsStep?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AD 1. If matrix is invalid FTL returns
nullastoolResultsStepAD 2. This is more to avoid crashing flank in the future, so far, for now, I do not know how to reproduce this issue
AD 3. This is safe because tests results are based on a request made with
toolResultsStepwhich will not succeed withouttoolResultsStepAD 4. Ideally, we should not trigger INVALID matrix request, but for now, we do not know which settings will cause matrix invalid (see point 2)