-
Notifications
You must be signed in to change notification settings - Fork 119
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
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
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.
JUnit coverage for edge cases in ArgsHelperFilePath
(/**/
, /*/
, /tmp
, etc.) will help improve confidence that the code is working as intended.
@@ -45,6 +48,24 @@ object ArgsHelper { | |||
} | |||
} | |||
|
|||
fun evaluateFilePath(filePath: String): String { | |||
var file = filePath.trim().replaceFirst("~", System.getProperty("user.home")) |
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.
~ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we raise an error/warning here? Silently ignoring un-found env variables seems like a bug.
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.
this is standard behavior in Bash, that's how environment variables work sadly.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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