Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Weaver GlobalResource loses forkEnv under test scheduler #7113

@nguyenyou

Description

@nguyenyou

TLDR

Regression since Mill 1.0.3: Mill calls runner.tasks(...) during scheduler pre-filtering in the Mill/Zinc worker, before the forked test JVM is launched. For Weaver, runner.tasks(...) initializes GlobalResource, so forkEnv is not visible there.

Then the queue scheduler calls runner.tasks(...) one claimed class at a time, so Weaver's GlobalResource TaskDef and resource-using suite TaskDef are split apart.

Minimal repro: https://github.com/nguyenyou/mill-weaver-forkenv-global-resource-repro

Root Cause

Current path:

TestModuleUtil.runTests
  |
  |-- ZincOp.GetTestTasks
  |     |
  |     `-- TestRunnerUtils.getTestTasks0
  |           |
  |           `-- runner.tasks(...)   // runs in Mill/Zinc worker, no forkEnv
  |
  `-- forked test JVM
        |
        `-- queue scheduler calls runner.tasks([one claimed class])

For most frameworks, runner.tasks(...) is effectively cheap task materialization. For Weaver, it is semantically meaningful: global resources are collected and initialized from the full TaskDef batch.

So there are two related scheduler issues:

  1. runner.tasks(...) runs outside the forked JVM, so framework setup cannot see forkEnv.
  2. The queue scheduler splits related TaskDefs, so Weaver sees the suite without the global resource.

Regression / Affected Versions

Bisect points to:

First affected stable release: Mill 1.0.3

Affected:

  • 1.0.3+
  • all current 1.1.x releases, including 1.1.5

Not affected:

  • 0.12.x
  • 1.0.0 through 1.0.2

User report: 0.12.16 works, 1.1.5 fails.

Expected

Framework setup and TaskDef batching should happen inside the forked test JVM with forkEnv applied, or Mill should preserve full selected TaskDef batch semantics for frameworks that require it.

Actual

Mill pre-filters by invoking framework task creation in a worker without forkEnv, then the forked queue runner invokes framework task creation per claimed class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions