Skip to content

Commit

Permalink
Merge pull request #2498 from input-output-hk/lehins/warnings-and-warts
Browse files Browse the repository at this point in the history
Warnings and warts
  • Loading branch information
lehins committed Sep 24, 2021
2 parents ac51494 + cadd93a commit 3005092
Show file tree
Hide file tree
Showing 57 changed files with 166 additions and 169 deletions.
10 changes: 5 additions & 5 deletions .buildkite/nightly-tests.sh
Expand Up @@ -3,14 +3,14 @@ set -e

nix build -f `dirname $0`/.. haskellPackages.cardano-ledger-alonzo-test.components.tests.cardano-ledger-alonzo-test -o cardano-ledger-alonzo-test
pushd eras/alonzo/test-suite/
nix-shell ../../shell.nix --run \
"../../cardano-ledger-alonzo-test/bin/cardano-ledger-alonzo-test --scenario=Nightly"
nix-shell ../../../shell.nix --run \
"../../../cardano-ledger-alonzo-test/bin/cardano-ledger-alonzo-test --scenario=Nightly"
popd

nix build -f `dirname $0`/.. haskellPackages.cardano-ledger-shelley-ma-test.components.tests.cardano-ledger-shelley-ma-test -o cardano-ledger-shelley-ma-test
pushd eras/shelley-ma/test-suite/
nix-shell ../../shell.nix --run \
"../../cardano-ledger-shelley-ma-test/bin/cardano-ledger-shelley-ma-test --scenario=Nightly"
nix-shell ../../../shell.nix --run \
"../../../cardano-ledger-shelley-ma-test/bin/cardano-ledger-shelley-ma-test --scenario=Nightly"
popd

nix build -f `dirname $0`/.. haskellPackages.cardano-ledger-shelley-test.components.tests.cardano-ledger-shelley-test -o cardano-ledger-shelley-test
Expand All @@ -24,7 +24,7 @@ popd
#../../../cardano-ledger-byron-test/bin/cardano-ledger-byron-test --scenario=QualityAssurance
#popd
#
# Two bryon property tests are currently failing:
# Two byron property tests are currently failing:
# 1 ts_prop_mainnetEpochsValid
# 2 prop_deserializeEpochs
# See:
Expand Down
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -129,6 +129,17 @@ For a continuous compilation of the `LaTeX` file run:
nix-shell --pure --run "make watch"
```

## Development

While building most compilation warnings will be turned into an error due to
`-Werror` flag. However during development it might be a bit inconvenient thus
can be disabled on per project basis:

```shell
cabal configure <package-name> --ghc-options="-Wwarn"
cabal build <package-name>
```

## Testing the Haskell programs

The tests can be run with cabal.
Expand Down
80 changes: 79 additions & 1 deletion cabal.project
Expand Up @@ -27,10 +27,16 @@ packages:
eras/shelley/chain-and-ledger/shelley-spec-ledger-test
eras/shelley/chain-and-ledger/dependencies/non-integer


-- Always write GHC env files, because they are needed by the doctests.
write-ghc-environment-files: always

-- Always build tests and benchmarks.
tests: true
benchmarks: true

-- The only sensible test display option
test-show-details: streaming

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
Expand Down Expand Up @@ -102,3 +108,75 @@ constraints:
-- ones they reuse the one from 'some', but there isn't e.g. a proper version
-- constraint from dependent-sum-template (which is the library we actually use).
, dependent-sum > 0.6.2.0

-- Have to specify '-Werror' for each package until this is taken care of:
-- https://github.com/haskell/cabal/issues/3579
package cardano-ledger-alonzo
ghc-options: -Werror

package cardano-ledger-alonzo-test
ghc-options: -Werror

package byron-spec-chain
ghc-options: -Werror

package cardano-crypto-wrapper
ghc-options: -Werror

package cardano-crypto-test
ghc-options: -Werror

package byron-spec-ledger
ghc-options: -Werror

package cardano-ledger-byron
ghc-options: -Werror

package cardano-ledger-byron-test
ghc-options: -Werror

package cardano-ledger-shelley-ma
ghc-options: -Werror

package cardano-ledger-shelley-ma-test
ghc-options: -Werror

package shelley-spec-non-integral
ghc-options: -Werror

package shelley-spec-ledger
ghc-options: -Werror

package shelley-spec-ledger-test
ghc-options: -Werror

package cardano-ledger-shelley
ghc-options: -Werror

package cardano-ledger-shelley-test
ghc-options: -Werror

package cardano-ledger-core
ghc-options: -Werror

package cardano-ledger-example-shelley
ghc-options: -Werror

package cardano-ledger-test
ghc-options: -Werror

package cardano-protocol-tpraos
ghc-options: -Werror

package non-integral
ghc-options: -Werror

package plutus-preprocessor
ghc-options: -Werror

package small-steps-test
ghc-options: -Werror

package small-steps
ghc-options: -Werror

2 changes: 1 addition & 1 deletion eras/alonzo/impl/.ghcid
@@ -1 +1 @@
-c "nix-shell ../../shell.nix --run \"cabal repl -f development cardano-ledger-alonzo\"" -o ghcid.txt
-c "nix-shell ../../shell.nix --run \"cabal repl cardano-ledger-alonzo\"" -o ghcid.txt
7 changes: 6 additions & 1 deletion eras/alonzo/impl/cardano-ledger-alonzo.cabal
Expand Up @@ -14,8 +14,13 @@ copyright: 2020 Input Output (Hong Kong) Ltd.
category: Network
build-type: Simple

source-repository head
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
subdir: eras/alonzo/impl

common base { build-depends: base >= 4.12 && < 4.15 }
common base
build-depends: base >= 4.12 && < 4.15

common project-config
default-language: Haskell2010
Expand Down
2 changes: 1 addition & 1 deletion eras/alonzo/impl/src/Cardano/Ledger/Alonzo/TxBody.hs
Expand Up @@ -143,7 +143,7 @@ data TxOut era
| TxOutCompactDH
{-# UNPACK #-} !(CompactAddr (Crypto era))
!(CompactForm (Core.Value era))
{-# UNPACK #-} !(DataHash (Crypto era))
!(DataHash (Crypto era))

deriving stock instance
( Eq (Core.Value era),
Expand Down
9 changes: 7 additions & 2 deletions eras/alonzo/test-suite/cardano-ledger-alonzo-test.cabal
Expand Up @@ -14,13 +14,18 @@ copyright: 2020 Input Output (Hong Kong) Ltd.
category: Network
build-type: Simple


extra-source-files:
cddl-files/alonzo.cddl
cddl-files/mock/crypto.cddl
cddl-files/mock/extras.cddl

common base { build-depends: base >= 4.12 && < 4.15 }
source-repository head
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
subdir: eras/alonzo/test-suite

common base
build-depends: base >= 4.12 && < 4.15

common project-config
default-language: Haskell2010
Expand Down
6 changes: 3 additions & 3 deletions eras/byron/README.md
Expand Up @@ -69,9 +69,9 @@ Example, while in the `byron/ledger/executable-spec` directory one can run:
nix-shell --pure --run "cabal new-test ledger-delegation-test"
```

