diff --git a/.ghci b/.ghci new file mode 100644 index 00000000..93e78dd2 --- /dev/null +++ b/.ghci @@ -0,0 +1,13 @@ +-- Default `-Werror` flags that should be disabled in GHCi +:set -Wno-error=identities +:set -Wno-error=redundant-constraints +:set -Wno-error=unused-imports + +-- Default warning flags that should be disabled in GHCi +:set -Wno-unused-local-binds +:set -Wno-unused-packages +:set -Wno-unused-pattern-binds +:set -Wno-unused-top-binds + +-- Set the GHCi prompt for "proto3-suite" sessions. +:set prompt "proto3-suite> " \ No newline at end of file diff --git a/README.md b/README.md index c7c89a40..2069ae2a 100644 --- a/README.md +++ b/README.md @@ -44,14 +44,15 @@ testing). From the root of this repository, run: ```bash $ nix-shell +[nix-shell]$ cabal configure -f development [nix-shell]$ cabal build ``` -Once your source code compiles and you want to test, run this instead: +To enable testing, configure `cabal` with `--enable-test` and (optionally) with the [`development`](./proto3-suite.cabal) flag to enable `-Werror`. Once your source code compiles and you want to test, run: ```bash $ nix-shell -[nix-shell]$ cabal configure --enable-tests +[nix-shell]$ cabal configure -f development --enable-tests [nix-shell]$ cabal build [nix-shell]$ cabal test ``` diff --git a/nix/overlays/haskell-packages.nix b/nix/overlays/haskell-packages.nix index c7c6e613..e047f17c 100644 --- a/nix/overlays/haskell-packages.nix +++ b/nix/overlays/haskell-packages.nix @@ -140,6 +140,10 @@ in { postPatch = (oldArgs.postPatch or "") + copyGeneratedCode + patchTestScripts; + configureFlags = (oldArgs.configureFlags or []) ++ [ + "-fdevelopment" + ]; + testHaskellDepends = (oldArgs.testHaskellDepends or [ ]) ++ [ haskellPackagesNew.proto3-suite-boot diff --git a/proto3-suite.cabal b/proto3-suite.cabal index 472dfc84..6c5b3fd1 100644 --- a/proto3-suite.cabal +++ b/proto3-suite.cabal @@ -44,6 +44,11 @@ flag attoparsec-aeson Manual: False -- "Manual: False" to automatically skip "attoparsec-aeson" if it is not available +flag development + description: Enable development-specific options. + default: False + manual: true + source-repository head type: git location: https://github.com/awakesecurity/proto3-suite @@ -53,6 +58,10 @@ common common BlockArguments ExplicitNamespaces DeriveDataTypeable DeriveGeneric ImportQualifiedPost ViewPatterns + if flag(development) + ghc-options: + -Werror + library import: common @@ -138,7 +147,7 @@ library build-depends: attoparsec-aeson >= 2.2.0.0 hs-source-dirs: src default-language: Haskell2010 - ghc-options: -O2 -Wall -Werror + ghc-options: -O2 -Wall test-suite tests import: common @@ -239,7 +248,7 @@ executable compile-proto-file , system-filepath , text , turtle - ghc-options: -O2 -Wall -Werror + ghc-options: -O2 -Wall executable canonicalize-proto-file import: common @@ -254,4 +263,4 @@ executable canonicalize-proto-file , proto3-wire >= 1.4.6 && < 1.5 , system-filepath , turtle - ghc-options: -O2 -Wall -Werror + ghc-options: -O2 -Wall