Skip to content

Commit

Permalink
Fix tweag#236: allow files in "data" attributes.
Browse files Browse the repository at this point in the history
Also adds a test that the data file is passed transitively through runfiles.
  • Loading branch information
judah committed May 7, 2018
1 parent 80a0041 commit 103a1a4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions haskell/haskell.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ _haskell_common_attrs = {
),
"data": attr.label_list(
doc = "See [Bazel documentation](https://docs.bazel.build/versions/master/be/common-definitions.html#common.data).",
allow_files = True,
cfg = "data",
),
"compiler_flags": attr.string_list(
Expand Down
2 changes: 2 additions & 0 deletions tests/binary-with-data/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ haskell_binary(
main_file = "bin1.hs",
prebuilt_dependencies = ["base"],
visibility = ["//visibility:public"],
# Regular file input:
data = ["bin1-input"],
)

haskell_binary(
Expand Down
1 change: 1 addition & 0 deletions tests/binary-with-data/bin1-input
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
contents
8 changes: 7 additions & 1 deletion tests/binary-with-data/bin1.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
module Main where

main = return ()
import Control.Monad (unless)

main :: IO ()
main = do
contents <- readFile "tests/binary-with-data/bin1-input"
unless (contents == "contents\n")
$ error $ "Incorrect input; got " ++ show contents
3 changes: 3 additions & 0 deletions tests/binary-with-data/bin3.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int main() {
return 0;
}

0 comments on commit 103a1a4

Please sign in to comment.