daml/compiler/damlc/tests/BUILD.bazel
Moritz Kiefer 0201055f80
Move damlc test tests out of packaging tests (#4332)
The packaging tests are already one of our slowest test suites and
damlc test takes quite a while since it has to spin up the scenario
service.

We already have tests for damlc tests so this PR moves the tests from
the packaging test suite that are specific to `damlc test` to those
tests which should balance things a bit better.

changelog_begin
changelog_end
2020-01-31 18:39:43 +01:00

410 lines
9.8 KiB
Python

# Copyright (c) 2020 The DAML Authors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load("//bazel_tools:haskell.bzl", "da_haskell_binary", "da_haskell_test")
load("@os_info//:os_info.bzl", "is_windows")
load(":util.bzl", "damlc_compile_test", "damlc_integration_test")
# Tests for the lax CLI parser
da_haskell_test(
name = "damlc-cliparser",
srcs = ["src/CliParser.hs"],
hackage_deps = [
"tasty",
"base",
"optparse-applicative",
"tasty-hunit",
],
main_function = "Cli.main",
src_strip_prefix = "tests",
visibility = ["//visibility:private"],
deps = [
"//compiler/damlc:damlc-lib",
],
)
# Tests for damlc visual
da_haskell_test(
name = "daml-lf-reader",
srcs = ["src/DarReaderTest.hs"],
hackage_deps = [
"base",
"bytestring",
"tasty",
"tasty-hunit",
],
main_function = "DarReaderTest.main",
src_strip_prefix = "tests",
visibility = ["//visibility:private"],
deps = [
"//compiler/daml-lf-reader",
],
)
# Tests for damlc test
da_haskell_test(
name = "damlc-test",
srcs = ["src/DamlcTest.hs"],
data = [
"//compiler/damlc",
],
hackage_deps = [
"base",
"directory",
"extra",
"filepath",
"process",
"tasty",
"tasty-hunit",
],
main_function = "DamlcTest.main",
src_strip_prefix = "tests",
visibility = ["//visibility:private"],
deps = [
"//:sdk-version-hs-lib",
"//compiler/damlc:damlc-lib",
"//compiler/damlc/daml-opts:daml-opts-types",
"//libs-haskell/bazel-runfiles",
"//libs-haskell/da-hs-base",
],
)
# Integration tests for all non-dev DAML-LF versions
damlc_integration_test("integration-stable", "DA.Test.DamlcIntegration.mainAll")
# Integration tests for DAML-LF 1.dev
damlc_integration_test("integration-dev", "DA.Test.DamlcIntegration.main")
# Tests for daml-doc
da_haskell_test(
name = "daml-doc",
srcs = ["src/DA/Test/DamlDoc.hs"],
data = [
":daml-test-files",
"//compiler/damlc/pkg-db",
],
hackage_deps = [
"base",
"tasty-hunit",
"text",
],
main_function = "DA.Test.DamlDoc.main",
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
"//compiler/damlc:damlc-lib",
"//compiler/damlc/daml-doc:daml-doc-testing",
"//libs-haskell/da-hs-base",
],
)
# Unit tests for daml-doctest
da_haskell_test(
name = "daml-doctest",
srcs = ["src/DA/Test/DamlDocTest.hs"],
data = ["//compiler/damlc/pkg-db"],
hackage_deps = [
"base",
"data-default",
"extra",
"ghcide",
"haskell-lsp-types",
"tasty",
"tasty-hunit",
"text",
],
main_function = "DA.Test.DamlDocTest.main",
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
"//compiler/damlc:damlc-lib",
"//compiler/damlc/daml-doctest",
"//compiler/damlc/daml-opts",
"//compiler/damlc/daml-opts:daml-opts-types",
"//libs-haskell/da-hs-base",
],
)
# Integration test for damlc doctest
da_haskell_test(
name = "daml-doctest-integration",
srcs = ["src/DA/Test/DamlDocTestIntegration.hs"],
data = ["//compiler/damlc"],
hackage_deps = [
"base",
"extra",
"filepath",
"process",
"tasty",
"tasty-hunit",
],
main_function = "DA.Test.DamlDocTestIntegration.main",
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
"//libs-haskell/bazel-runfiles",
],
)
# Tests of damlc at the Shake API layer
da_haskell_test(
name = "shake",
size = "large",
# this test takes a while and often time out -- tell that to bazel
timeout = "long",
srcs = ["src/DA/Test/ShakeIdeClient.hs"],
data = [
"//compiler/damlc/pkg-db",
"//compiler/damlc/stable-packages",
"//compiler/scenario-service/server:scenario_service_jar",
],
hackage_deps = [
"base",
"directory",
"ghcide",
"tasty-hunit",
"text",
"containers",
],
main_function = "DA.Test.ShakeIdeClient.main",
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
"//compiler/damlc/daml-compiler",
"//compiler/damlc/daml-ide-core",
"//compiler/damlc/daml-ide-core:ide-testing",
"//compiler/damlc/daml-visual",
"//libs-haskell/da-hs-base",
],
)
# Tests for incremental builds
da_haskell_test(
name = "incremental",
srcs = ["src/DA/Test/IncrementalBuilds.hs"],
data = [
"//compiler/damlc",
"//daml-lf/repl",
],
hackage_deps = [
"base",
"containers",
"directory",
"extra",
"filepath",
"process",
"tasty",
"tasty-hunit",
],
main_function = "DA.Test.IncrementalBuilds.main",
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = ["//libs-haskell/bazel-runfiles"],
)
# Tests for packaging
da_haskell_test(
name = "packaging",
timeout = "long",
srcs = ["src/DA/Test/Packaging.hs"],
data = [
"//compiler/damlc",
"//compiler/damlc/tests:generate-simple-dalf",
"//daml-lf/repl",
"@davl//:released/davl-v3.dar",
],
# See https://github.com/digital-asset/daml/issues/4328
flaky = True,
hackage_deps = [
"base",
"bytestring",
"extra",
"filepath",
"process",
"safe-exceptions",
"tasty",
"tasty-hunit",
"zip-archive",
],
main_function = "DA.Test.Packaging.main",
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
"//:sdk-version-hs-lib",
"//compiler/daml-lf-ast",
"//compiler/daml-lf-proto",
"//compiler/daml-lf-reader",
"//libs-haskell/bazel-runfiles",
"//libs-haskell/da-hs-base",
],
)
# Memory tests
da_haskell_binary(
name = "generate-module-tree",
srcs = ["src/DA/Test/GenerateModuleTree.hs"],
hackage_deps = [
"base",
"filepath",
],
main_function = "DA.Test.GenerateModuleTree.main",
src_strip_prefix = "src",
deps = ["//libs-haskell/da-hs-base"],
)
genrule(
name = "module-tree-test",
outs = ["FatTree{i}.daml".format(i = i) for i in range(1, 19)],
cmd = "$(location :generate-module-tree) $(@D) 18",
tools = [":generate-module-tree"],
visibility = ["//visibility:public"],
)
damlc_compile_test(
name = "memory-module-tree",
srcs = [":module-tree-test"],
main = "FatTree18.daml",
visibility = ["//visibility:public"],
)
damlc_compile_test(
name = "memory-examples",
srcs = [":daml-test-files"],
heap_limit = "200M",
main = "daml-test-files/Examples.daml",
stack_limit = "230K",
)
damlc_compile_test(
name = "memory-bond-trading",
srcs = [":bond-trading"],
heap_limit = "200M" if is_windows else "100M",
main = "bond-trading/Test.daml",
stack_limit = "100K" if is_windows else "70K",
)
filegroup(
name = "daml-test-files",
srcs = glob(["daml-test-files/**"]),
visibility = [
"__pkg__",
"//daml-foundations/integration-tests:__pkg__",
],
)
filegroup(
name = "bond-trading",
srcs = glob(["bond-trading/**"]),
visibility = [
"__pkg__",
"//daml-foundations/integration-tests:__pkg__",
],
)
filegroup(
name = "query-lf-lib",
srcs = glob(["src/*.jq"]),
visibility = [
"__pkg__",
"//daml-foundations/integration-tests:__pkg__",
],
)
# Check that DAML compilation is deterministic.
sh_test(
name = "deterministic",
srcs = ["src/daml-ghc-deterministic.sh"],
args = [
"$(location //compiler/damlc)",
"$(location @com_google_protobuf//:protoc)",
"$(POSIX_DIFF)",
],
data = [
":daml-test-files",
"//compiler/damlc",
"//compiler/damlc/pkg-db",
"@com_google_protobuf//:protoc",
],
toolchains = [
"@rules_sh//sh/posix:make_variables",
],
deps = [
"@bazel_tools//tools/bash/runfiles",
],
)
sh_test(
name = "unstable-types",
srcs = ["src/unstable-types.sh"],
args = [
"$(location @jq_dev_env//:jq)",
"$(location :src/query-lf-interned.jq)",
"$(location //compiler/damlc/pkg-db)",
"$(location //compiler/damlc)",
"$(POSIX_DIFF)",
],
data = [
":src/query-lf-interned.jq",
"//compiler/damlc",
"//compiler/damlc/pkg-db",
"@jq_dev_env//:jq",
],
toolchains = [
"@rules_sh//sh/posix:make_variables",
],
deps = [
"@bazel_tools//tools/bash/runfiles",
],
)
sh_test(
name = "stable-packages",
srcs = ["src/stable-packages.sh"],
args = [
"$(location //compiler/damlc)",
"$(location //:VERSION)",
"$(POSIX_DIFF)",
],
data = [
"//:VERSION",
"//compiler/damlc",
],
toolchains = [
"@rules_sh//sh/posix:make_variables",
],
deps = [
"@bazel_tools//tools/bash/runfiles",
],
)
# Generate a simple DALF for plain DALF import testing
genrule(
name = "simple-dalf",
outs = ["simple-dalf.dalf"],
cmd = "$(location :generate-simple-dalf) $@",
tools = [":generate-simple-dalf"],
visibility = ["//visibility:public"],
)
da_haskell_binary(
name = "generate-simple-dalf",
srcs = ["src/DA/Test/GenerateSimpleDalf.hs"],
hackage_deps = [
"base",
"bytestring",
"text",
],
main_function = "DA.Test.GenerateSimpleDalf.main",
src_strip_prefix = "src",
visibility = ["//visibility:public"],
deps = [
"//compiler/daml-lf-ast",
"//compiler/daml-lf-proto",
"//compiler/daml-lf-tools",
"//libs-haskell/da-hs-base",
],
)