mirror of
https://github.com/digital-asset/daml.git
synced 2024-11-05 03:56:26 +03:00
Move all damlc tests to compiler/damlc/tests (#2057)
I’ve also changed some of the names to be more sensible.
This commit is contained in:
parent
5c3620613b
commit
2371d173b1
1
.gitignore
vendored
1
.gitignore
vendored
@ -89,3 +89,4 @@ daml-lf/project
|
||||
daml-lf/gen
|
||||
daml-lf/build.sbt
|
||||
.markdown-preview.html
|
||||
compiler/damlc/output
|
@ -145,79 +145,6 @@ da_haskell_library(
|
||||
],
|
||||
)
|
||||
|
||||
# Tests for the lax CLI parser
|
||||
da_haskell_test(
|
||||
name = "damlc-cliparser-test",
|
||||
srcs = ["cli-tests/CliParser.hs"],
|
||||
hazel_deps = [
|
||||
"tasty",
|
||||
"base",
|
||||
"optparse-applicative",
|
||||
"tasty-hunit",
|
||||
],
|
||||
main_function = "Cli.main",
|
||||
src_strip_prefix = "tests",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
":damlc-lib",
|
||||
],
|
||||
)
|
||||
|
||||
# Tests for damlc visual
|
||||
da_haskell_test(
|
||||
name = "damlc-visual-test",
|
||||
srcs = ["cli-tests/DamlcVisual.hs"],
|
||||
data = [
|
||||
":cli-tests/visual/Basic.dot",
|
||||
":visual-test-daml.dar",
|
||||
],
|
||||
hazel_deps = [
|
||||
"tasty",
|
||||
"base",
|
||||
"extra",
|
||||
"filepath",
|
||||
"tasty-golden",
|
||||
],
|
||||
main_function = "VisualTest.main",
|
||||
src_strip_prefix = "tests",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
":damlc-lib",
|
||||
"//libs-haskell/bazel-runfiles",
|
||||
],
|
||||
)
|
||||
|
||||
# Test file used in damlc-visual-test
|
||||
daml_compile(
|
||||
name = "visual-test-daml",
|
||||
main_src = "cli-tests/visual/Basic.daml",
|
||||
)
|
||||
|
||||
# Tests for damlc test
|
||||
da_haskell_test(
|
||||
name = "damlc-test-test",
|
||||
srcs = ["cli-tests/DamlcTest.hs"],
|
||||
data = [
|
||||
"//compiler/damlc/pkg-db",
|
||||
"//compiler/scenario-service/server:scenario_service_jar",
|
||||
],
|
||||
hazel_deps = [
|
||||
"base",
|
||||
"extra",
|
||||
"tasty",
|
||||
"tasty-hunit",
|
||||
],
|
||||
main_function = "DamlcTest.main",
|
||||
src_strip_prefix = "tests",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
":damlc-lib",
|
||||
"//compiler/damlc/daml-opts:daml-opts-types",
|
||||
"//compiler/hie-core",
|
||||
"//libs-haskell/da-hs-base",
|
||||
],
|
||||
)
|
||||
|
||||
# Generating DAML stdlib docs.
|
||||
|
||||
filegroup(
|
||||
@ -264,158 +191,3 @@ genrule(
|
||||
tools = ["//compiler/damlc"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
load(
|
||||
":util.bzl",
|
||||
"daml_ghc_compile_test",
|
||||
"daml_ghc_integration_test",
|
||||
)
|
||||
load("@os_info//:os_info.bzl", "is_windows")
|
||||
|
||||
# Runs the tests with all non-dev DAML-LF versions
|
||||
daml_ghc_integration_test("daml-ghc-test-stable", "DA.Test.GHC.mainAll")
|
||||
|
||||
# Runs the tests with DAML-LF 1.dev
|
||||
daml_ghc_integration_test("daml-ghc-test-dev", "DA.Test.GHC.main")
|
||||
|
||||
da_haskell_test(
|
||||
name = "tasty-test",
|
||||
srcs = ["test-src/DA/Test/TastyMain.hs"],
|
||||
data = [
|
||||
":test-files",
|
||||
"//compiler/damlc/pkg-db",
|
||||
],
|
||||
hazel_deps = [
|
||||
"base",
|
||||
"tasty-hunit",
|
||||
"text",
|
||||
],
|
||||
main_function = "DA.Test.TastyMain.main",
|
||||
src_strip_prefix = "test-src",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//compiler/damlc:damlc-lib",
|
||||
"//compiler/damlc/daml-doc:daml-doc-testing",
|
||||
"//libs-haskell/da-hs-base",
|
||||
],
|
||||
)
|
||||
|
||||
da_haskell_test(
|
||||
name = "damlc-shake-tests",
|
||||
size = "large",
|
||||
# this test takes a while and often time out -- tell that to bazel
|
||||
timeout = "long",
|
||||
srcs = ["test-src/DA/Test/ShakeIdeClient.hs"],
|
||||
data = [
|
||||
"//compiler/damlc/pkg-db",
|
||||
"//compiler/scenario-service/server:scenario_service_jar",
|
||||
],
|
||||
hazel_deps = [
|
||||
"base",
|
||||
"directory",
|
||||
"tasty-hunit",
|
||||
"text",
|
||||
],
|
||||
main_function = "DA.Test.ShakeIdeClient.main",
|
||||
src_strip_prefix = "test-src",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//compiler/damlc/daml-compiler",
|
||||
"//compiler/damlc/daml-ide-core",
|
||||
"//compiler/damlc/daml-ide-core:ide-testing",
|
||||
"//compiler/hie-core",
|
||||
"//libs-haskell/da-hs-base",
|
||||
],
|
||||
)
|
||||
|
||||
da_haskell_binary(
|
||||
name = "generate-module-tree",
|
||||
srcs = ["test-src/DA/Test/GenerateModuleTree.hs"],
|
||||
hazel_deps = [
|
||||
"base",
|
||||
"filepath",
|
||||
],
|
||||
main_function = "DA.Test.GenerateModuleTree.main",
|
||||
src_strip_prefix = "test-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"],
|
||||
)
|
||||
|
||||
daml_ghc_compile_test(
|
||||
name = "module-tree-memory",
|
||||
srcs = [":module-tree-test"],
|
||||
main = "FatTree18.daml",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
daml_ghc_compile_test(
|
||||
name = "compile-subdir",
|
||||
srcs = [":test-files"],
|
||||
main = "test-files/Subdir/Examples.daml",
|
||||
)
|
||||
|
||||
daml_ghc_compile_test(
|
||||
name = "compile-empty",
|
||||
srcs = [":test-files"],
|
||||
main = "test-files/Empty.daml",
|
||||
)
|
||||
|
||||
daml_ghc_compile_test(
|
||||
name = "examples-memory",
|
||||
srcs = [":test-files"],
|
||||
heap_limit = "200M",
|
||||
main = "test-files/Examples.daml",
|
||||
stack_limit = "230K",
|
||||
)
|
||||
|
||||
daml_ghc_compile_test(
|
||||
name = "bond-trading-memory",
|
||||
srcs = [":bond-trading"],
|
||||
heap_limit = "200M" if is_windows else "100M",
|
||||
main = "bond-trading/Test.daml",
|
||||
stack_limit = "35K",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "test-files",
|
||||
srcs = glob(["test-files/**"]),
|
||||
visibility = [
|
||||
"__pkg__",
|
||||
"//daml-foundations/integration-tests:__pkg__",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "bond-trading",
|
||||
srcs = glob(["bond-trading/**"]),
|
||||
visibility = [
|
||||
"__pkg__",
|
||||
"//daml-foundations/integration-tests:__pkg__",
|
||||
],
|
||||
)
|
||||
|
||||
# Check that DAML compilation is deterministic.
|
||||
sh_test(
|
||||
name = "daml-ghc-deterministic",
|
||||
srcs = ["test-files/daml-ghc-deterministic.sh"],
|
||||
args = [
|
||||
"$(location //compiler/damlc)",
|
||||
"$(location @com_google_protobuf//:protoc)",
|
||||
],
|
||||
data = [
|
||||
":test-files",
|
||||
"//compiler/damlc",
|
||||
"//compiler/damlc/pkg-db",
|
||||
"@com_google_protobuf//:protoc",
|
||||
],
|
||||
deps = [
|
||||
"@bazel_tools//tools/bash/runfiles",
|
||||
],
|
||||
)
|
||||
|
@ -1,31 +1,23 @@
|
||||
## Developing
|
||||
|
||||
Before you start, build the IDE test suite. We fall back to this to
|
||||
find runfiles such as the scenario service and the package database
|
||||
when we’re running inside GHCi.
|
||||
|
||||
```
|
||||
bazel build //compiler/damlc:damlc-shake-tests
|
||||
```
|
||||
|
||||
When working on the compiler:
|
||||
|
||||
```
|
||||
da-ghcid //compiler/damlc:daml-ghc-test-dev --reload=compiler/damlc/test-files --test=":main --pattern="
|
||||
bazel run //compiler/damlc:daml-ghc-test-dev -- --pattern=
|
||||
da-ghcid //compiler/damlc/tests:integration-dev --reload=compiler/damlc/tests/daml-test-files --test=":main --pattern="
|
||||
bazel run //compiler/damlc/tests:integration-dev -- --pattern=
|
||||
bazel run damlc -- compile $PWD/MyDaml12File.daml
|
||||
```
|
||||
|
||||
When working on the IDE via the test suite:
|
||||
|
||||
```
|
||||
bazel run //compiler/damlc:damlc-shake-tests -- --pattern=
|
||||
da-ghcid //compiler/damlc:damlc-shake-tests --test=":main --pattern="
|
||||
bazel run //compiler/damlc/tests:shake -- --pattern=
|
||||
da-ghcid //compiler/damlc/tests:shake --test=":main --pattern="
|
||||
```
|
||||
|
||||
The above commands do not execute scenarios. To do that, use a command like
|
||||
```
|
||||
bazel run damlc test $PWD/compiler/damlc/bond-trading/Test.daml
|
||||
bazel run damlc test $PWD/compiler/damlc/tests/bond-trading/Test.daml
|
||||
```
|
||||
|
||||
At the moment, commands relying on ghc-pkg, e.g., `damlc build` do not
|
||||
|
@ -60,10 +60,10 @@ da_haskell_library(
|
||||
"//compiler/damlc/daml-doc",
|
||||
"//compiler/damlc/daml-opts",
|
||||
"//compiler/damlc/daml-opts:daml-opts-types",
|
||||
"//compiler/damlc/test-utils",
|
||||
"//compiler/hie-core",
|
||||
"//libs-haskell/bazel-runfiles",
|
||||
"//libs-haskell/da-hs-base",
|
||||
"//libs-haskell/test-utils",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -34,7 +34,7 @@ import Data.Maybe
|
||||
mkTestTree :: IO Tasty.TestTree
|
||||
mkTestTree = do
|
||||
|
||||
testDir <- locateRunfiles $ mainWorkspace </> "compiler/damlc/test-files"
|
||||
testDir <- locateRunfiles $ mainWorkspace </> "compiler/damlc/tests/daml-test-files"
|
||||
|
||||
let isExpectationFile filePath =
|
||||
".EXPECTED" == takeExtensions (dropExtension filePath)
|
||||
|
@ -79,7 +79,7 @@ da_haskell_library(
|
||||
"//compiler/damlc/daml-compiler",
|
||||
"//compiler/damlc/daml-opts",
|
||||
"//compiler/damlc/daml-opts:daml-opts-types",
|
||||
"//compiler/damlc/test-utils",
|
||||
"//compiler/hie-core",
|
||||
"//libs-haskell/test-utils",
|
||||
],
|
||||
)
|
||||
|
221
compiler/damlc/tests/BUILD.bazel
Normal file
221
compiler/damlc/tests/BUILD.bazel
Normal file
@ -0,0 +1,221 @@
|
||||
# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
load("//bazel_tools:haskell.bzl", "da_haskell_binary", "da_haskell_test")
|
||||
load("//rules_daml:daml.bzl", "daml_compile")
|
||||
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"],
|
||||
hazel_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 = "damlc-visual",
|
||||
srcs = ["src/DamlcVisual.hs"],
|
||||
data = [
|
||||
":visual-test-daml.dar",
|
||||
":visual/Basic.dot",
|
||||
],
|
||||
hazel_deps = [
|
||||
"tasty",
|
||||
"base",
|
||||
"extra",
|
||||
"filepath",
|
||||
"tasty-golden",
|
||||
],
|
||||
main_function = "VisualTest.main",
|
||||
src_strip_prefix = "tests",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//compiler/damlc:damlc-lib",
|
||||
"//libs-haskell/bazel-runfiles",
|
||||
],
|
||||
)
|
||||
|
||||
# Test file used in damlc-visual-test
|
||||
daml_compile(
|
||||
name = "visual-test-daml",
|
||||
main_src = "visual/Basic.daml",
|
||||
)
|
||||
|
||||
# Tests for damlc test
|
||||
da_haskell_test(
|
||||
name = "damlc-test",
|
||||
srcs = ["src/DamlcTest.hs"],
|
||||
data = [
|
||||
"//compiler/damlc/pkg-db",
|
||||
"//compiler/scenario-service/server:scenario_service_jar",
|
||||
],
|
||||
hazel_deps = [
|
||||
"base",
|
||||
"extra",
|
||||
"tasty",
|
||||
"tasty-hunit",
|
||||
],
|
||||
main_function = "DamlcTest.main",
|
||||
src_strip_prefix = "tests",
|
||||
visibility = ["//visibility:private"],
|
||||
deps = [
|
||||
"//compiler/damlc:damlc-lib",
|
||||
"//compiler/damlc/daml-opts:daml-opts-types",
|
||||
"//compiler/hie-core",
|
||||
"//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/TastyMain.hs"],
|
||||
data = [
|
||||
":daml-test-files",
|
||||
"//compiler/damlc/pkg-db",
|
||||
],
|
||||
hazel_deps = [
|
||||
"base",
|
||||
"tasty-hunit",
|
||||
"text",
|
||||
],
|
||||
main_function = "DA.Test.TastyMain.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",
|
||||
],
|
||||
)
|
||||
|
||||
# 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/scenario-service/server:scenario_service_jar",
|
||||
],
|
||||
hazel_deps = [
|
||||
"base",
|
||||
"directory",
|
||||
"tasty-hunit",
|
||||
"text",
|
||||
],
|
||||
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/hie-core",
|
||||
"//libs-haskell/da-hs-base",
|
||||
],
|
||||
)
|
||||
|
||||
# Memory tests
|
||||
|
||||
da_haskell_binary(
|
||||
name = "generate-module-tree",
|
||||
srcs = ["src/DA/Test/GenerateModuleTree.hs"],
|
||||
hazel_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 = "35K",
|
||||
)
|
||||
|
||||
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__",
|
||||
],
|
||||
)
|
||||
|
||||
# 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)",
|
||||
],
|
||||
data = [
|
||||
":daml-test-files",
|
||||
"//compiler/damlc",
|
||||
"//compiler/damlc/pkg-db",
|
||||
"@com_google_protobuf//:protoc",
|
||||
],
|
||||
deps = [
|
||||
"@bazel_tools//tools/bash/runfiles",
|
||||
],
|
||||
)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user