To have the warnings not being treated as errors the `development` flag can be
used, e.g.:
To have the warnings not being treated as errors the `-Wwarn` ghc flag can be
used to negate the effect of `-Werror`, e.g.:

```sh
nix-shell --pure --run "cabal new-test ledger-delegation-test -fdevelopment"
nix-shell --pure --run "cabal new-test ledger-delegation-test --ghc-options='-Wwarn'"
```
2 changes: 1 addition & 1 deletion eras/byron/chain/executable-spec/.ghcid
@@ -1 +1 @@
-c "nix-shell ../../../shell.nix --run \"cabal repl -f development byron-spec-chain\"" -o ghcid.txt
-c "nix-shell ../../../shell.nix --run \"cabal repl byron-spec-chain\"" -o ghcid.txt
11 changes: 2 additions & 9 deletions eras/byron/chain/executable-spec/byron-spec-chain.cabal
Expand Up @@ -13,12 +13,8 @@ category: Testing
build-type: Simple
extra-source-files: ChangeLog.md

flag development
description: Disable '-Werror'
default: False
manual: True

common base { build-depends: base >= 4.11 && < 4.15 }
common base
build-depends: base >= 4.12 && < 4.15

common project-config
default-language: Haskell2010
Expand All @@ -30,9 +26,6 @@ common project-config
-Wredundant-constraints
-Wunused-packages

if (!flag(development))
ghc-options: -Werror

library
import: base, project-config

Expand Down
8 changes: 0 additions & 8 deletions eras/byron/crypto/cardano-crypto-wrapper.cabal
Expand Up @@ -12,11 +12,6 @@ category: Currency
build-type: Simple
extra-source-files: README.md

flag development
description: Disable `-Werror`
default: False
manual: True

common base
build-depends: base >= 4.12 && < 4.15

Expand All @@ -34,9 +29,6 @@ common project-config
-Wno-unsafe
-Wunused-packages

