Skip to content

Commit

Permalink
added integration tests that would have detected the bug that was fix…
Browse files Browse the repository at this point in the history
…ed in #34 (#35)
  • Loading branch information
jothepro authored Mar 19, 2021
1 parent a2003c7 commit 1fae663
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
29 changes: 29 additions & 0 deletions src/it/scala/djinni/GeneratorIntegrationTest.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package djinni

import org.scalatest.GivenWhenThen
import org.scalatest.Matchers.{convertToAnyShouldWrapper, equal}
import org.scalatest.prop.TableDrivenPropertyChecks._

class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen {
Expand Down Expand Up @@ -78,5 +79,33 @@ class GeneratorIntegrationTest extends IntegrationTest with GivenWhenThen {
assertFileContentEquals(idlFile, OBJCPP, objcppFilenames)
}
}

it("should be able to only generate Java output") {
val outputPath = "src/it/resources/result/only_java_out"
When("calling the generator with just `--java-out`")
val output: String = djinni(s"--idl src/it/resources/all_datatypes.djinni --java-out $outputPath")
Then("the generator should successfully generate just java output")
output should equal ("Parsing...\nResolving...\nGenerating...\n")
assertFileExists(s"$outputPath/AllDatatypes.java")
}

it("should be able to only generate Obj-C output") {
val outputPath = "src/it/resources/result/only_objc_out"
When("calling the generator with just `--objc-out`")
val output = djinni(s"--idl src/it/resources/all_datatypes.djinni --objc-out $outputPath")
Then("the generator should successfully generate just objc output")
output should equal ("Parsing...\nResolving...\nGenerating...\n")
assertFileExists(s"$outputPath/AllDatatypes.h")
assertFileExists(s"$outputPath/AllDatatypes.mm")
}

it("should be able to only generate C++ output") {
val outputPath = "src/it/resources/result/only_cpp_out"
When("calling the generator with just `--cpp-out`")
val output = djinni(s"--idl src/it/resources/all_datatypes.djinni --cpp-out $outputPath")
Then("the generator should successfully generate just cpp output")
output should equal ("Parsing...\nResolving...\nGenerating...\n")
assertFileExists(s"$outputPath/all_datatypes.hpp")
}
}
}
6 changes: 5 additions & 1 deletion src/it/scala/djinni/IntegrationTest.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package djinni

import org.scalatest.FunSpec
import org.scalatest.Matchers.{convertToAnyShouldWrapper, equal}
import org.scalatest.Matchers.{be, convertToAnyShouldWrapper, equal, noException}

import scala.io.Source
import scala.sys.process._
Expand Down Expand Up @@ -70,4 +70,8 @@ class IntegrationTest extends FunSpec {
}
}

def assertFileExists(filename: String): Unit = {
noException should be thrownBy Source.fromFile(filename)
}

}

0 comments on commit 1fae663

Please sign in to comment.