Skip to content

Commit

Permalink
Merge pull request #1569 from tweag/run-tests
Browse files Browse the repository at this point in the history
Test `bazel test //...` in all configurations
  • Loading branch information
aherrmann authored Jul 19, 2021
2 parents 7abaefd + a1d53cb commit e65211d
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 10 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
./tests/run-start-script.sh --use-nix
bazel build //tests:run-tests
./bazel-ci-bin/tests/run-tests
bazel coverage //tests/...
bazel coverage //...
bazel build //docs:api_html
bazel build //docs:guide_html
'
Expand Down Expand Up @@ -141,7 +141,12 @@ jobs:
export PATH=$HOME/bazel:$PATH
[[ ${{ matrix.os }} == macos ]] && export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
./tests/run-start-script.sh --use-bindists
bazel test //tests/...
if [[ ${{ matrix.os }} == windows ]]; then
# On Windows `//...` expands to `/...`.
bazel test ///...
else
bazel test //...
fi
# Test stack_snapshot pinning
# NOTE keep in sync with tests/RunTests.hs
bazel run @stackage-pinning-test-unpinned//:pin
Expand Down
7 changes: 5 additions & 2 deletions debug/linking_utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ if res != {}:
pprint.pprint(res)
exit(1)
''',
# it only works on linux
tags = ["dont_test_on_darwin"],
# it only works on linux with nixpkgs
tags = [
"dont_test_on_darwin",
"requires_nix",
],
)
12 changes: 12 additions & 0 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ libraries = [
input = "//haskell:%s.bzl" % lib,
provider_template = ":templates/metadata/provider.vm",
rule_template = ":templates/metadata/rule.vm",
tags = ["dont_test_on_windows"],
deps = ["//haskell"],
),
# Generate markdown API documentation.
Expand All @@ -58,6 +59,7 @@ libraries = [
input = "//haskell:%s.bzl" % lib,
provider_template = ":templates/markdown/provider.vm",
rule_template = ":templates/markdown/rule.vm",
tags = ["dont_test_on_windows"],
deps = ["//haskell"],
),
# Convert markdown to html.
Expand All @@ -82,6 +84,7 @@ $(execpath //docs/pandoc) \
-o $(OUTS) \
$(execpath :{}_md)
""".format(lib),
tags = ["dont_test_on_windows"],
toolchains = [":set_site_end_location"],
tools = ["//docs/pandoc"],
),
Expand All @@ -102,6 +105,7 @@ for file in $(SRCS); do
cat $$file >>$(OUTS)
done
""",
tags = ["dont_test_on_windows"],
)

# Generate top-level API documentation navigation sidebar.
Expand All @@ -124,6 +128,7 @@ $(execpath //docs/pandoc) \
--metadata-file=$(execpath :metadata) \
<<<""
""",
tags = ["dont_test_on_windows"],
toolchains = [":set_site_end_location"],
tools = ["//docs/pandoc"],
)
Expand Down Expand Up @@ -165,6 +170,7 @@ $(execpath //docs/pandoc) \
--metadata-file=$(execpath :metadata) \
index_body.html
""",
tags = ["dont_test_on_windows"],
toolchains = [":set_site_end_location"],
tools = ["//docs/pandoc"],
)
Expand All @@ -190,6 +196,7 @@ $(location @bazel_tools//tools/zip:zipper) c $@ %s
":index_html",
] + [":%s_html" % lib for lib in libraries]
]),
tags = ["dont_test_on_windows"],
tools = ["@bazel_tools//tools/zip:zipper"],
)

Expand All @@ -199,6 +206,7 @@ py_binary(
srcs = ["serve.py"],
args = ["$(rootpath :api_html)"],
data = [":api_html"],
tags = ["dont_test_on_windows"],
)

genrule(
Expand All @@ -220,6 +228,10 @@ genrule(
(cd $$builddir/html && zip -q -r $$CWD/$@ .)
rm -rf $$builddir
""",
tags = [
"dont_test_on_windows",
"requires_nix",
],
tools = [
"@graphviz//:bin",
"@sphinx//:bin",
Expand Down
1 change: 1 addition & 0 deletions docs/pandoc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ toolchain_type(

pandoc(
name = "pandoc",
tags = ["dont_test_on_windows"],
visibility = ["//visibility:public"],
)

Expand Down
1 change: 1 addition & 0 deletions rule_info/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ proto_library(

haskell_proto_library(
name = "rule_info_haskell_proto",
tags = ["requires_dynamic"],
visibility = ["//visibility:public"],
deps = [":rule_info_proto"],
)
4 changes: 2 additions & 2 deletions tests/RunTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ main = hspec $ do
assertSuccess (bazel ["run", "//:buildifier"])

it "bazel test" $ do
assertSuccess (bazel ["test", "//...", "--build_tests_only"])
assertSuccess (bazel ["test", "//..."])

it "bazel test prof" $ do
-- In .github/workflows/workflow.yaml we specify --test_tag_filters
Expand All @@ -31,7 +31,7 @@ main = hspec $ do
-- we have to duplicate that filter here.
let tagFilter | os == "darwin" = "-dont_test_on_darwin,-requires_dynamic,-skip_profiling"
| otherwise = "-requires_dynamic,-skip_profiling"
assertSuccess (bazel ["test", "-c", "dbg", "//...", "--build_tests_only", "--test_tag_filters", tagFilter])
assertSuccess (bazel ["test", "-c", "dbg", "//...", "--build_tag_filters", tagFilter, "--test_tag_filters", tagFilter])

it "bazel build worker" $ do
assertSuccess (bazel ["build", "//tools/worker:bin"])
Expand Down
1 change: 1 addition & 0 deletions tests/haddock-with-plugin/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ haskell_library(
name = "library",
srcs = ["Lib.hs"],
plugins = [":plugin"],
tags = ["skip_profiling"],
deps = ["//tests/hackage:base"],
)

Expand Down
4 changes: 4 additions & 0 deletions tests/haddock/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ haskell_library(
"header.h",
],
compiler_flags = ["-I."],
tags = ["requires_dynamic"],
deps = [
":haddock-lib-deep",
"//tests/hackage:base",
Expand All @@ -44,6 +45,7 @@ haskell_library(
# This is missing on darwin with bindist due to
# https://github.com/tweag/rules_haskell/issues/1317.
"dont_test_on_darwin_with_bindist",
"requires_dynamic",
],
deps = [
":haddock-lib-a",
Expand All @@ -59,6 +61,7 @@ haskell_doc(
tags = [
"dont_test_on_darwin_with_bindist",
"dont_test_on_windows",
"requires_dynamic",
],
deps = [":haddock-lib-b"],
)
Expand All @@ -83,6 +86,7 @@ haskell_doc(
tags = [
"dont_test_on_darwin_with_bindist",
"dont_test_on_windows",
"requires_dynamic",
],
deps = [":haddock-lib-b"],
)
Expand Down
12 changes: 10 additions & 2 deletions tests/haddock_protobuf/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ proto_library(

haskell_proto_library(
name = "hello_world_haskell_proto",
tags = ["requires_dynamic"],
deps = [
":hello_world_proto",
],
Expand All @@ -21,6 +22,7 @@ haskell_proto_library(
haskell_library(
name = "hello_world_haskell",
srcs = ["HelloWorld.hs"], # Just imports the proto and does something trivial
tags = ["requires_dynamic"],
deps = [
":hello_world_haskell_proto",
"@stackage//:base",
Expand All @@ -30,7 +32,10 @@ haskell_library(
# Haddocks version A: depend on just the haskell_library
haskell_doc(
name = "haddocks_a",
tags = ["dont_test_on_windows"],
tags = [
"dont_test_on_windows",
"requires_dynamic",
],
deps = [
":hello_world_haskell",
],
Expand All @@ -39,7 +44,10 @@ haskell_doc(
# Haddocks version B: depend on both haskell_library and haskell_proto_library
haskell_doc(
name = "haddocks_b",
tags = ["dont_test_on_windows"],
tags = [
"dont_test_on_windows",
"requires_dynamic",
],
deps = [
":hello_world_haskell",
":hello_world_haskell_proto",
Expand Down
2 changes: 2 additions & 0 deletions tests/haskell_doctest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ haskell_doctest(
haskell_doctest(
name = "doctest-lib-all-success",
doctest_flags = ["-DMAGIC_DOCTEST_THING"],
tags = ["requires_dynamic"],
visibility = ["//visibility:public"],
deps = [":lib-b"],
)
Expand All @@ -58,6 +59,7 @@ haskell_test(

haskell_doctest(
name = "doctest-bin",
tags = ["requires_dynamic"],
visibility = ["//visibility:public"],
deps = [":bin"],
)
9 changes: 8 additions & 1 deletion tests/haskell_proto_library/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,26 @@ proto_library(

haskell_proto_library(
name = "address_haskell_proto",
tags = ["requires_dynamic"],
deps = [":address_proto"],
)

haskell_proto_library(
name = "stripped_address_haskell_proto",
tags = ["requires_dynamic"],
deps = [":stripped_address_proto"],
)

haskell_proto_library(
name = "person_haskell_proto",
tags = ["requires_dynamic"],
deps = [":person_proto"],
)

haskell_library(
name = "hs-lib",
srcs = ["Bar.hs"],
tags = ["requires_dynamic"],
visibility = ["//visibility:public"],
deps = [
":address_haskell_proto",
Expand All @@ -66,6 +70,9 @@ haskell_library(

haskell_doc(
name = "docs",
tags = ["dont_test_on_windows"],
tags = [
"dont_test_on_windows",
"requires_dynamic",
],
deps = [":hs-lib"],
)
2 changes: 2 additions & 0 deletions tests/haskell_proto_simple/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ haskell_proto_library(
tags = [
# Requires proto-lens >=0.6.0.0. On Windows we're stuck on 0.5.1.0 until we can update GHC.
"dont_test_on_windows",
"requires_dynamic",
],
deps = [
":foo",
Expand All @@ -31,6 +32,7 @@ haskell_library(
srcs = ["Bar.hs"],
tags = [
"dont_test_on_windows",
"requires_dynamic",
],
visibility = ["//visibility:public"],
deps = [
Expand Down
2 changes: 2 additions & 0 deletions tests/library-deps/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package(default_testonly = 1)
haskell_library(
name = "library-deps",
srcs = ["TestLib.hs"],
tags = ["requires_dynamic"],
visibility = ["//visibility:public"],
deps = [
"//tests/hackage:base",
Expand All @@ -20,6 +21,7 @@ haskell_test(
name = "bin-deps",
size = "small",
srcs = ["Bin.hs"],
tags = ["requires_dynamic"],
visibility = ["//visibility:public"],
deps = [
"//tests/hackage:base",
Expand Down
5 changes: 4 additions & 1 deletion tests/library-with-sysincludes/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ haskell_library(
"Lib.hs",
"TH.hs",
],
tags = ["requires_nix"],
tags = [
"requires_dynamic",
"requires_nix",
],
visibility = ["//visibility:public"],
deps = [
":intermediate-library",
Expand Down
2 changes: 2 additions & 0 deletions tools/worker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_binary")
haskell_cabal_binary(
name = "bin",
srcs = glob(["**"]),
# Requires more recent GHC version than we use on Windows.
tags = ["dont_test_on_windows"],
visibility = ["//visibility:public"],
deps = [
"@rules_haskell_worker_dependencies//:base",
Expand Down

0 comments on commit e65211d

Please sign in to comment.