Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move all damlc tests to compiler/damlc/tests #2057

Merged
merged 1 commit into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,4 @@ daml-lf/project
daml-lf/gen
daml-lf/build.sbt
.markdown-preview.html
compiler/damlc/output
228 changes: 0 additions & 228 deletions compiler/damlc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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",
],
)
18 changes: 5 additions & 13 deletions compiler/damlc/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion compiler/damlc/daml-doc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)

Expand Down
2 changes: 1 addition & 1 deletion compiler/damlc/daml-doc/test/DA/Daml/GHC/Damldoc/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion compiler/damlc/daml-ide-core/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)
Loading