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

Test case name parsing fails if name contains special characters like . or , #320

Open
jk-1 opened this issue Feb 21, 2024 · 0 comments
Open

Comments

@jk-1
Copy link

jk-1 commented Feb 21, 2024

I have this simplified test object:

package TestExp

object BugTests extends TestSuite{
  val a = true
  val b = true
  val tests =  Tests {
    test("1 foo bar") { assert(a==b) }
    test("2 foo, bar") { assert(a==b) }
    test("3 foo.txt") { assert(a==b) }
  }
}

When I run all tests, they all run OK:

mill show testexplib.test.testOnly -- TestExp.BugTests
[1/1] show > [85/85] testexplib.test.testOnly 
********************     Setting up BugTestFramework     ********************
------------------------ Running Tests TestExp.BugTests ------------------------
+ TestExp.BugTests.1 foo bar 6ms  
+ TestExp.BugTests.2 foo, bar 0ms  
+ TestExp.BugTests.3 foo.txt 0ms  
********************     Tearing down BugTestFramework     ********************
[
  "----------------------------------- Results -----------------------------------\n- TestExp.BugTests  \n\nTests: 3, Passed: 3, Failed: 0",
  [
    {
      "fullyQualifiedName": "TestExp.BugTests",
      "selector": "TestExp.BugTests.1 foo bar",
      "duration": 6,
      "status": "Success"
    },
    {
      "fullyQualifiedName": "TestExp.BugTests",
      "selector": "TestExp.BugTests.2 foo, bar",
      "duration": 0,
      "status": "Success"
    },
    {
      "fullyQualifiedName": "TestExp.BugTests",
      "selector": "TestExp.BugTests.3 foo.txt",
      "duration": 0,
      "status": "Success"
    }
  ]
]

But when I try to run single test cases with '.' or ',' -chars in their name, I get utest.NoSuchTestException -error.

This one runs OK:

mill show testexplib.test.testOnly -- TestExp.BugTests."1 foo bar" 
[1/1] show > [85/85] testexplib.test.testOnly 
********************     Setting up BugTestFramework     ********************
------------------- Running Tests TestExp.BugTests.1 foo bar -------------------
+ TestExp.BugTests.1 foo bar 6ms  
********************     Tearing down BugTestFramework     ********************
[
  "Tests: 1, Passed: 1, Failed: 0",
  [
    {
      "fullyQualifiedName": "TestExp.BugTests",
      "selector": "TestExp.BugTests.1 foo bar",
      "duration": 6,
      "status": "Success"
    }
  ]
]

But these fail:

mill show testexplib.test.testOnly -- TestExp.BugTests."2 foo, bar" 
[1/1] show > [85/85] testexplib.test.testOnly 
********************     Setting up BugTestFramework     ********************
utest.NoSuchTestException: [ bar]
utest.NoSuchTestException: [ bar]
	at utest.runner.BaseRunner.tasks(BaseRunner.scala:73)
	at mill.testrunner.TestRunnerUtils$.runTestFramework0(TestRunnerUtils.scala:123)
	at mill.testrunner.TestRunnerMain0$.main0(TestRunnerMain0.scala:38)
	at mill.testrunner.TestRunnerMain0.main0(TestRunnerMain0.scala)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at mill.testrunner.entrypoint.TestRunnerMain.main(TestRunnerMain.java:42)
1 targets failed
show 1 targets failed
testexplib.test.testOnly Test execution failed.


mill show testexplib.test.testOnly -- TestExp.BugTests."3 foo.txt" 
[1/1] show > [85/85] testexplib.test.testOnly 
********************     Setting up BugTestFramework     ********************
------------------- Running Tests TestExp.BugTests.3 foo.txt -------------------
utest.NoSuchTestException: [3 foo]
utest.NoSuchTestException: [3 foo]
	at utest.TestRunner$.runAsync(TestRunner.scala:60)
	at utest.runner.BaseRunner.runSuite(BaseRunner.scala:173)
	at utest.runner.BaseRunner.$anonfun$makeTask$1(BaseRunner.scala:184)
	at utest.runner.Task.execute(Task.scala:20)
	at mill.testrunner.TestRunnerUtils$.runTestFramework0(TestRunnerUtils.scala:142)
	at mill.testrunner.TestRunnerMain0$.main0(TestRunnerMain0.scala:38)
	at mill.testrunner.TestRunnerMain0.main0(TestRunnerMain0.scala)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at mill.testrunner.entrypoint.TestRunnerMain.main(TestRunnerMain.java:42)
1 targets failed
show 1 targets failed
testexplib.test.testOnly Test execution failed.

Please fix the test case name parsing or add documentation how to escape special characters like '.', ','in test names (there may also be others, I just found these two).

Used uTest is v 0.8.2 and scala v 2.13.12.

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

No branches or pull requests

1 participant