Invalid file names are generated because of test names
See original GitHub issueI’m having these tests in src/androidTest/kotlin
:
class ColorUtilsKtTest {
class ReplaceAlphaFrom(
val useCase: String,
@ColorInt val receiver: Int,
@ColorInt val param: Int,
@ColorInt val expected: Int,
)
@TestFactory fun replaceAlphaFrom() =
listOf(
ReplaceAlphaFrom(
"Replaces alpha keeping RGB",
Color.argb(0x12, 0x34, 0x56, 0x78),
Color.argb(0x87, 0x65, 0x43, 0x21),
Color.argb(0x87, 0x34, 0x56, 0x78),
),
ReplaceAlphaFrom(
"Adds only alpha",
Color.argb(0x00, 0x00, 0x00, 0x00),
Color.argb(0xAB, 0x00, 0x00, 0x00),
Color.argb(0xAB, 0x00, 0x00, 0x00),
),
ReplaceAlphaFrom(
"Clears alpha",
Color.argb(0x12, 0x34, 0x56, 0x78),
Color.argb(0x00, 0x00, 0x00, 0x00),
Color.argb(0x00, 0x34, 0x56, 0x78),
),
).map {
dynamicTest(it.useCase) {
val result = it.receiver.replaceAlphaFrom(it.param)
assertThat(it.expected, equalTo(result))
}
}
}
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:
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: https://github.com/android/android-test/issues/1314
Repro: https://github.com/TWiStErRob/repros/tree/master/agp/junit5-logcat-filenames
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
Btw, I tried to type a
:
and Windows told me this:Mind you, this means that
&
,;
,{
/}
,%
,=
,'
,!
,#
,@
,$
are all valid characters.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”.