nix: Add weeder to postgrest-coverage

Removes a bit of dead code from SpecHelper.hs
This commit is contained in:
Wolfgang Walther
2022-06-03 22:19:16 -05:00
committed by Steve Chavez
parent 9b397878dc
commit 7940e73a12
5 changed files with 14 additions and 16 deletions
+1
View File
@@ -5,6 +5,7 @@
, devCabalOptions
, entr
, graphviz
, haskellPackages
, hsie
, nix
, silver-searcher
+4 -2
View File
@@ -5,7 +5,7 @@
, ghc
, glibcLocales
, gnugrep
, haskell
, haskellPackages
, hpc-codecov
, jq
, postgrest
@@ -116,7 +116,7 @@ let
checkedShellScript
{
name = "postgrest-coverage";
docs = "Run spec and io tests while collecting hpc coverage data.";
docs = "Run spec and io tests while collecting hpc coverage data. First runs weeder to detect dead code.";
args = [ "ARG_LEFTOVERS([hpc report arguments])" ];
inRootDir = true;
redirectTixFiles = false;
@@ -133,6 +133,8 @@ let
# build once before running all the tests
${cabal-install}/bin/cabal v2-build ${devCabalOptions} exe:postgrest lib:postgrest test:spec test:querycost
${haskellPackages.weeder}/bin/weeder --config=./test/weeder.dhall || echo Found dead code: Check file list above.
# collect all tests
HPCTIXFILE="$tmpdir"/io.tix \
${withTools.withPg} ${cabal-install}/bin/cabal v2-exec ${devCabalOptions} \
+4 -2
View File
@@ -123,7 +123,7 @@ library
-fno-spec-constr -optP-Wno-nonportable-include-path
if flag(dev)
ghc-options: -O0
ghc-options: -O0 -fwrite-ide-info
if flag(hpc)
ghc-options: -fhpc -hpcdir .hpc
else
@@ -152,7 +152,7 @@ executable postgrest
-fno-spec-constr -optP-Wno-nonportable-include-path
if flag(dev)
ghc-options: -O0
ghc-options: -O0 -fwrite-ide-info
if flag(hpc)
ghc-options: -fhpc -hpcdir .hpc
else
@@ -237,6 +237,7 @@ test-suite spec
ghc-options: -O0 -Werror -Wall -fwarn-identities
-fno-spec-constr -optP-Wno-nonportable-include-path
-fno-warn-missing-signatures
-fwrite-ide-info
test-suite querycost
type: exitcode-stdio-1.0
@@ -281,6 +282,7 @@ test-suite querycost
, wai-extra >= 3.0.19 && < 3.2
ghc-options: -O0 -Werror -Wall -fwarn-identities
-fno-spec-constr -optP-Wno-nonportable-include-path
-fwrite-ide-info
test-suite doctests
type: exitcode-stdio-1.0
+1 -12
View File
@@ -1,6 +1,6 @@
module SpecHelper where
import qualified Data.ByteString.Base64 as B64 (decodeLenient, encode)
import qualified Data.ByteString.Base64 as B64 (decodeLenient)
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy as BL
import qualified Data.Map.Strict as M
@@ -189,17 +189,10 @@ testMultipleSchemaCfg testDbConn = (testCfg testDbConn) { configDbSchemas = from
testCfgLegacyGucs :: Text -> AppConfig
testCfgLegacyGucs testDbConn = (testCfg testDbConn) { configDbUseLegacyGucs = False }
resetDb :: Text -> IO ()
resetDb dbConn = loadFixture dbConn "data"
analyzeTable :: Text -> Text -> IO ()
analyzeTable dbConn tableName =
void $ readProcess "psql" ["--set", "ON_ERROR_STOP=1", toS dbConn, "-a", "-c", toS $ "ANALYZE test.\"" <> tableName <> "\""] []
loadFixture :: Text -> FilePath -> IO()
loadFixture dbConn name =
void $ readProcess "psql" ["--set", "ON_ERROR_STOP=1", toS dbConn, "-q", "-f", "test/fixtures/" ++ name ++ ".sql"] []
rangeHdrs :: ByteRange -> [Header]
rangeHdrs r = [rangeUnit, (hRange, renderByteRange r)]
@@ -226,10 +219,6 @@ authHeader :: BS.ByteString -> BS.ByteString -> Header
authHeader typ creds =
(hAuthorization, typ <> " " <> creds)
authHeaderBasic :: BS.ByteString -> BS.ByteString -> Header
authHeaderBasic u p =
authHeader "Basic" $ toS . B64.encode . toS $ u <> ":" <> p
authHeaderJWT :: BS.ByteString -> Header
authHeaderJWT = authHeader "Bearer"
+4
View File
@@ -0,0 +1,4 @@
{
roots = [ "^Main.main$", "^Paths_" ],
type-class-roots = True
}