-
Notifications
You must be signed in to change notification settings - Fork 81
Validate hidden modules #1796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Validate hidden modules #1796
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
33c89ac
put in logic to validate hidden modules against src list and rexports
martyall ae37a87
buildifier
martyall 3de941a
don't worry about the reexport case, but handle the case provided by …
martyall 24f51c4
add expect failure test in case of haskell libraries that declare non…
martyall b69a156
write out separate test using the haskell modules rule
martyall afe8897
formatting
martyall 552ea05
Merge branch 'master' into validate-hidden_modules
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") | ||
load("@rules_haskell//haskell:defs.bzl", "haskell_library") | ||
load("@rules_haskell//haskell/experimental:defs.bzl", "haskell_module") | ||
|
||
# Test for failure in the case of hiding non existent modules | ||
def _hidden_module_test_impl(ctx): | ||
env = analysistest.begin(ctx) | ||
|
||
asserts.expect_failure(env, "Hidden modules must be a subset of all modules") | ||
|
||
return analysistest.end(env) | ||
|
||
hidden_module_test = analysistest.make( | ||
_hidden_module_test_impl, | ||
expect_failure = True, | ||
) | ||
|
||
# test using the standard haskell library rules | ||
def _test_hidden_modules1(): | ||
haskell_library( | ||
name = "lib-hidden-1", | ||
srcs = native.glob(["lib-a/*.hs"]), | ||
src_strip_prefix = "lib-a", | ||
hidden_modules = ["NotHere"], | ||
deps = ["//tests/hackage:base"], | ||
tags = ["manual"], | ||
) | ||
|
||
hidden_module_test( | ||
name = "hidden_module_test-1", | ||
target_under_test = ":lib-hidden-1", | ||
) | ||
|
||
# Test using haskell modules | ||
def _test_hidden_modules2(): | ||
haskell_module( | ||
name = "FooModule", | ||
src = "lib-a/Foo.hs", | ||
module_name = "Foo", | ||
) | ||
|
||
haskell_module( | ||
name = "BarModule", | ||
src = "lib-a/Bar.hs", | ||
module_name = "Bar", | ||
) | ||
|
||
haskell_library( | ||
name = "lib-hidden-2", | ||
modules = [ | ||
":FooModule", | ||
":BarModule", | ||
], | ||
# Should be [Bar] if you actually want to hide the Bar module | ||
hidden_modules = ["BarModule"], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//tests/hackage:base", | ||
], | ||
tags = ["manual"], | ||
) | ||
|
||
hidden_module_test( | ||
name = "hidden_module_test-2", | ||
target_under_test = ":lib-hidden-2", | ||
) | ||
|
||
# Run all of the expect failure tests | ||
def hidden_modules_test_suite(name): | ||
_test_hidden_modules1() | ||
_test_hidden_modules2() | ||
|
||
native.test_suite( | ||
name = name, | ||
tests = [ | ||
":hidden_module_test-1", | ||
":hidden_module_test-2", | ||
], | ||
) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Orthogonal to this PR, but we should really get rid of
private/set.bzl
and replace it by Skylib. I've opened #1799 to track this.