summaryrefslogtreecommitdiff
path: root/core/src/test
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2017-11-12 11:28:52 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2017-11-12 11:28:52 -0800
commitb12c3f0f040a2b6caf1f94ad789d80b91313e381 (patch)
tree977a108a79d4b512e86680d058b411d919e04c6b /core/src/test
parentde3f16918dc5b5af6cb8bf226f3aa80ef8879bba (diff)
downloadmill-b12c3f0f040a2b6caf1f94ad789d80b91313e381.tar.gz
mill-b12c3f0f040a2b6caf1f94ad789d80b91313e381.tar.bz2
mill-b12c3f0f040a2b6caf1f94ad789d80b91313e381.zip
Rename out `Task.path` to `Task.source`, use it more aggressively to get `amm -w` watch-n-rebuild functionality working on `build.sc`
Diffstat (limited to 'core/src/test')
-rw-r--r--core/src/test/scala/mill/EvaluationTests.scala8
-rw-r--r--core/src/test/scala/mill/GraphTests.scala6
-rw-r--r--core/src/test/scala/mill/JavaCompileJarTests.scala30
3 files changed, 24 insertions, 20 deletions
diff --git a/core/src/test/scala/mill/EvaluationTests.scala b/core/src/test/scala/mill/EvaluationTests.scala
index 0face75e..1cfc93fa 100644
--- a/core/src/test/scala/mill/EvaluationTests.scala
+++ b/core/src/test/scala/mill/EvaluationTests.scala
@@ -27,7 +27,7 @@ object EvaluationTests extends TestSuite{
// are directly evaluating tasks which need to re-evaluate every time
secondRunNoOp: Boolean = true) = {
- val Evaluator.Results(returnedValues, returnedEvaluated) = evaluator.evaluate(OSet(target))
+ val Evaluator.Results(returnedValues, returnedEvaluated, _) = evaluator.evaluate(OSet(target))
val (matchingReturnedEvaled, extra) = returnedEvaluated.items.partition(expEvaled.contains)
@@ -39,7 +39,7 @@ object EvaluationTests extends TestSuite{
// Second time the value is already cached, so no evaluation needed
if (secondRunNoOp){
- val Evaluator.Results(returnedValues2, returnedEvaluated2) = evaluator.evaluate(OSet(target))
+ val Evaluator.Results(returnedValues2, returnedEvaluated2, _) = evaluator.evaluate(OSet(target))
val expecteSecondRunEvaluated = OSet()
assert(
returnedValues2 == returnedValues,
@@ -50,7 +50,9 @@ object EvaluationTests extends TestSuite{
}
def countGroups[T: Discovered](t: T, terminals: Task[_]*) = {
val labeling = Discovered.mapping(t)
- val topoSorted = Evaluator.topoSortedTransitiveTargets(OSet.from(terminals))
+ val topoSorted = Evaluator.topoSorted(
+ Evaluator.transitiveTargets(OSet.from(terminals))
+ )
val grouped = Evaluator.groupAroundNamedTargets(topoSorted, labeling)
grouped.keyCount
}
diff --git a/core/src/test/scala/mill/GraphTests.scala b/core/src/test/scala/mill/GraphTests.scala
index 575b4a89..60895c71 100644
--- a/core/src/test/scala/mill/GraphTests.scala
+++ b/core/src/test/scala/mill/GraphTests.scala
@@ -84,7 +84,7 @@ object GraphTests extends TestSuite{
'topoSortedTransitiveTargets - {
def check(targets: OSet[Task[_]], expected: OSet[Task[_]]) = {
- val result = Evaluator.topoSortedTransitiveTargets(targets).values
+ val result = Evaluator.topoSorted(Evaluator.transitiveTargets(targets)).values
TestUtil.checkTopological(result)
assert(result == expected)
}
@@ -128,7 +128,7 @@ object GraphTests extends TestSuite{
)
)
'bigSingleTerminal - {
- val result = Evaluator.topoSortedTransitiveTargets(OSet(bigSingleTerminal.j)).values
+ val result = Evaluator.topoSorted(Evaluator.transitiveTargets(OSet(bigSingleTerminal.j))).values
TestUtil.checkTopological(result)
assert(result.size == 28)
}
@@ -140,7 +140,7 @@ object GraphTests extends TestSuite{
expected: OSet[(OSet[R], Int)]) = {
val mapping = Discovered.mapping(base)
- val topoSortedTransitive = Evaluator.topoSortedTransitiveTargets(OSet(target))
+ val topoSortedTransitive = Evaluator.topoSorted(Evaluator.transitiveTargets(OSet(target)))
val grouped = Evaluator.groupAroundNamedTargets(topoSortedTransitive, mapping)
val flattened = OSet.from(grouped.values().flatMap(_.items))
diff --git a/core/src/test/scala/mill/JavaCompileJarTests.scala b/core/src/test/scala/mill/JavaCompileJarTests.scala
index 6e398540..8272ed71 100644
--- a/core/src/test/scala/mill/JavaCompileJarTests.scala
+++ b/core/src/test/scala/mill/JavaCompileJarTests.scala
@@ -5,7 +5,7 @@ import ammonite.ops._
import ImplicitWd._
import mill.define.Task
import mill.discover.Discovered
-import mill.eval.{Evaluator, PathRef}
+import mill.eval.Evaluator
import mill.modules.Jvm.jarUp
import mill.util.OSet
import utest._
@@ -38,8 +38,8 @@ object JavaCompileJarTests extends TestSuite{
// |
// v
// resourceRoot ----> jar
- def sourceRoot = T{ Task.path(sourceRootPath) }
- def resourceRoot = T{ Task.path(resourceRootPath) }
+ def sourceRoot = T.source{ sourceRootPath }
+ def resourceRoot = T.source{ resourceRootPath }
def allSources = T{ ls.rec(sourceRoot().path).map(PathRef(_)) }
def classFiles = T{ compileAll(Task.ctx().dest, allSources()) }
def jar = T{ jarUp(resourceRoot, classFiles) }
@@ -56,13 +56,13 @@ object JavaCompileJarTests extends TestSuite{
val evaluated = evaluator.evaluate(OSet(t))
Tuple2(
evaluated.values(0).asInstanceOf[T],
- evaluated.targets.filter(x => mapping.contains(x) || x.isInstanceOf[mill.define.Command[_]]).size
+ evaluated.evaluated.filter(x => mapping.contains(x) || x.isInstanceOf[mill.define.Command[_]]).size
)
}
def check(targets: OSet[Task[_]], expected: OSet[Task[_]]) = {
val evaluator = new Evaluator(workspacePath, mapping)
- val evaluated = evaluator.evaluate(targets).targets.filter(mapping.contains)
+ val evaluated = evaluator.evaluate(targets).evaluated.filter(mapping.contains)
assert(evaluated == expected)
}
@@ -71,7 +71,7 @@ object JavaCompileJarTests extends TestSuite{
check(
targets = OSet(jar),
- expected = OSet(resourceRoot, sourceRoot, allSources, classFiles, jar)
+ expected = OSet(allSources, classFiles, jar)
)
// Re-running with no changes results in nothing being evaluated
@@ -84,30 +84,32 @@ object JavaCompileJarTests extends TestSuite{
// Appending whitespace forces a recompile, but the classfilesend up
// exactly the same so no re-jarring.
append(sourceRootPath / "Foo.java", " ")
- check(targets = OSet(jar), expected = OSet(sourceRoot, allSources, classFiles))
+ // Note that `sourceRoot` and `resourceRoot` never turn up in the `expected`
+ // list, because they are `Source`s not `Target`s
+ check(targets = OSet(jar), expected = OSet(/*sourceRoot, */allSources, classFiles))
// Appending a new class changes the classfiles, which forces us to
// re-create the final jar
append(sourceRootPath / "Foo.java", "\nclass FooTwo{}")
- check(targets = OSet(jar), expected = OSet(sourceRoot, allSources, classFiles, jar))
+ check(targets = OSet(jar), expected = OSet(allSources, classFiles, jar))
// Tweaking the resources forces rebuild of the final jar, without
// recompiling classfiles
append(resourceRootPath / "hello.txt", " ")
- check(targets = OSet(jar), expected = OSet(resourceRoot, jar))
+ check(targets = OSet(jar), expected = OSet(jar))
// Asking for an intermediate target forces things to be build up to that
// target only; these are re-used for any downstream targets requested
append(sourceRootPath / "Bar.java", "\nclass BarTwo{}")
append(resourceRootPath / "hello.txt", " ")
- check(targets = OSet(classFiles), expected = OSet(sourceRoot, allSources, classFiles))
- check(targets = OSet(jar), expected = OSet(resourceRoot, jar))
+ check(targets = OSet(classFiles), expected = OSet(allSources, classFiles))
+ check(targets = OSet(jar), expected = OSet(jar))
check(targets = OSet(allSources), expected = OSet())
append(sourceRootPath / "Bar.java", "\nclass BarThree{}")
append(resourceRootPath / "hello.txt", " ")
- check(targets = OSet(resourceRoot), expected = OSet(resourceRoot))
- check(targets = OSet(allSources), expected = OSet(sourceRoot, allSources))
+ check(targets = OSet(resourceRoot), expected = OSet())
+ check(targets = OSet(allSources), expected = OSet(allSources))
check(targets = OSet(jar), expected = OSet(classFiles, jar))
val jarContents = %%('jar, "-tf", workspacePath/'jar)(workspacePath).out.string
@@ -154,7 +156,7 @@ object JavaCompileJarTests extends TestSuite{
val (runOutput2, evalCount2) = eval(Build.run("test.BarFour"))
assert(
runOutput2.out.string == "New Cls!\n",
- evalCount2 == 4
+ evalCount2 == 3
)
val (runOutput3, evalCount3) = eval(Build.run("test.BarFour"))
assert(