Skip to content

Commit

Permalink
Fix linting of ‘haskell_binary’ targets
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkkrp committed Mar 28, 2018
1 parent ab61de7 commit 64f9d86
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion haskell/lint.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _haskell_lint_aspect_impl(target, ctx):

# Expose all bazel dependencies
for package in set.to_list(build_info.package_names):
if lib_info != None or package != lib_info.package_name:
if lib_info == None or package != lib_info.package_name:
args.add(["-package", package])

for cache in set.to_list(build_info.package_caches):
Expand Down
14 changes: 12 additions & 2 deletions tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,22 @@ rule_test(
)

rule_test(
name = "test-haskell_lint",
name = "test-haskell_lint-library",
generates = [
"lint-log-lib-a-1.0.0",
"lint-log-lib-b-1.0.0",
],
rule = "//tests/haskell_lint:haskell_lint",
rule = "//tests/haskell_lint:lint-lib-b",
size = "small",
)

rule_test(
name = "test-haskell_lint-binary",
generates = [
"lint-log-lib-a-1.0.0",
"lint-log-bin-1.0.0",
],
rule = "//tests/haskell_lint:lint-bin",
size = "small",
)

Expand Down
23 changes: 17 additions & 6 deletions tests/haskell_lint/BUILD
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package(default_testonly = 1)

# XXX This package is for manual testing. I could not find a way to
# automatically test the fact that a rule must fail (must be not a very
# common use case for Bazel) and that files produced by a failing rule have
# certain contents.

load("@io_tweag_rules_haskell//haskell:haskell.bzl",
"haskell_library",
"haskell_binary",
"haskell_test",
"haskell_lint",
)

Expand All @@ -26,7 +23,21 @@ haskell_library(
)

haskell_lint(
name = "haskell_lint",
name = "lint-lib-b",
deps = [":lib-b"],
visibility = ["//visibility:public"],
)

haskell_binary(
name = "bin",
srcs = ["Main.hs"],
prebuilt_dependencies = ["base"],
deps = [":lib-a"],
visibility = ["//visibility:public"],
)

haskell_lint(
name = "lint-bin",
deps = [":bin"],
visibility = ["//visibility:public"],
)
6 changes: 6 additions & 0 deletions tests/haskell_lint/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Main (main) where

import Foo (foo)

main :: IO ()
main = print foo

0 comments on commit 64f9d86

Please sign in to comment.