Skip to content
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

Flacoco crashes when a test method name contains spaces #247

Open
xmcp opened this issue Dec 30, 2023 · 3 comments
Open

Flacoco crashes when a test method name contains spaces #247

xmcp opened this issue Dec 30, 2023 · 3 comments

Comments

@xmcp
Copy link

xmcp commented Dec 30, 2023

Some JVM languages (e.g., Kotlin) allow method names to contain spaces. This convention is used in many projects, such as lettuce-core, which is a subject in the APR-Comp. It has a test method that looks like this:

@Test
fun `should scan iteratively`() = runBlocking<Unit> {
    ...
}

Flacoco will crash on such projects because it won't escape the spaces.

I forgot the exact error because I encountered this bug a few months ago and now I don't have a Kotlin environment at hand, but I still remember what's going on in the code:

  1. Flacoco calls the runOnlineCoveredTestResultPerTestMethods method in test-runner with a list of collected test method names (code).
  2. runOnlineCoveredTestResultPerTestMethods will then concatenate all test method names with a space (code),
  3. ... and then transform it into a command-line argument and call runGivenCommandLine (code).
  4. runGivenCommandLine will then spawn a new Java process with the given argument (code).

Therefore, if a test method name contains a space, it will be parsed as two arguments, crashing the command-line parser.

Maybe you can reproduce this issue and forward it to test-runner if necessary. Thanks again for your great project!

@monperrus
Copy link
Collaborator

thanks for the bug report @xmcp

@andre15silva WDYT?

@andre15silva
Copy link
Member

Hi @xmcp ,

Thanks a lot for the bug report :)

I will try to reproduce this ASAP and ping you when it is fixed!

@xmcp
Copy link
Author

xmcp commented Jan 15, 2024

Thanks for the response! The lettuce-core bug (id=6) in the APR-Comp Functional-Java benchmark should be able to reproduce this issue, as I have encountered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants