diff options
author | Vincent Ambo <tazjin@google.com> | 2019-07-04T10·18+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2019-07-04T10·18+0100 |
commit | f723b8b878a3c4a4687b9e337a875500bebb39b1 (patch) | |
tree | e85204cf042c355e90cff61c111e7d8cd15df311 /third_party/bazel/rules_haskell/tests/BUILD.bazel | |
parent | 2eb1dc26e42ffbdc168f05ef744bd4b4f3e4c36f (diff) |
feat(third_party/bazel): Check in rules_haskell from Tweag r/17
Diffstat (limited to 'third_party/bazel/rules_haskell/tests/BUILD.bazel')
-rw-r--r-- | third_party/bazel/rules_haskell/tests/BUILD.bazel | 322 |
1 files changed, 322 insertions, 0 deletions
diff --git a/third_party/bazel/rules_haskell/tests/BUILD.bazel b/third_party/bazel/rules_haskell/tests/BUILD.bazel new file mode 100644 index 000000000000..276db5546332 --- /dev/null +++ b/third_party/bazel/rules_haskell/tests/BUILD.bazel @@ -0,0 +1,322 @@ +load(":inline_tests.bzl", "sh_inline_test") +load("@bazel_tools//tools/build_rules:test_rules.bzl", "rule_test") +load("//tests:rule_test_exe.bzl", "rule_test_exe") +load( + "@io_tweag_rules_haskell//haskell:c2hs.bzl", + "c2hs_toolchain", +) +load( + "@io_tweag_rules_haskell//haskell:haskell.bzl", + "haskell_binary", + "haskell_doctest_toolchain", + "haskell_proto_toolchain", + "haskell_test", + "haskell_toolchain", +) +load( + "//:constants.bzl", + "test_ghc_version", +) + +package(default_testonly = 1) + +haskell_doctest_toolchain( + name = "doctest-toolchain", + doctest = "@hackage-doctest//:bin", + tags = ["requires_doctest"], +) + +# This toolchain is morally testonly. However, that would break our +# tests of haskell_library_rules: aspects of non-testonly +# proto_library rules (from com_google_protobuf) can't themselves be +# testonly. + +haskell_proto_toolchain( + name = "protobuf-toolchain", + testonly = 0, + plugin = "@hackage-proto-lens-protoc//:bin/proto-lens-protoc", + protoc = "@com_google_protobuf//:protoc", + tags = ["requires_hackage"], + deps = [ + "//tests/hackage:base", + "//tests/hackage:bytestring", + "//tests/hackage:containers", + "//tests/hackage:deepseq", + "//tests/hackage:mtl", + "//tests/hackage:text", + "@hackage//:data-default-class", + "@hackage//:lens-family", + "@hackage//:lens-family-core", + "@hackage//:lens-labels", + "@hackage//:proto-lens", + ], +) + +c2hs_toolchain( + name = "c2hs-toolchain", + c2hs = "@hackage-c2hs//:bin", + tags = ["requires_c2hs"], +) + +rule_test_exe( + name = "test-binary-simple", + size = "small", + generates = ["binary-simple"], + rule = "//tests/binary-simple", +) + +rule_test_exe( + name = "test-binary-custom-main", + size = "small", + generates = ["binary-custom-main"], + rule = "//tests/binary-custom-main", +) + +rule_test( + name = "test-binary-with-lib", + size = "small", + generates = ["binary-with-lib"], + rule = "//tests/binary-with-lib", +) + +rule_test( + name = "test-binary-with-prebuilt", + size = "small", + generates = ["binary-with-prebuilt"], + rule = "//tests/binary-with-prebuilt", + tags = ["requires_hackage"], +) + +rule_test( + name = "test-binary-with-main", + size = "small", + generates = ["binary-with-main"], + rule = "//tests/binary-with-main", +) + +rule_test( + name = "test-binary-with-sysdeps", + size = "small", + generates = ["binary-with-sysdeps"], + rule = "//tests/binary-with-sysdeps", + tags = ["requires_zlib"], +) + +sh_test( + name = "test-binary-with-data", + size = "small", + srcs = ["//tests/binary-with-data"], + args = ["$(location //tests/binary-with-data:bin1)"], + data = ["//tests/binary-with-data:bin1"], + tags = ["requires_hackage"], +) + +rule_test( + name = "test-library-deps", + size = "small", + generates = select({ + "@bazel_tools//src/conditions:darwin": [ + "libHStestsZSlibrary-depsZSlibrary-deps-ghc{}.dylib".format(test_ghc_version), + "libHStestsZSlibrary-depsZSlibrary-deps.a", + ], + "@bazel_tools//src/conditions:windows": [ + "libHStestsZSlibrary-depsZSlibrary-deps-ghc{}.dll".format(test_ghc_version), + "libHStestsZSlibrary-depsZSlibrary-deps.a", + ], + "//conditions:default": [ + "libHStestsZSlibrary-depsZSlibrary-deps-ghc{}.so".format(test_ghc_version), + "libHStestsZSlibrary-depsZSlibrary-deps.a", + ], + }), + rule = "//tests/library-deps", +) + +rule_test( + name = "test-hsc", + size = "small", + generates = ["hsc"], + rule = "//tests/hsc", +) + +rule_test( + name = "test-haddock", + size = "small", + generates = [ + "haddock/index", + "haddock/testsZShaddockZShaddock-lib-a", + "haddock/testsZShaddockZShaddock-lib-b", + "haddock/testsZShaddockZShaddock-lib-deep", + ], + rule = "//tests/haddock", + tags = ["requires_hackage"], +) + +rule_test( + name = "test-haskell_lint-library", + size = "small", + generates = [ + "lint-log-lib-b", + ], + rule = "//tests/haskell_lint:lint-lib-b", +) + +rule_test( + name = "test-haskell_lint-binary", + size = "small", + generates = [ + "lint-log-bin", + ], + rule = "//tests/haskell_lint:lint-bin", +) + +rule_test( + name = "test-haskell_doctest", + size = "small", + generates = [ + "doctest-log-doctest-lib-lib-b", + ], + rule = "//tests/haskell_doctest:doctest-lib", + tags = ["requires_doctest"], +) + +rule_test( + name = "test-haskell_test", + size = "small", + generates = ["haskell_test"], + rule = "//tests/haskell_test:haskell_test", +) + +rule_test( + name = "test-java_classpath", + size = "small", + generates = ["java_classpath"], + rule = "//tests/java_classpath", +) + +rule_test( + name = "test-cc_haskell_import-cc-link", + size = "small", + generates = ["cc-bin"], + rule = "//tests/cc_haskell_import:cc-bin", + tags = ["requires_threaded_rts"], +) + +sh_test( + name = "test-cc_haskell_import_python", + size = "small", + srcs = ["scripts/exec.sh"], + args = ["tests/cc_haskell_import/python_add_one"], + data = [ + "//tests/cc_haskell_import:python_add_one", + "@bazel_tools//tools/bash/runfiles", + ], + tags = ["requires_threaded_rts"], +) + +sh_inline_test( + name = "test-haskell_binary-with-link-flags", + size = "small", + args = ["$(location //tests/binary-with-link-flags:binary-with-link-flags)"], + data = ["//tests/binary-with-link-flags"], + script = """\ +set -e + +# Fails if executable was linked without -threaded flag. +$1 +RTS -N +""", +) + +rule_test( + name = "test-lhs", + size = "small", + generates = ["lhs-bin"], + rule = "//tests/lhs:lhs-bin", +) + +rule_test( + name = "test-hs-boot", + size = "small", + generates = ["hs-boot"], + rule = "//tests/hs-boot:hs-boot", +) + +rule_test( + name = "test-textual-hdrs", + size = "small", + generates = ["textual-hdrs"], + rule = "//tests/textual-hdrs:textual-hdrs", +) + +rule_test( + name = "test-two-libs", + size = "small", + generates = ["two-libs"], + rule = "//tests/two-libs:two-libs", +) + +genrule( + name = "run-bin-with-lib", + outs = ["dummy"], + cmd = """sh -c ' + set -e + $(location //tests/binary-with-lib:binary-with-lib) + touch $(location dummy) +'""", + tools = ["//tests/binary-with-lib"], +) + +rule_test( + name = "test-run-bin-with-lib", + size = "small", + generates = ["dummy"], + rule = "//tests:run-bin-with-lib", +) + +genrule( + name = "run-bin-with-lib-dynamic", + outs = ["dyn-dummy"], + cmd = """sh -c ' + set -e + $(location //tests/binary-with-lib-dynamic:binary-with-lib-dynamic) + touch $(location dyn-dummy) +'""", + tools = ["//tests/binary-with-lib-dynamic"], +) + +rule_test( + name = "test-run-bin-with-lib-dynamic", + size = "small", + generates = ["dyn-dummy"], + rule = "//tests:run-bin-with-lib-dynamic", +) + +genrule( + name = "run-bin-with-c-lib", + outs = ["c-dummy"], + cmd = """sh -c ' + set -e + $(location //tests/c-compiles) + touch $(location c-dummy) +'""", + tools = ["//tests/c-compiles"], +) + +rule_test( + name = "test-run-bin-with-c-lib", + size = "small", + generates = ["c-dummy"], + rule = "//tests:run-bin-with-c-lib", +) + +# This is the test runner +haskell_binary( + name = "run-tests", + srcs = ["RunTests.hs"], + tags = ["requires_hackage"], + deps = [ + "//tests/hackage:base", + "//tests/hackage:process", + "@hackage//:hspec", + "@hackage//:hspec-core", + ], +) |