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

Avoid running subsequent meta-level builds after reaching the desired meta-level in MillBuildBootstrap #3960

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions integration/feature/meta-skip-compile/resources/build.mill
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CoMpIlAtIoNeRrOr
27 changes: 27 additions & 0 deletions integration/feature/meta-skip-compile/src/MetaSkipCompile.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package mill.integration

import mill.testkit.UtestIntegrationTestSuite

import utest._

object MetaSkipCompile extends UtestIntegrationTestSuite {

val tests: Tests = Tests {
test("test") - integrationTest { tester =>
// Make sure that when we pass in --meta-level 1, we stop after
// evaluating that level of the meta-build and do not proceed further,
// such that compilation errors in the build.mill do not affect us
val result1 = tester.eval(("--meta-level", "1", "resolve", "_"))
assert(result1.isSuccess)

// Without --meta-level 1, we hit the compilation error
val result2 = tester.eval(("resolve", "_"))
assert(!result2.isSuccess)

// Remove compilation error makes non-meta-level commands work again
os.write.over(tester.workspacePath / "build.mill", "")
val result3 = tester.eval(("resolve", "_"))
assert(result3.isSuccess)
}
}
}
19 changes: 5 additions & 14 deletions runner/src/mill/runner/MillBuildBootstrap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -181,29 +181,20 @@ class MillBuildBootstrap(
depth,
actualBuildFileName = nestedState.buildFile
)) { evaluator =>
if (depth != 0) {
val retState = processRunClasspath(
if (depth == requestedDepth) processFinalTargets(nestedState, rootModule, evaluator)
else if (depth <= requestedDepth) nestedState
else {
processRunClasspath(
nestedState,
rootModule,
evaluator,
prevFrameOpt,
prevOuterFrameOpt
)

if (retState.errorOpt.isEmpty && depth == requestedDepth) {
// TODO: print some message and indicate actual evaluated frame
val evalRet = processFinalTargets(nestedState, rootModule, evaluator)
if (evalRet.errorOpt.isEmpty) retState
else evalRet
} else
retState

} else {
processFinalTargets(nestedState, rootModule, evaluator)
}
}
}
// println(s"-evaluateRec($depth) " + recRoot(projectRoot, depth))

res
}

Expand Down
Loading