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

Possible incorrect path to tests #715

Closed
hmf opened this issue Oct 15, 2019 · 2 comments
Closed

Possible incorrect path to tests #715

hmf opened this issue Oct 15, 2019 · 2 comments

Comments

@hmf
Copy link

hmf commented Oct 15, 2019

I have tried to reopen #370 to what seems like an issue. I have dug deeper and something looks incorrect. I am executing a JUnit test and it fails due to a missing library. When I print the classpath within the test it is in fact missing. The test call is as follows:

def test(args: String*) = T.command{
    val outputPath = T.ctx().dest/"out.json"

    Jvm.runSubprocess(
      mainClass = "mill.scalalib.TestRunner",
      classPath = zincWorker.scalalibClasspath().map(_.path),
      jvmArgs = forkArgs(),
      envArgs = forkEnv(),
      mainArgs =
        Seq(testFrameworks().length.toString) ++
        testFrameworks() ++
        Seq(runClasspath().length.toString) ++
        runClasspath().map(_.path.toString) ++
        Seq(args.length.toString) ++
        args ++
        Seq(outputPath.toString, T.ctx().log.colored.toString, compile().classes.path.toString, T.ctx().home.toString),
      workingDir = forkWorkingDir()
    )

    try {
      val jsonOutput = ujson.read(outputPath.toIO)
      val (doneMsg, results) = upickle.default.read[(String, Seq[TestRunner.Result])](jsonOutput)
      TestModule.handleResults(doneMsg, results)
    }catch{case e: Throwable =>
      Result.Failure("Test reporting failed: " + e)
    }

  }

Notice that the classpath is set to zincWorker.scalalibClasspath().map(_.path), If we look at the subprocess call we have:

def runSubprocess(mainClass: String,
                    classPath: Agg[os.Path],
                    jvmArgs: Seq[String] = Seq.empty,
                    envArgs: Map[String, String] = Map.empty,
                    mainArgs: Seq[String] = Seq.empty,
                    workingDir: os.Path = null,
                    background: Boolean = false): Unit = {
    val args =
      Vector("java") ++
      jvmArgs ++
      Vector("-cp", classPath.mkString(java.io.File.pathSeparator), mainClass) ++
      mainArgs

    if (background) spawnSubprocess(args, envArgs, workingDir)
    else runSubprocess(args, envArgs, workingDir)
  }

Notice that only the Zin Worker classpath is used. The runClasspath() is passed as a parameter but is not set in the classpath. If I look at the JUnitRunner, the arguments don't seem to be used to set the classpath.

Shouldn't the classPath include Mill's runClasspath()? A search for path in the JUnit interface repository doesn't provide me with any more clues.

Test were done with version 0.5.1, JDK 11 and Linux

@hmf
Copy link
Author

hmf commented Oct 15, 2019

I see that my assumption is incorrect. The testRunner takes the arguments and uses that to construct the classpath. However the path still does not show up in the test case.

@hmf
Copy link
Author

hmf commented Oct 16, 2019

I am closing this one because I cannot find a way to debug Mil's TestRunner. I will reopen a new issue with a better explanation of the error.

@hmf hmf closed this as completed Oct 16, 2019
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