Skip to content

Commit

Permalink
Merge pull request #378 from rabbitmq/dialyze-test-suites
Browse files Browse the repository at this point in the history
Dialyze test suites in bazel
  • Loading branch information
michaelklishin committed Jun 8, 2023
2 parents 471e215 + 394ebaa commit 76f1144
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 8 deletions.
54 changes: 47 additions & 7 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@rules_erlang//:erlang_app.bzl", "erlang_app", "test_erlang_app")
load("@rules_erlang//:xref.bzl", "xref")
load("@rules_erlang//:dialyze.bzl", "DEFAULT_PLT_APPS", "dialyze", "plt")
load("@rules_erlang//:eunit2.bzl", "eunit")
load(":ra.bzl", "ra_suites")

NAME = "ra"
Expand Down Expand Up @@ -35,15 +36,17 @@ test_erlang_app(

xref()

PLT_APPS = DEFAULT_PLT_APPS + [
"compiler",
"tools",
"runtime_tools",
"mnesia",
"eunit",
]

plt(
name = "deps_plt",
apps = DEFAULT_PLT_APPS + [
"compiler",
"tools",
"runtime_tools",
"mnesia",
"eunit",
],
apps = PLT_APPS,
for_target = ":erlang_app",
)

Expand All @@ -52,4 +55,41 @@ dialyze(
plt = ":deps_plt",
)

plt(
name = "test_deps_plt",
apps = PLT_APPS + [
"common_test",
],
for_target = ":test_erlang_app",
deps = [
"@meck//:erlang_app",
"@proper//:erlang_app",
],
)

dialyze(
name = "dialyze_tests",
size = "small",
beam = [
f.replace("test/", "").replace(".erl", "_beam_files")
for f in glob(["test/*_SUITE.erl"])
] + [
":test_helpers",
],
plt = ":test_deps_plt",
tags = ["manual"],
)

eunit(
name = "eunit",
eunit_opts = [
"no_tty",
"{report, {eunit_progress, [colored, profile]}}",
],
target = ":test_erlang_app",
deps = [
"@eunit_formatters//:erlang_app",
],
)

ra_suites()
19 changes: 18 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module(

bazel_dep(
name = "rules_erlang",
version = "3.10.2",
version = "3.10.5",
)

erlang_config = use_extension(
Expand Down Expand Up @@ -84,3 +84,20 @@ use_repo(
"proper",
"seshat",
)

erlang_dev_package = use_extension(
"@rules_erlang//bzlmod:extensions.bzl",
"erlang_package",
dev_dependency = True,
)

erlang_package.hex_package(
name = "eunit_formatters",
version = "0.5.0",
build_file = "@ra//bzl:BUILD.eunit_formatters",
)

use_repo(
erlang_dev_package,
"eunit_formatters",
)
Empty file added bzl/BUILD.bazel
Empty file.
10 changes: 10 additions & 0 deletions bzl/BUILD.eunit_formatters
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
load("@rules_erlang//:erlang_app.bzl", "DEFAULT_ERLC_OPTS", "erlang_app")

erlang_app(
testonly = True,
app_name = "eunit_formatters",
app_version = "0.5.0",
erlc_opts = DEFAULT_ERLC_OPTS + [
"-Dnamespaced_dicts",
],
)
1 change: 1 addition & 0 deletions ra.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def ra_suites():

erlang_bytecode(
name = "test_helpers",
erlc_opts = TEST_ERLC_OPTS,
srcs = helpers,
hdrs = hdrs,
deps = [
Expand Down

0 comments on commit 76f1144

Please sign in to comment.