nix: Add weeder to postgrest-coverage
Removes a bit of dead code from SpecHelper.hs
This commit is contained in:
committed by
Steve Chavez
parent
9b397878dc
commit
7940e73a12
@@ -5,6 +5,7 @@
|
|||||||
, devCabalOptions
|
, devCabalOptions
|
||||||
, entr
|
, entr
|
||||||
, graphviz
|
, graphviz
|
||||||
|
, haskellPackages
|
||||||
, hsie
|
, hsie
|
||||||
, nix
|
, nix
|
||||||
, silver-searcher
|
, silver-searcher
|
||||||
|
|||||||
+4
-2
@@ -5,7 +5,7 @@
|
|||||||
, ghc
|
, ghc
|
||||||
, glibcLocales
|
, glibcLocales
|
||||||
, gnugrep
|
, gnugrep
|
||||||
, haskell
|
, haskellPackages
|
||||||
, hpc-codecov
|
, hpc-codecov
|
||||||
, jq
|
, jq
|
||||||
, postgrest
|
, postgrest
|
||||||
@@ -116,7 +116,7 @@ let
|
|||||||
checkedShellScript
|
checkedShellScript
|
||||||
{
|
{
|
||||||
name = "postgrest-coverage";
|
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])" ];
|
args = [ "ARG_LEFTOVERS([hpc report arguments])" ];
|
||||||
inRootDir = true;
|
inRootDir = true;
|
||||||
redirectTixFiles = false;
|
redirectTixFiles = false;
|
||||||
@@ -133,6 +133,8 @@ let
|
|||||||
# build once before running all the tests
|
# build once before running all the tests
|
||||||
${cabal-install}/bin/cabal v2-build ${devCabalOptions} exe:postgrest lib:postgrest test:spec test:querycost
|
${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
|
# collect all tests
|
||||||
HPCTIXFILE="$tmpdir"/io.tix \
|
HPCTIXFILE="$tmpdir"/io.tix \
|
||||||
${withTools.withPg} ${cabal-install}/bin/cabal v2-exec ${devCabalOptions} \
|
${withTools.withPg} ${cabal-install}/bin/cabal v2-exec ${devCabalOptions} \
|
||||||
|
|||||||
+4
-2
@@ -123,7 +123,7 @@ library
|
|||||||
-fno-spec-constr -optP-Wno-nonportable-include-path
|
-fno-spec-constr -optP-Wno-nonportable-include-path
|
||||||
|
|
||||||
if flag(dev)
|
if flag(dev)
|
||||||
ghc-options: -O0
|
ghc-options: -O0 -fwrite-ide-info
|
||||||
if flag(hpc)
|
if flag(hpc)
|
||||||
ghc-options: -fhpc -hpcdir .hpc
|
ghc-options: -fhpc -hpcdir .hpc
|
||||||
else
|
else
|
||||||
@@ -152,7 +152,7 @@ executable postgrest
|
|||||||
-fno-spec-constr -optP-Wno-nonportable-include-path
|
-fno-spec-constr -optP-Wno-nonportable-include-path
|
||||||
|
|
||||||
if flag(dev)
|
if flag(dev)
|
||||||
ghc-options: -O0
|
ghc-options: -O0 -fwrite-ide-info
|
||||||
if flag(hpc)
|
if flag(hpc)
|
||||||
ghc-options: -fhpc -hpcdir .hpc
|
ghc-options: -fhpc -hpcdir .hpc
|
||||||
else
|
else
|
||||||
@@ -237,6 +237,7 @@ test-suite spec
|
|||||||
ghc-options: -O0 -Werror -Wall -fwarn-identities
|
ghc-options: -O0 -Werror -Wall -fwarn-identities
|
||||||
-fno-spec-constr -optP-Wno-nonportable-include-path
|
-fno-spec-constr -optP-Wno-nonportable-include-path
|
||||||
-fno-warn-missing-signatures
|
-fno-warn-missing-signatures
|
||||||
|
-fwrite-ide-info
|
||||||
|
|
||||||
test-suite querycost
|
test-suite querycost
|
||||||
type: exitcode-stdio-1.0
|
type: exitcode-stdio-1.0
|
||||||
@@ -281,6 +282,7 @@ test-suite querycost
|
|||||||
, wai-extra >= 3.0.19 && < 3.2
|
, wai-extra >= 3.0.19 && < 3.2
|
||||||
ghc-options: -O0 -Werror -Wall -fwarn-identities
|
ghc-options: -O0 -Werror -Wall -fwarn-identities
|
||||||
-fno-spec-constr -optP-Wno-nonportable-include-path
|
-fno-spec-constr -optP-Wno-nonportable-include-path
|
||||||
|
-fwrite-ide-info
|
||||||
|
|
||||||
test-suite doctests
|
test-suite doctests
|
||||||
type: exitcode-stdio-1.0
|
type: exitcode-stdio-1.0
|
||||||
|
|||||||
+1
-12
@@ -1,6 +1,6 @@
|
|||||||
module SpecHelper where
|
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.Char8 as BS
|
||||||
import qualified Data.ByteString.Lazy as BL
|
import qualified Data.ByteString.Lazy as BL
|
||||||
import qualified Data.Map.Strict as M
|
import qualified Data.Map.Strict as M
|
||||||
@@ -189,17 +189,10 @@ testMultipleSchemaCfg testDbConn = (testCfg testDbConn) { configDbSchemas = from
|
|||||||
testCfgLegacyGucs :: Text -> AppConfig
|
testCfgLegacyGucs :: Text -> AppConfig
|
||||||
testCfgLegacyGucs testDbConn = (testCfg testDbConn) { configDbUseLegacyGucs = False }
|
testCfgLegacyGucs testDbConn = (testCfg testDbConn) { configDbUseLegacyGucs = False }
|
||||||
|
|
||||||
resetDb :: Text -> IO ()
|
|
||||||
resetDb dbConn = loadFixture dbConn "data"
|
|
||||||
|
|
||||||
analyzeTable :: Text -> Text -> IO ()
|
analyzeTable :: Text -> Text -> IO ()
|
||||||
analyzeTable dbConn tableName =
|
analyzeTable dbConn tableName =
|
||||||
void $ readProcess "psql" ["--set", "ON_ERROR_STOP=1", toS dbConn, "-a", "-c", toS $ "ANALYZE test.\"" <> 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 :: ByteRange -> [Header]
|
||||||
rangeHdrs r = [rangeUnit, (hRange, renderByteRange r)]
|
rangeHdrs r = [rangeUnit, (hRange, renderByteRange r)]
|
||||||
|
|
||||||
@@ -226,10 +219,6 @@ authHeader :: BS.ByteString -> BS.ByteString -> Header
|
|||||||
authHeader typ creds =
|
authHeader typ creds =
|
||||||
(hAuthorization, 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 :: BS.ByteString -> Header
|
||||||
authHeaderJWT = authHeader "Bearer"
|
authHeaderJWT = authHeader "Bearer"
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
roots = [ "^Main.main$", "^Paths_" ],
|
||||||
|
type-class-roots = True
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user