Skip to content

Commit

Permalink
Change tests to test 'resolveJavadocs' option
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolay Obedin committed Dec 3, 2015
1 parent 9a35d8c commit 649bda3
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 21 deletions.
1 change: 0 additions & 1 deletion extractor/src/test/data/0.12/bare/structure-0.12.4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@
<repository>
<module revision="2.10.1" name="scala-library" artifactType="jar" organization="org.scala-lang" classifier="">
<jar>~/.sbt/boot/scala-2.10.1/lib/scala-library.jar</jar>
<doc>~/.ivy2/cache/org.scala-lang/scala-library/docs/scala-library-2.10.1-javadoc.jar</doc>
<src>~/.ivy2/cache/org.scala-lang/scala-library/srcs/scala-library-2.10.1-sources.jar</src>
</module>
</repository>
Expand Down
1 change: 0 additions & 1 deletion extractor/src/test/data/0.12/simple/structure-0.12.4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
<repository>
<module revision="2.10.1" name="scala-library" artifactType="jar" organization="org.scala-lang" classifier="">
<jar>~/.sbt/boot/scala-2.10.1/lib/scala-library.jar</jar>
<doc>~/.ivy2/cache/org.scala-lang/scala-library/docs/scala-library-2.10.1-javadoc.jar</doc>
<src>~/.ivy2/cache/org.scala-lang/scala-library/srcs/scala-library-2.10.1-sources.jar</src>
</module>
</repository>
Expand Down
1 change: 0 additions & 1 deletion extractor/src/test/data/0.13/bare/structure-0.13.0.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@
<repository>
<module organization="org.scala-lang" name="scala-library" revision="2.10.1" artifactType="jar" classifier="">
<jar>~/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.10.1.jar</jar>
<doc>~/.ivy2/cache/org.scala-lang/scala-library/docs/scala-library-2.10.1-javadoc.jar</doc>
<src>~/.ivy2/cache/org.scala-lang/scala-library/srcs/scala-library-2.10.1-sources.jar</src>
</module>
</repository>
Expand Down
1 change: 0 additions & 1 deletion extractor/src/test/data/0.13/bare/structure-0.13.7.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@
<repository>
<module organization="org.scala-lang" name="scala-library" revision="2.10.1" artifactType="jar" classifier="">
<jar>~/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.10.1.jar</jar>
<doc>~/.ivy2/cache/org.scala-lang/scala-library/docs/scala-library-2.10.1-javadoc.jar</doc>
<src>~/.ivy2/cache/org.scala-lang/scala-library/srcs/scala-library-2.10.1-sources.jar</src>
</module>
</repository>
Expand Down
1 change: 0 additions & 1 deletion extractor/src/test/data/0.13/bare/structure-0.13.9.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@
<repository>
<module organization="org.scala-lang" name="scala-library" revision="2.10.1" artifactType="jar" classifier="">
<jar>~/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.10.1.jar</jar>
<doc>~/.ivy2/cache/org.scala-lang/scala-library/docs/scala-library-2.10.1-javadoc.jar</doc>
<src>~/.ivy2/cache/org.scala-lang/scala-library/srcs/scala-library-2.10.1-sources.jar</src>
</module>
</repository>
Expand Down
1 change: 0 additions & 1 deletion extractor/src/test/data/0.13/simple/structure-0.13.0.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@
<repository>
<module organization="org.scala-lang" name="scala-library" revision="2.10.1" artifactType="jar" classifier="">
<jar>~/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.10.1.jar</jar>
<doc>~/.ivy2/cache/org.scala-lang/scala-library/docs/scala-library-2.10.1-javadoc.jar</doc>
<src>~/.ivy2/cache/org.scala-lang/scala-library/srcs/scala-library-2.10.1-sources.jar</src>
</module>
</repository>
Expand Down
1 change: 0 additions & 1 deletion extractor/src/test/data/0.13/simple/structure-0.13.7.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@
<repository>
<module organization="org.scala-lang" name="scala-library" revision="2.10.1" artifactType="jar" classifier="">
<jar>~/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.10.1.jar</jar>
<doc>~/.ivy2/cache/org.scala-lang/scala-library/docs/scala-library-2.10.1-javadoc.jar</doc>
<src>~/.ivy2/cache/org.scala-lang/scala-library/srcs/scala-library-2.10.1-sources.jar</src>
</module>
</repository>
Expand Down
1 change: 0 additions & 1 deletion extractor/src/test/data/0.13/simple/structure-0.13.9.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@
<repository>
<module organization="org.scala-lang" name="scala-library" revision="2.10.1" artifactType="jar" classifier="">
<jar>~/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.10.1.jar</jar>
<doc>~/.ivy2/cache/org.scala-lang/scala-library/docs/scala-library-2.10.1-javadoc.jar</doc>
<src>~/.ivy2/cache/org.scala-lang/scala-library/srcs/scala-library-2.10.1-sources.jar</src>
</module>
</repository>
Expand Down
15 changes: 8 additions & 7 deletions extractor/src/test/scala/org/jetbrains/sbt/ImportSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ class ImportSpec extends Specification with XmlMatchers {
"Actual structure" should {
sequential // running 10 sbt instances at once is a bad idea unless you have >16G of ram

equalExpectedOneIn("bare")
equalExpectedOneIn("bare", options="resolveClassifiers resolveSbtClassifiers")
equalExpectedOneIn("simple", options="resolveClassifiers resolveSbtClassifiers")
equalExpectedOneIn("multiple")
equalExpectedOneIn("simple")
equalExpectedOneIn("dependency")
equalExpectedOneIn("classifiers", sbt13only)
equalExpectedOneIn("optional", sbt13only)
equalExpectedOneIn("play", onlyFor("0.13.7", "0.13.9"), resolveClassifiers = false)
equalExpectedOneIn("play", onlyFor("0.13.7", "0.13.9"), options = "")
equalExpectedOneIn("android-1.4", onlyFor("0.13.7", "0.13.9") and ifAndroidDefined)
equalExpectedOneIn("android", sbt13only and ifAndroidDefined)
equalExpectedOneIn("ide-settings", onlyFor("0.13.7", "0.13.9"))
Expand All @@ -39,22 +39,23 @@ class ImportSpec extends Specification with XmlMatchers {
val AndroidHome = Option(System.getenv.get("ANDROID_HOME")).map(normalizePath)
val UserHome = Option(System.getProperty("user.home")).map(normalizePath)

private def equalExpectedOneIn(projectName: String, conditions: => MatchResult[Any] = always, resolveClassifiers: Boolean = true) =
private def equalExpectedOneIn(projectName: String, conditions: => MatchResult[Any] = always,
options: String = "resolveClassifiers resolveSbtClassifiers resolveJavadocs") =
("equal expected one in '" + projectName + "' project [" + SbtVersionFull + "]").in { _: String =>
if (conditions.isSuccess)
testProject(projectName, resolveClassifiers)
testProject(projectName, options)
else
conditions
}

private def testProject(project: String, resolveClassifiers: Boolean) = {
private def testProject(project: String, options: String) = {
val base = new File(TestDataRoot, project)
val testDataFile = new File(base, "structure-" + SbtVersionFull + ".xml")

testDataFile must exist.setMessage("No test data for version " + SbtVersionFull + " found")

val expectedStr = getExpectedStr(testDataFile, base)
val actualStr = Loader.load(base, resolveClassifiers, SbtVersionFull, PluginFile, verbose = true).mkString("\n")
val actualStr = Loader.load(base, options, SbtVersionFull, PluginFile, verbose = true).mkString("\n")
val actualXml = XML.loadString(actualStr)
val expectedXml = XML.loadString(expectedStr)
val actual = actualXml.deserialize[StructureData].right.get
Expand Down
8 changes: 2 additions & 6 deletions extractor/src/test/scala/org/jetbrains/sbt/Loader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ object Loader {
private val JavaVM = path(new File(new File(new File(System.getProperty("java.home")), "bin"), "java"))
private val SbtLauncher = path(new File("sbt-launch.jar"))

def load(project: File, resolveClassifiers: Boolean, sbtVersion: String, pluginFile: File, verbose: Boolean = false): Seq[String] = {
def load(project: File, options: String, sbtVersion: String, pluginFile: File, verbose: Boolean = false): Seq[String] = {
val structureFile = createTempFile("sbt-structure", ".xml")
val commandsFile = createTempFile("sbt-commands", ".lst")

val opts =
if (resolveClassifiers)
"download prettyPrint resolveClassifiers resolveSbtClassifiers resolveJavadocs"
else
"download prettyPrint"
val opts = "download prettyPrint " + options

writeLinesTo(commandsFile,
"set SettingKey[Option[File]](\"sbt-structure-output-file\") in Global := Some(file(\"" + path(structureFile) + "\"))",
Expand Down

0 comments on commit 649bda3

Please sign in to comment.