Skip to content

Commit

Permalink
Merge branch 'out-folder-content-reproducible' of https://github.com/…
Browse files Browse the repository at this point in the history
…rahat2134/mill into out-folder-content-reproducible
  • Loading branch information
rahat2134 committed Nov 7, 2024
2 parents a6a9d13 + 6565ce2 commit 01c705c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
15 changes: 13 additions & 2 deletions main/api/src/mill/api/PathRef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,25 @@ object PathRef {

def normalizePath(path: os.Path, isTest: Boolean = false): String = {
if (serializationContext.get() || isTest) {

if (sys.env.contains("GITHUB_WORKSPACE")) {
println(s"Debug: GITHUB_WORKSPACE detected: ${sys.env("GITHUB_WORKSPACE")}")
println(s"Debug: Input path: $path")
}

// First normalize the path for worker.json files
if (path.toString().contains("/test/test.dest/")) {
return path.toString()
}
val normalizedPath = NonDeterministicFiles.normalizeWorkerJson(path)

val workspaceRoot = if (isTest) testUserHome / "projects" / "myproject"
else os.Path(WorkspaceRoot.workspaceRoot.toIO)
val workspaceRoot = sys.env.get("GITHUB_WORKSPACE") match {
case Some(workspace) if path.toString().startsWith(workspace) =>
os.Path(workspace)
case _ if isTest => testUserHome / "projects" / "myproject"
case _ => os.Path(WorkspaceRoot.workspaceRoot.toIO)
}

val coursierCache = if (isTest) Some(testUserHome / ".coursier" / "cache")
else sys.env.get("COURSIER_CACHE").map(os.Path(_))
val home = if (isTest) testUserHome else realUserHome
Expand Down
27 changes: 23 additions & 4 deletions testrunner/src/mill/testrunner/TestRunnerUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,28 @@ import scala.jdk.CollectionConverters.IteratorHasAsScala
ctx: Ctx.Log with Ctx.Home
): (String, Iterator[TestResult]) = {
val events = new ConcurrentLinkedQueue[Event]()
val doneMessage = {
var hasFailures = false

val doneMessage = {
val taskQueue = tasks.to(mutable.Queue)
while (taskQueue.nonEmpty) {
val next = taskQueue.dequeue().execute(
new EventHandler {
def handle(event: Event) = {
testReporter.logStart(event)
events.add(event)

// Fixed throwable handling
if (event.status() == Status.Failure) {
hasFailures = true
val throwableMsg =
if (event.throwable().isDefined) event.throwable().get().getMessage
else ""
ctx.log.debug(
s"Test failure detected: ${event.fullyQualifiedName()} - $throwableMsg"
)
}

testReporter.logFinish(event)
}
},
Expand All @@ -154,7 +167,6 @@ import scala.jdk.CollectionConverters.IteratorHasAsScala
def info(msg: String) = ctx.log.outputStream.println(msg)
})
)

taskQueue.enqueueAll(next)
}
runner.done()
Expand All @@ -167,9 +179,12 @@ import scala.jdk.CollectionConverters.IteratorHasAsScala
ctx.log.outputStream.println(doneMessage)
}

ctx.log.debug(s"Test execution completed. Total events: ${events.size()}")

val results = for (e <- events.iterator().asScala) yield {
val ex =
if (e.throwable().isDefined) Some(e.throwable().get) else None
ctx.log.debug(s"Test result: ${e.fullyQualifiedName()} - Status: ${e.status()}")

val ex = if (e.throwable().isDefined) Some(e.throwable().get()) else None
mill.testrunner.TestResult(
e.fullyQualifiedName(),
e.selector() match {
Expand All @@ -187,6 +202,10 @@ import scala.jdk.CollectionConverters.IteratorHasAsScala
)
}

if (hasFailures) {
ctx.log.debug("Test failures detected, ensuring proper result propagation")
}

(doneMessage, results)
}

Expand Down

0 comments on commit 01c705c

Please sign in to comment.