lazy val verifyDeps = taskKey[Unit]("verify inherited dependencies are properly extracted")

verifyDeps := {
	val a = compile.in(Compile).value
	same(a.relations.publicInherited.internal.forwardMap, expectedDeps.forwardMap)
}

lazy val expected = Seq(
	"A" -> Seq("C", "D", "E", "G", "J"),
	"B" -> Seq(),
	"C" -> Seq("D", "G", "J"),
	"D" -> Seq("G", "J"),
	"E" -> Seq(),
	"F" -> Seq("C", "D", "G", "J"),
	"G" -> Seq("J"),
	"J" -> Seq()
)
lazy val pairs =
	expected.map { case (from,tos) =>
		(toFile(from), tos.map(toFile))
	}
lazy val expectedDeps = (Relation.empty[File,File] /: pairs) { case (r, (x,ys)) => r + (x,ys) }
def toFile(s: String) = file(s + ".scala").getAbsoluteFile

def same[T](x: T, y: T) {
	assert(x == y, s"\nActual: $x, \nExpected: $y")
}

lazy val verifyDeps = taskKey[Unit]("verify inherited dependencies are properly extracted")

verifyDeps := {
	val a = compile.in(Compile).value
	val baseDir = baseDirectory.value
	def relative(f: java.io.File): java.io.File =  f.relativeTo(baseDir) getOrElse f
	def toFile(s: String) = relative(baseDir / (s + ".scala"))
	def inheritedDeps(name: String): Set[File] = {
		val file = (baseDir / (name + ".scala")).getAbsoluteFile
		val absoluteFiles = a.relations.publicInherited.internal.forward(file)
		absoluteFiles.map(relative)
	}
	val ADeps = Set("C", "D", "E", "G", "J").map(toFile)
	same(inheritedDeps("A"), ADeps)
	val BDeps = Set.empty[File]
	same(inheritedDeps("B"), BDeps)
	val CDeps = Set("D", "G", "J").map(toFile)
	same(inheritedDeps("C"), CDeps)
	val DDeps = Set("G", "J").map(toFile)
	same(inheritedDeps("D"), DDeps)
	val EDeps = Set.empty[File]
	same(inheritedDeps("E"), EDeps)
	val FDeps = Set("C", "D", "G", "J").map(toFile)
	same(inheritedDeps("F"), FDeps)
	val GDeps = Set("J").map(toFile)
	same(inheritedDeps("G"), GDeps)
	val JDeps = Set.empty[File]
	same(inheritedDeps("J"), JDeps)
}

def same[T](x: T, y: T) {
	assert(x == y, s"\nActual: $x, \nExpected: $y")
}

Improve failure message in `inherited-dependencies` test.
Improve failure message in `inherited-dependencies` test.

When the `source-dependencies/inherited-dependencies` test fails we
get a dump of a big collection of all dependencies with absolute
file paths printed. This is not very readable when one needs to
understand the actual difference.

I decided to test dependencies of each source file separately. This way
when assertion exception is thrown we get a stack trace that points
us at the line which tested dependencies of a specific source file.
Also, all files are relative to baseDirectory of the project.
