Skip to content

Commit cf6beb4

Browse files
authored
Merge pull request #1300 from tweag/haddock_data
Set runfiles attribute in haskell_doc
2 parents 55b539c + a4190b1 commit cf6beb4

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

haskell/haddock.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,10 @@ def _haskell_doc_rule_impl(ctx):
321321
arguments = [args],
322322
)
323323

324+
files = html_dict_copied.values() + [index_root]
324325
return [DefaultInfo(
325-
files = depset(html_dict_copied.values() + [index_root]),
326+
files = depset(files),
327+
runfiles = ctx.runfiles(files),
326328
)]
327329

328330
haskell_doc = rule(

tests/haddock/BUILD.bazel

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,32 @@ haskell_doc(
5656
deps = [":haddock-lib-b"],
5757
)
5858

59+
sh_test(
60+
name = "data-dependency",
61+
srcs = ["data_dependency.sh"],
62+
args = ["$(rootpaths :haddock)"],
63+
data = [":haddock"],
64+
tags = [
65+
# Fails in profiling mode due to missing haddocks for Deep.
66+
"requires_dynamic",
67+
],
68+
deps = ["@bazel_tools//tools/bash/runfiles"],
69+
)
70+
5971
haskell_doc(
6072
name = "haddock-transitive",
6173
index_transitive_deps = True,
6274
deps = [":haddock-lib-b"],
6375
)
76+
77+
sh_test(
78+
name = "data-dependency-transitive",
79+
srcs = ["data_dependency.sh"],
80+
args = ["$(rootpaths :haddock-transitive)"],
81+
data = [":haddock-transitive"],
82+
tags = [
83+
# Fails in profiling mode due to missing haddocks for Deep.
84+
"requires_dynamic",
85+
],
86+
deps = ["@bazel_tools//tools/bash/runfiles"],
87+
)

tests/haddock/data_dependency.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copy-pasted from the Bazel Bash runfiles library v2.
2+
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
3+
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
4+
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
5+
source "$0.runfiles/$f" 2>/dev/null || \
6+
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
7+
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
8+
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
9+
# --- end runfiles.bash initialization v2 ---
10+
11+
set -euo pipefail
12+
fail=
13+
for data in "$@"; do
14+
if [[ ! -e "$(rlocation "$TEST_WORKSPACE/$data")" ]]; then
15+
echo "missing data dependency: $data" >&2
16+
fail=1
17+
fi
18+
done
19+
exit $fail

0 commit comments

Comments
 (0)