-
Notifications
You must be signed in to change notification settings - Fork 80
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
Improve doctest support #342
Conversation
I was able to reproduce the darwin build failure on my laptop, and fix it by prefixing "-optl" to the arguments:
Not sure whether that also works on Linux or if we need to special-case it. |
Actually, that probably should be |
Doesn't seem to work without |
Quick clarification: the |
250b7ee
to
c633b45
Compare
haskell/doctest.bzl
Outdated
), | ||
"modules": attr.string_list( | ||
doc = """List of names of modules that will be tested. If the list is | ||
omitted, all modules provided by `deps` will be tested. |
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.
Clarify that this is all exposed modules provided by deps? (Assuming I'm reading the code correctly above)
haskell/doctest.bzl
Outdated
|
||
Note that your toolchain must be equipped with `doctest` executable, i.e. | ||
you should specify location of the executable using the `doctest` attribute | ||
when you invoke `haskell_toolchain`. |
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.
It's now configured by doctest_toolchain
rather than haskell_toolchain
. (Sorry, looks like I forgot to update this doc when I made that change earlier.)
haskell/private/actions/compile.bzl
Outdated
@@ -210,7 +210,7 @@ def _compilation_defaults(hs, cc, java, dep_info, srcs, extra_srcs, cpp_defines, | |||
DefaultCompileInfo: Populated default compilation settings. | |||
""" | |||
args = hs.actions.args() | |||
haddock_args = hs.actions.args() | |||
ghc_args = [] |
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.
Here's a refactoring suggestion; up to you whether it's worth it: consider moving l.272-282 below. Nearly all of args and ghc_args seem duplicated; it seems like we should be able to structure the code like:
ghc_args = []
ghc_args += ["-hide-all-packages"]
ghc_args += ...
...
args = hs.actions.args()
args.add(ghc_args)
# then add -hidir, -odir, etc to args
In theory it might even be possible to extract the computation of ghc_args into a separate function. Again, up to you whether it's worth it at this point.
Currently, `-c opt` will turn on optimization for all Haskell rules with no way to disable it. Previously, it was possible to do so with `compiler_flags = ["-O0"]`, but that behavior was changed in #342: https://github.com/tweag/rules_haskell/pull/342/files#diff-33a8c46955e2a9917090b5258346aee2L247 Some Haskell packages take a *lot* of memory and a lot longer to compile with optimizations. So it's useful for us to be able to control this tradeoff.
Currently, `-c opt` will turn on optimization for all Haskell rules with no way to disable it. Previously, it was possible to do so with `compiler_flags = ["-O0"]`, but that behavior was changed in tweag#342: https://github.com/tweag/rules_haskell/pull/342/files#diff-33a8c46955e2a9917090b5258346aee2L247 Some Haskell packages take a *lot* of memory and a lot longer to compile with optimizations. So it's useful for us to be able to control this tradeoff.
* Allow rules to override -O2 with their own compiler_flags. Currently, `-c opt` will turn on optimization for all Haskell rules with no way to disable it. Previously, it was possible to do so with `compiler_flags = ["-O0"]`, but that behavior was changed in #342: https://github.com/tweag/rules_haskell/pull/342/files#diff-33a8c46955e2a9917090b5258346aee2L247 Some Haskell packages take a *lot* of memory and a lot longer to compile with optimizations. So it's useful for us to be able to control this tradeoff.
* Allow rules to override -O2 with their own compiler_flags. Currently, `-c opt` will turn on optimization for all Haskell rules with no way to disable it. Previously, it was possible to do so with `compiler_flags = ["-O0"]`, but that behavior was changed in tweag#342: https://github.com/tweag/rules_haskell/pull/342/files#diff-33a8c46955e2a9917090b5258346aee2L247 Some Haskell packages take a *lot* of memory and a lot longer to compile with optimizations. So it's useful for us to be able to control this tradeoff.
This PR redesigns the
haskell_doctest
rule to make it capable to do everything normal doctest test suites do. In particular now it's possible to:doctest
allows that, and in fact if we always go for all modules it's not going to work because some modules may contain things that doctest doesn't like). Specifying module names is the sanest approach here because filenames of modules may change if pre-processing is involved, etc. If themodules
attribute is not specified we default to testing all modules.doctest
executable, because that's what one can do without Bazel.