From 4635af182a17f4c270d319a2fa455869ea364e78 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Sat, 15 Feb 2020 16:53:41 +0000 Subject: [PATCH] Add some tests around Def.displayRelative2 --- .../src/test/scala/sbt/ScopeDisplaySpec.scala | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/main-settings/src/test/scala/sbt/ScopeDisplaySpec.scala b/main-settings/src/test/scala/sbt/ScopeDisplaySpec.scala index 6c7798d67..de8290196 100644 --- a/main-settings/src/test/scala/sbt/ScopeDisplaySpec.scala +++ b/main-settings/src/test/scala/sbt/ScopeDisplaySpec.scala @@ -47,4 +47,28 @@ class ScopeDisplaySpec extends FlatSpec { ) assert(string == "blah") } + + behavior of "Def.displayRelative2" + + val b1 = project.build + val b2 = sbt.io.IO.toURI(file("other")) + + val p1 = project + val p2 = ProjectRef(b1, "baz") + val p3 = ProjectRef(b2, "qux") + + private def disp(r: Reference) = Def.displayRelative2(current = p1, r) + + it should "ProjectRef curr proj" in assert(disp(p1) == "") + it should "ProjectRef same build" in assert(disp(p2) == "baz /") + it should "ProjectRef diff build" in assert(disp(p3) == """ProjectRef(uri("other"), "qux") /""") + it should "BuildRef same build" in assert(disp(BuildRef(b1)) == "ThisBuild /") + it should "BuildRef diff build" in assert(disp(BuildRef(b2)) == "{other} /") + it should "RootProject same build" in assert(disp(RootProject(b1)) == "{foo/bar } /") + it should "RootProject diff build" in assert(disp(RootProject(b2)) == "{other } /") + it should "LocalProject curr proj" in assert(disp(LocalProject(p1.project)) == "{}bar /") + it should "LocalProject diff proj" in assert(disp(LocalProject(p2.project)) == "{}baz /") + it should "ThisBuild" in assert(disp(ThisBuild) == "{} /") + it should "LocalRootProject" in assert(disp(LocalRootProject) == "{} /") + it should "ThisProject" in assert(disp(ThisProject) == "{} /") }