-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More granular cache invalidaton with multiple file
- Loading branch information
Showing
19 changed files
with
199 additions
and
31 deletions.
There are no files selected for viewing
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
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,3 @@ | ||
def input = T { | ||
println("a") | ||
} |
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,5 @@ | ||
import $file.inputD | ||
def input = T { | ||
inputD.method() | ||
println("b") | ||
} |
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,3 @@ | ||
def method() = { | ||
println("d") | ||
} |
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,10 @@ | ||
import $file.a.inputA | ||
import $file.b.inputB | ||
import $file.inputC | ||
import $ivy.`org.scalaj::scalaj-http:2.4.2` | ||
|
||
def task = T { | ||
inputA.input() | ||
inputB.input() | ||
inputC.input() | ||
} |
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,3 @@ | ||
def input = T { | ||
println("c") | ||
} |
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,72 @@ | ||
package mill.integration | ||
|
||
import mill.util.ScriptTestSuite | ||
import utest._ | ||
|
||
import scala.collection.mutable | ||
|
||
class ScriptsInvalidationTests(fork: Boolean) extends ScriptTestSuite(fork) { | ||
def workspaceSlug: String = "invalidation" | ||
def scriptSourcePath: os.Path = os.pwd / "integration" / "test" / "resources" / workspaceSlug | ||
|
||
val output = mutable.Buffer[String]() | ||
val stdout = os.ProcessOutput((bytes, count) => output += new String(bytes, 0, count)) | ||
def runTask() = assert(eval(stdout, "task")) | ||
|
||
override def utestBeforeEach(path: Seq[String]): Unit = { | ||
output.clear() | ||
} | ||
|
||
val tests = Tests { | ||
test("should not invalidate tasks in different untouched sc files") { | ||
test("first run") { | ||
initWorkspace() | ||
runTask() | ||
|
||
val result = output.map(_.trim).toList | ||
val expected = List("a", "d", "b", "c") | ||
|
||
assert(result == expected) | ||
} | ||
|
||
test("second run modifying script") { | ||
val oldContent = os.read(scriptSourcePath / buildPath) | ||
val newContent = s"""$oldContent | ||
|def newTask = T { } | ||
|""".stripMargin | ||
os.write.over(workspacePath / buildPath, newContent) | ||
|
||
runTask() | ||
|
||
assert(output.isEmpty) | ||
} | ||
} | ||
test("should invalidate tasks if leaf file is changed") { | ||
test("first run") { | ||
initWorkspace() | ||
runTask() | ||
|
||
val result = output.map(_.trim).toList | ||
val expected = List("a", "d", "b", "c") | ||
|
||
assert(result == expected) | ||
} | ||
|
||
test("second run modifying script") { | ||
val inputD = os.sub / "b" / "inputD.sc" | ||
val oldContent = os.read(scriptSourcePath / inputD) | ||
val newContent = s"""$oldContent | ||
|def newTask = T { } | ||
|""".stripMargin | ||
os.write.over(workspacePath / inputD, newContent) | ||
|
||
runTask() | ||
|
||
val result = output.map(_.trim).toList | ||
val expected = List("d", "b") | ||
|
||
assert(result == expected) | ||
} | ||
} | ||
} | ||
} |
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
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
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,8 @@ | ||
package mill.define | ||
|
||
trait GraphNode[T] { | ||
/** | ||
* What other nodes does this node depend on? | ||
*/ | ||
def inputs: Seq[T] | ||
} |
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,3 @@ | ||
package mill.define | ||
|
||
case class ScriptNode(cls: String, inputs: Seq[ScriptNode]) extends GraphNode[ScriptNode] |
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
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
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
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
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
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
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
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