if (!flag(development))
ghc-options: -Werror

library
import: base, project-config

Expand Down
8 changes: 0 additions & 8 deletions eras/byron/crypto/test/cardano-crypto-test.cabal
Expand Up @@ -11,11 +11,6 @@ copyright: 2018 IOHK
category: Currency
build-type: Simple

flag development
description: Disable `-Werror`
default: False
manual: True

common base
build-depends: base >= 4.12 && < 4.15

Expand All @@ -34,9 +29,6 @@ common project-config
-Wno-unsafe
-Wunused-packages

if (!flag(development))
ghc-options: -Werror

library
import: base, project-config

Expand Down
2 changes: 1 addition & 1 deletion eras/byron/ledger/executable-spec/.ghcid
@@ -1 +1 @@
-c "nix-shell ../../../shell.nix --run \"cabal repl -f development byron-spec-ledger\"" -o ghcid.txt
-c "nix-shell ../../../shell.nix --run \"cabal repl byron-spec-ledger\"" -o ghcid.txt
8 changes: 0 additions & 8 deletions eras/byron/ledger/executable-spec/byron-spec-ledger.cabal
Expand Up @@ -15,11 +15,6 @@ build-type: Simple
extra-source-files: CHANGELOG.md
src/goblin_genomes/*.genome

flag development
description: Disable '-Werror'
default: False
manual: True

common base
build-depends: base >= 4.12 && < 4.15

Expand All @@ -32,9 +27,6 @@ common project-config
-Wincomplete-uni-patterns
-Wredundant-constraints
-Wno-unused-packages

if (!flag(development))
ghc-options: -Werror

library
import: base, project-config
Expand Down
8 changes: 0 additions & 8 deletions eras/byron/ledger/impl/cardano-ledger-byron.cabal
Expand Up @@ -12,11 +12,6 @@ category: Currency
build-type: Simple
extra-source-files: README.md

flag development
description: Disable `-Werror`
default: False
manual: True

flag test-normal-form
description: Test ledger state normal form during epoch validation
default: False
Expand All @@ -39,9 +34,6 @@ common project-config
-Wno-unsafe
-Wunused-packages

if (!flag(development))
ghc-options: -Werror

library
import: base, project-config

Expand Down
Expand Up @@ -7,6 +7,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-missed-specialisations #-}

-- | Helper data type for block, tx attributes
--
Expand Down
Expand Up @@ -6,6 +6,7 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -fno-warn-missed-specialisations #-}

module Cardano.Chain.Genesis.AvvmBalances
( GenesisAvvmBalances (..),
Expand Down
Expand Up @@ -8,6 +8,7 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -fno-warn-missed-specialisations #-}

module Cardano.Chain.Genesis.Delegation
( GenesisDelegation (..),
Expand Down
Expand Up @@ -6,6 +6,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -fno-warn-missed-specialisations #-}

module Cardano.Chain.Genesis.KeyHashes
( GenesisKeyHashes (..),
Expand Down
Expand Up @@ -8,6 +8,7 @@
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -fno-warn-missed-specialisations #-}

module Cardano.Chain.Genesis.NonAvvmBalances
( GenesisNonAvvmBalances (..),
Expand Down
1 change: 1 addition & 0 deletions eras/byron/ledger/impl/src/Cardano/Chain/UTxO/UTxO.hs
Expand Up @@ -6,6 +6,7 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-warn-missed-specialisations #-}

module Cardano.Chain.UTxO.UTxO
( UTxO (..),
Expand Down
8 changes: 0 additions & 8 deletions eras/byron/ledger/impl/test/cardano-ledger-byron-test.cabal
Expand Up @@ -11,11 +11,6 @@ copyright: 2018 IOHK
category: Currency
build-type: Simple

flag development
description: Disable `-Werror`
default: False
manual: True

common base
build-depends: base >= 4.12 && < 4.15

Expand All @@ -33,9 +28,6 @@ common project-config
-Wno-unsafe
-Wunused-packages

if (!flag(development))
ghc-options: -Werror

library
import: base, project-config

Expand Down
2 changes: 1 addition & 1 deletion eras/shelley-ma/impl/.ghcid
@@ -1 +1 @@
-c "nix-shell ../../shell.nix --run \"cabal repl -f development cardano-ledger-shelley-ma\"" -o ghcid.txt
-c "nix-shell ../../shell.nix --run \"cabal repl cardano-ledger-shelley-ma\"" -o ghcid.txt

0 comments on commit 3005092

Please sign in to comment.