-
Notifications
You must be signed in to change notification settings - Fork 53
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
Invalid file names are generated because of test names #263
Comments
Thanks for bringing this up and the thorough description! 🙏 Ideally we'd like to retain the colon characters for test reporting, but sanitize the handoff to this Logcat task for generation of its file names. Gotta dive into how this new implementation of |
I have entered the rabbit hole that is the Unified Test Platform for Android (UTP) and wanted to share some initial findings. UTP was apparently introduced with AGP 7.0 and takes care of the test reporting for instrumentation tests through a variety of plugins (here's a list of all the Maven artifacts for these plugins). I found private fun parseLine(line: String) {
val testPackageClassAndMethodNames = line.split("TestRunner: started: ")[1].split("(")
val testMethod = testPackageClassAndMethodNames[0].trim()
val testPackageAndClass = testPackageClassAndMethodNames[1].removeSuffix(")")
val tempFileName = generateLogcatFileName(testPackageAndClass, testMethod) // <----- !!
tempLogcatFile = File(tempFileName)
logcatFilePaths.add(tempFileName)
tempLogcatWriter = tempLogcatFile.outputStream().bufferedWriter()
}
private fun generateLogcatFileName(
testPackageAndClass: String,
testMethod: String
) = File(outputDir, "logcat-$testPackageAndClass-$testMethod.txt").absolutePath // <----- !! I can't really change the output of Logcat, though - else the IDE reporting and other places would start to look messy again. I wonder if the fix could be applied from AGP's side, cleaning the generated file names of any illegal symbols. We managed to fix other upstream bugs in the past so maybe this could be another attempt at one. 🤔 |
Awesome investigation, brave soul embarking on a journey into the rabbit hole. 🙏 I opened a bug for AGP too, would you mind commenting on the issue with your findings? In the meantime please consider making a change to allow for at least making it work in some way. A configuration param that's off by default, or even just mutable private field that can be set with reflection 🥺. "Ugly working" is better than "pretty, but broken". |
Note: there's something weird in your screenshots, the open |
Thanks for confirming!
Yeah, I noticed that too. It's likely a side effect of this Logcat plugin splitting the test name by In any case, version |
This comment was marked as resolved.
This comment was marked as resolved.
Ah no, sorry - I was referring to the fix on android-junit5's side: dependencies {
androidTestImplementation("de.mannodermaus.junit5:android-test-core:1.3.1-SNAPSHOT")
androidTestRuntimeOnly("de.mannodermaus.junit5:android-test-runner:1.3.1-SNAPSHOT")
} Also, noted about the edge case with the parentheses. Square brackets could work as an alternative for our own test naming, I suppose, though I'm hoping for an AGP-side resolution first before considering that one, to be honest. |
Released in |
I'm having these tests in
src/androidTest/kotlin
:When running them in Android Studio I get
which is beautiful, well done!
I have the same structure in
src/test/kotlin
too, that looks like this:At this point I can see that there's a limitation of nesting test containers in androidTest and you worked around it by concat-ing. I've identified this line to be responsible:
android-junit5/instrumentation/runner/src/main/kotlin/de/mannodermaus/junit5/internal/runners/AndroidJUnitPlatformTestTree.kt
Line 53 in 9136759
Now, onto the issue...
When running on AGP 7.1 (
gradlew :feature:base:connectedCheck
) there are some new features to dump the logcat and other files, see what is the output here:This is on Windows, where there are reserved characters in file names (see also wiki. You can see this in action, because
build/outputs/androidTest-results/connected/API_29(AVD) - 10/logcat-net.twisterrob.colorfilters.android.ColorUtilsKtTest-replaceAlphaFrom
file name is truncated at the:
, and actually there's only 1 file, not 3. (AGP issue)When running the same on Mac (CI) I get the full name:
build/outputs/androidTest-results/connected/test(AVD) - 10/logcat-net.twisterrob.colorfilters.android.ColorUtilsKtTest-replaceAlphaFrom: Adds only alpha.txt
, but when trying to upload artifacts I get an error because of the "invalid" character: https://github.com/TWiStErRob/net.twisterrob.colorfilters/runs/5487958432?check_suite_focus=true#step:7:17(AGP issue)
At this point I would like to ask to make it configurable what the joiner characters are, e.g. I would configure it to
-
to prevent this error. Related android-test issue: android/android-test#1314Repro: https://github.com/TWiStErRob/repros/tree/master/agp/junit5-logcat-filenames
The text was updated successfully, but these errors were encountered: