packages feed

hlint-test (empty) → 0.1.0.0

raw patch · 8 files changed

+197/−0 lines, 8 filesdep +basedep +hlintdep +hlint-testsetup-changed

Dependencies added: base, hlint, hlint-test

Files

+ CHANGES.md view
@@ -0,0 +1,3 @@+## 0.1.0.0 released 2017-12-28++Start of changelog
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Jan Sipr (c) 2017++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Jan Sipr nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,44 @@+# hlint-test++[![Build Status](https://travis-ci.org/Siprj/hlint-test.svg?branch=master)](https://travis-ci.org/Siprj/hlint-test)+[![Hackage](https://img.shields.io/hackage/v/hlint-test.svg?style=flat)](https://hackage.haskell.org/package/hlint-test)+[![Hackage Dependencies](https://img.shields.io/hackage-deps/v/hlint-test.svg?style=flat)](http://packdeps.haskellers.com/reverse/hlint-test)+[![Stackage LTS](http://stackage.org/package/hlint-test/badge/lts)](http://stackage.org/lts/package/hlint-test)+[![Stackage Nightly](http://stackage.org/package/hlint-test/badge/nightly)](http://stackage.org/nightly/package/hlint-test)+[![BSD3 License](http://img.shields.io/badge/license-BSD3-brightgreen.svg?style=flat)](https://tldrlegal.com/license/bsd-3-clause-license-(revised))++This package aims to make easy to automatically run hlint as part of unit tests.+That means hlint will be run when you execute `cabal test` or `stack test`.++## How to make it work++Hlint-test package contains GHC preprocessor which will generate the code+containing hlint runner. To invoke the preprocessor, create new test and put+following line into it:++```+{-# OPTIONS_GHC -F -pgmF hlint-test #-}+```++Don't forget to add the test into cabal file (or package.yaml respectively) as+separated test runner ;).++Now you can run the test simply by `stack test` or `cabal test`.++## Hlint options++If you need to you can use the preprocessor macro to pass some additional+arguments to the hlint. As it's shown on following line:++```+{-# OPTIONS_GHC -F -pgmF hlint-test -optF src -optF -r #-}+```++This will tell hlint to look for source codes only in `src` directory and to +generate html report if some suggestions are found.++Also you can use hlint configuration file too ;).++## Example++Simple example of the use can be seen in this package.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ driver/hlint-test.hs view
@@ -0,0 +1,3 @@+{-# LANGUAGE NoImplicitPrelude #-}+module Main (main) where+import Test.HLint.Preprocessor (main)
+ hlint-test.cabal view
@@ -0,0 +1,64 @@+-- This file has been generated from package.yaml by hpack version 0.20.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: d8a8b74bab041063eae27ade979f8532d90699daa926933c6abab8fcb257ff38++name:           hlint-test+version:        0.1.0.0+synopsis:       Run hlint in test suite+description:    Allows you to write small  hlint test runner; so you will not forget to run hlint before pushing to master.+category:       test+homepage:       https://github.com/Siprj/hlint-test#readme+bug-reports:    https://github.com/Siprj/hlint-test/issues+author:         Tomáš Janoušek <tomi@nomi.cz>, Jan Šipr <sipr.jan@gmail.com>+maintainer:     Jan Šipr <sipr.jan@gmail.com>+copyright:      2017  Tomáš Janoušek, Jan Šipr+license:        BSD3+license-file:   LICENSE+build-type:     Simple+cabal-version:  >= 1.10++extra-source-files:+    CHANGES.md+    README.md++source-repository head+  type: git+  location: https://github.com/Siprj/hlint-test++flag pedantic+  description: Pass additional warning flags and -Werror to GHC.+  manual: True+  default: False++library+  hs-source-dirs:+      src+  ghc-options: -Wall -fwarn-tabs -fwarn-missing-import-lists -fwarn-implicit-prelude+  build-depends:+      base >=4.7 && <5+    , hlint >=2.0+  if flag(pedantic)+    ghc-options: -Werror+  exposed-modules:+      Test.HLint.Preprocessor+      Test.HLint.Run+  other-modules:+      Paths_hlint_test+  default-language: Haskell2010++executable hlint-test+  main-is: hlint-test.hs+  hs-source-dirs:+      driver+  ghc-options: -Wall -fwarn-tabs -fwarn-missing-import-lists -fwarn-implicit-prelude -threaded -with-rtsopts=-N+  build-depends:+      base >=4.7 && <5+    , hlint >=2.0+    , hlint-test+  if flag(pedantic)+    ghc-options: -Werror+  other-modules:+      Paths_hlint_test+  default-language: Haskell2010
+ src/Test/HLint/Preprocessor.hs view
@@ -0,0 +1,34 @@+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE NoImplicitPrelude #-}+module Test.HLint.Preprocessor (main) where++import Control.Monad ((>>=))+import Data.Function (($), (.))+import Data.List (null)+import Data.Monoid ((<>))+import Data.String (String, unlines)+import System.Environment (getArgs)+import System.Exit (exitFailure)+import System.IO (IO, writeFile)+import Text.Show (show)+++main :: IO ()+main = getArgs >>= \case+    _src : _inp : dst : args ->+        writeFile dst . unlines $ mkModule args+    _ ->+        exitFailure++mkModule :: [String] -> [String]+mkModule args =+    [ "{-# OPTIONS_GHC -fno-warn-missing-import-lists #-}"+    , "{-# OPTIONS_GHC -fno-warn-implicit-prelude #-}"+    , "module Main (main) where"+    , ""+    , "import Prelude"+    , "import Test.HLint.Run (run)"+    , ""+    , "main :: IO ()"+    , "main = run " <> show (if null args then ["."] else args)+    ]
+ src/Test/HLint/Run.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE NoImplicitPrelude #-}+module Test.HLint.Run (run) where++import Control.Monad (unless)+import Data.List (null)+import Data.String (String)+import System.Exit (exitFailure)+import System.IO (IO, putStrLn)++import Language.Haskell.HLint (hlint)+++run :: [String] -> IO ()+run args = do+    putStrLn "" -- less confusing output, test-framework does this too+    hints <- hlint args+    unless (null hints) exitFailure