-
-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add nice error when non-exclusive task depends on exclusive task (#3887)
Fixes #3875 I placed a check to raise an error when a non-exclusive task depends on an exclusive task. We could place this check any time from task instantiation to just before the `NoSuchElementException` gets thrown. I ended up putting it as late as possible, such that the failure is localized, which allows other un-related parts of the build to proceed despite the failure, as well as allowing other errors in the build to be reported in parallel (rather than having to re-run the build over and over after fixing each one to see the next one) Covered with an integration test that asserts on the error message. Best reviewed with Ignore Whitespace
- Loading branch information
Showing
3 changed files
with
132 additions
and
77 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
integration/failure/non-exclusive-depends-on-exclusive/resources/build.mill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package build | ||
import mill._, mill.eval.Evaluator | ||
|
||
def foo = Task{1} | ||
def cleanClientWrong(ev: Evaluator) = Task.Command { | ||
clean(ev, "foo")() | ||
println("cleanClientWrong done") | ||
} | ||
|
||
def cleanClientRight(ev: Evaluator) = Task.Command(exclusive = true) { | ||
clean(ev, "foo")() | ||
println("cleanClientRight done") | ||
} |
24 changes: 24 additions & 0 deletions
24
...ation/failure/non-exclusive-depends-on-exclusive/src/NonExclusiveDependsOnExclusive.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package mill.integration | ||
|
||
import mill.testkit.UtestIntegrationTestSuite | ||
|
||
import utest._ | ||
|
||
object NonExclusiveDependsOnExclusive extends UtestIntegrationTestSuite { | ||
val tests: Tests = Tests { | ||
test("wrong") - integrationTest { tester => | ||
val res = tester.eval("cleanClientWrong") | ||
assert(res.isSuccess == false) | ||
assert(res.err.contains( | ||
"Non-exclusive task cleanClientWrong cannot depend on exclusive task clean" | ||
)) | ||
assert(!res.out.contains("cleanClientWrong done")) | ||
} | ||
test("right") - integrationTest { tester => | ||
val res = tester.eval("cleanClientRight") | ||
assert(res.isSuccess == true) | ||
assert(res.out.contains("cleanClientRight done")) | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters