Remove hardcoded number of packages from Java codegen test (#4604)

This breaks everytime we change the number of packages in damlc which
is rather annoying.

changelog_begin
changelog_end
This commit is contained in:
Moritz Kiefer 2020-02-19 15:45:35 +01:00 committed by GitHub
parent f22ea41251
commit ff90ec643e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -77,6 +77,8 @@ da_scala_test(
deps = [
":lib",
"//bazel_tools/runfiles:scala_runfiles",
"//daml-lf/archive:daml_lf_archive_reader",
"//daml-lf/archive:daml_lf_dev_archive_java_proto",
"//daml-lf/data",
"//daml-lf/interface",
"//language-support/codegen-common",

View File

@ -7,6 +7,7 @@ import java.io.File
import java.nio.file.Files
import com.digitalasset.daml.bazeltools.BazelRunfiles
import com.digitalasset.daml.lf.archive.DarReader
import com.digitalasset.daml.lf.codegen.backend.java.JavaBackend
import com.digitalasset.daml.lf.codegen.conf.Conf
import org.scalatest.{FlatSpec, Matchers}
@ -19,6 +20,7 @@ class CodeGenRunnerTests extends FlatSpec with Matchers with BazelRunfiles {
def path(p: String) = new File(p).getAbsoluteFile.toPath
val testDar = path(rlocation("language-support/java/codegen/test-daml.dar"))
val dar = DarReader().readArchiveFromFile(testDar.toFile).get
val dummyOutputDir = Files.createTempDirectory("codegen")
@ -48,8 +50,8 @@ class CodeGenRunnerTests extends FlatSpec with Matchers with BazelRunfiles {
val (interfaces, pkgPrefixes) = CodeGenRunner.collectDamlLfInterfaces(conf)
assert(interfaces.map(_.packageId).length == 19)
assert(pkgPrefixes.size == 19)
assert(interfaces.map(_.packageId).length == dar.all.length)
assert(pkgPrefixes.size == dar.all.length)
assert(pkgPrefixes.values.forall(_ == "PREFIX"))
}
}