Allow blob, tilde and env vars in app paths#386
Conversation
Codecov Report
@@ Coverage Diff @@
## master #386 +/- ##
============================================
+ Coverage 79.9% 79.98% +0.07%
- Complexity 483 490 +7
============================================
Files 66 67 +1
Lines 1553 1594 +41
Branches 234 241 +7
============================================
+ Hits 1241 1275 +34
- Misses 173 177 +4
- Partials 139 142 +3 |
Fixed failing tests Added unit tests
Add ArgsFileVisitor Fix paths
f189eb1 to
0ff99a3
Compare
| } | ||
|
|
||
| fun evaluateFilePath(filePath: String): String { | ||
| var file = filePath.trim().replaceFirst("~", System.getProperty("user.home")) |
There was a problem hiding this comment.
~ should be replaced only if it's the first character in the string
https://stackoverflow.com/a/7163455
the regex should be ^~, we should add a JUnit test for this (for both the happy path and failure case).
~/tmp should be replaced
/tmp/~ should not be replaced
| fun walk(searchPath: Path): List<Path> { | ||
| val searchString = searchPath.toString() | ||
| // /Users/tmp/code/flank/test_app/** => /Users/tmp/code/flank/test_app/ | ||
| val beforeGlob = Paths.get(searchString.substringBefore(RECURSE)) |
There was a problem hiding this comment.
we probably need more testing around paths with /**/ and /*/
i'm not sure splitting by /**/ works for all cases
|
|
||
| // https://stackoverflow.com/a/2821201/2450315 | ||
| private val envRegex = Pattern.compile("\\$([a-zA-Z_]+[a-zA-Z0-9_]*)") | ||
| private fun substituteEnvVars(text: String): String { |
There was a problem hiding this comment.
we should check this works for duplicate environment variables via more JUnit tests. There are probably other edge cases as well. For example the ${HOME} syntax which we should probably document as unsupported.
$HOME/$HOME/tmp
There was a problem hiding this comment.
We should probably WARN but not fail for duplicate env variables. The warning is to notify the user that he's duplicated an env variable. Not failing, in case its intentional.
Regardless, I don't think we should handle custom env vars. That would likely be a pain to maintain.
There was a problem hiding this comment.
bash doesn't warn on duplicates. I'm using bash as the model for the parsing logic.
| val matcher = envRegex.matcher(text) | ||
| while (matcher.find()) { | ||
| val envName = matcher.group(1) | ||
| val envValue = System.getenv(envName) ?: "" |
There was a problem hiding this comment.
Should we raise an error/warning here? Silently ignoring un-found env variables seems like a bug.
There was a problem hiding this comment.
this is standard behavior in Bash, that's how environment variables work sadly.
There was a problem hiding this comment.
discussed on slack, printing a warning makes sense.
| file = Paths.get(file).toAbsolutePath().normalize().toString() | ||
|
|
||
| // Avoid walking the folder's parent dir if we know it exists already. | ||
| if (File(file).exists()) return file |
There was a problem hiding this comment.
I would prefer if we also printed this value to console. Something like - Resolved app file path - "$file".
Under a conditional. if (filePath != file).
There was a problem hiding this comment.
I think it should be printed already when the args are printed to stdout at the start of a test run.
# Conflicts: # test_runner/src/main/kotlin/ftl/args/ArgsHelper.kt # test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt # test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt
| } | ||
|
|
||
| @Test | ||
| fun tmpTest() { |
There was a problem hiding this comment.
This should be deleted.
de09c9b to
7a4b6ec
Compare
ca4626c to
6a96663
Compare
6a96663 to
dbabf4d
Compare
dbabf4d to
2eefeee
Compare
app, test and xctestrun-file values in Flank config should support below formats along with current formats.
~)*and**Fix #336