diff --git a/elixir_app.bzl b/elixir_app.bzl index 33d8c26..dffd38f 100644 --- a/elixir_app.bzl +++ b/elixir_app.bzl @@ -50,6 +50,7 @@ def elixir_app( app_name = app_name, extra_apps = ["elixir"] + extra_apps, modules = [":beam_files"], + deps = deps, **kwargs ) diff --git a/test/app_deps/BUILD.bazel b/test/app_deps/BUILD.bazel new file mode 100644 index 0000000..0d08c62 --- /dev/null +++ b/test/app_deps/BUILD.bazel @@ -0,0 +1,16 @@ +load("@rules_elixir//:elixir_app.bzl", "elixir_app") +load("@rules_shell//shell:sh_test.bzl", "sh_test") + +elixir_app( + app_name = "main_app", + deps = ["//app_deps/dep:erlang_app"], +) + +# The .app file must list dep_app in applications, so OTP starts it first. +sh_test( + name = "app_file_lists_deps_test", + size = "small", + srcs = ["app_file_lists_deps_test.sh"], + args = ["$(rootpath :app_file)"], + data = [":app_file"], +) diff --git a/test/app_deps/app_file_lists_deps_test.sh b/test/app_deps/app_file_lists_deps_test.sh new file mode 100755 index 0000000..679e297 --- /dev/null +++ b/test/app_deps/app_file_lists_deps_test.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +set -euo pipefail + +app_file="$1" +cat "$app_file" +applications=$(tr -d '\n' < "$app_file" | grep -o '{applications, *\[[^]]*\]}') +echo "$applications" +for app in kernel stdlib elixir dep_app; do + if ! grep -Eq "[[ ,]$app[],]" <<< "$applications"; then + echo "FAIL: $app is not in the applications list" >&2 + exit 1 + fi +done diff --git a/test/app_deps/dep/BUILD.bazel b/test/app_deps/dep/BUILD.bazel new file mode 100644 index 0000000..754101c --- /dev/null +++ b/test/app_deps/dep/BUILD.bazel @@ -0,0 +1,7 @@ +load("@rules_elixir//:elixir_app.bzl", "elixir_app") + +package(default_visibility = ["//app_deps:__pkg__"]) + +elixir_app( + app_name = "dep_app", +) diff --git a/test/app_deps/dep/lib/dep_app.ex b/test/app_deps/dep/lib/dep_app.ex new file mode 100644 index 0000000..845f32c --- /dev/null +++ b/test/app_deps/dep/lib/dep_app.ex @@ -0,0 +1,3 @@ +defmodule DepApp do + def hello, do: :world +end diff --git a/test/app_deps/lib/main_app.ex b/test/app_deps/lib/main_app.ex new file mode 100644 index 0000000..acb1b79 --- /dev/null +++ b/test/app_deps/lib/main_app.ex @@ -0,0 +1,3 @@ +defmodule MainApp do + def hello, do: DepApp.hello() +end