diff --git a/.reuse/dep5 b/.reuse/dep5 index bafb377..7197762 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -7,3 +7,7 @@ License: Unlicense Files: links-tests/ftp_root/**/* Copyright: 2021 Serokell License: Unlicense + +Files: tests/configs/github-config.yaml +Copyright: 2019-2021 Serokell +License: Unlicense diff --git a/package.yaml b/package.yaml index fd18abf..954f26f 100644 --- a/package.yaml +++ b/package.yaml @@ -17,7 +17,6 @@ description: Please see the README on GitHub at )) import Time (KnownRatName, Second, Time, unitsP) import Xrefcheck.Core @@ -32,6 +30,7 @@ import Xrefcheck.Scan import Xrefcheck.Scanners.Markdown import Xrefcheck.System (RelGlobPattern) import Xrefcheck.Util (aesonConfigOption, postfixFields, (-:)) +import Xrefcheck.Config.Default -- | Overall config. data Config = Config @@ -65,14 +64,6 @@ data ScannersConfig = ScannersConfig makeLensesWith postfixFields ''Config makeLensesWith postfixFields ''VerifyConfig ------------------------------------------------------------ --- Default config ------------------------------------------------------------ - -defConfigUnfilled :: ByteString -defConfigUnfilled = - $(embedFile ("src-files" "def-config.yaml")) - -- | Picks raw config with @:PLACEHOLDER::@ and fills the specified fields -- in it, picking a replacement suitable for the given key. Only strings and lists -- of strings can be filled this way. diff --git a/src-files/def-config.yaml b/src/Xrefcheck/Config/Default.hs similarity index 81% rename from src-files/def-config.yaml rename to src/Xrefcheck/Config/Default.hs index 017fea4..407ed5d 100644 --- a/src-files/def-config.yaml +++ b/src/Xrefcheck/Config/Default.hs @@ -1,8 +1,19 @@ -# SPDX-FileCopyrightText: 2019-2021 Serokell -# -# SPDX-License-Identifier: Unlicense +{- SPDX-FileCopyrightText: 2022 Serokell + - + - SPDX-License-Identifier: MPL-2.0 + -} -# Parameters of repository traversal. +{-# LANGUAGE QuasiQuotes #-} + +module Xrefcheck.Config.Default where + +import Universum + +import Text.RawString.QQ + +defConfigUnfilled :: ByteString +defConfigUnfilled = + [r|# Parameters of repository traversal. traversal: # Files and folders which we pretend do not exist # (so they are neither analyzed nor can be referenced). @@ -50,3 +61,4 @@ scanners: # # This affects which anchors are generated for headers. flavor: :PLACEHOLDER:flavor: +|] diff --git a/stack.yaml b/stack.yaml index 1c0213f..ba79da7 100644 --- a/stack.yaml +++ b/stack.yaml @@ -13,6 +13,5 @@ extra-deps: - pretty-terminal-0.1.0.0 - roman-numerals-0.5.1.5 - with-utf8-1.0.2.3 -- file-embed-0.0.13.0 - th-utilities-0.2.4.0@sha256:ba19cd8441aa43dbaed40e9055bb5a7cbd7cf9e154f5253c6bf9293af8b1f96b,1869 - firefly-0.2.1.0@sha256:e9d73486464c3e223ec457e02b30ddd5b550fdbf6292b268c64581e2b07d888b,1519 diff --git a/stack.yaml.lock b/stack.yaml.lock index 9cba714..e5ec91f 100644 --- a/stack.yaml.lock +++ b/stack.yaml.lock @@ -25,13 +25,6 @@ packages: hackage: with-utf8-1.0.2.3@sha256:3de710e4aa70856ab0845373bfde4746920fd45b8641bfaa3bd5cd2c200c4704,3051 original: hackage: with-utf8-1.0.2.3 -- completed: - pantry-tree: - sha256: 6c8f71ca993658844b93a2120f2ff1536400e705890a6fbf0f4e9889ff502649 - size: 477 - hackage: file-embed-0.0.13.0@sha256:a819e90b91cab919ffef5895ab6e1b2a44eac395a585f489b0c289a4a12d1c54,1396 - original: - hackage: file-embed-0.0.13.0 - completed: pantry-tree: sha256: 8c577d112a8398a5542aa4205b2e8a470a66d57590e6606d752d71e75d7425ea diff --git a/tests/Test/Xrefcheck/ConfigSpec.hs b/tests/Test/Xrefcheck/ConfigSpec.hs index 5630ca3..5aaff05 100644 --- a/tests/Test/Xrefcheck/ConfigSpec.hs +++ b/tests/Test/Xrefcheck/ConfigSpec.hs @@ -13,7 +13,8 @@ import Control.Exception qualified as E import Data.ByteString qualified as BS import Network.HTTP.Types (Status (..)) import Test.Hspec (Spec, before, describe, it, shouldBe) -import Test.QuickCheck (counterexample, ioProperty, once) +import Test.Hspec.Expectations (expectationFailure) +import Test.QuickCheck (ioProperty, once) import Xrefcheck.Config (Config (..), VerifyConfig (..), defConfig, defConfigText) import Xrefcheck.Core (Flavor (GitHub), allFlavors) @@ -34,16 +35,13 @@ spec = do -- stack exec xrefcheck -- dump-config -t GitHub -o tests/configs/github-config.yaml it "Config matches" $ \config -> - let matches = - [ "Config does not match the expected format." - , "Run" - , "`stack exec xrefcheck -- dump-config -t GitHub -o tests/configs/github-config.yaml`" - , "and verify changes" - ] - in - counterexample - (toString $ unwords matches) - (config == defConfigText GitHub) + when (config /= defConfigText GitHub) $ + expectationFailure $ toString $ unwords + [ "Config does not match the expected format." + , "Run" + , "`stack exec xrefcheck -- dump-config -t GitHub -o tests/configs/github-config.yaml`" + , "and verify changes" + ] describe "`ignoreAuthFailures` working as expected" $ do let config = (cVerification $ defConfig GitHub) { vcCheckLocalhost = True } diff --git a/tests/configs/github-config.yaml b/tests/configs/github-config.yaml index 9820898..21d824a 100644 --- a/tests/configs/github-config.yaml +++ b/tests/configs/github-config.yaml @@ -1,7 +1,3 @@ -# SPDX-FileCopyrightText: 2019-2021 Serokell -# -# SPDX-License-Identifier: Unlicense - # Parameters of repository traversal. traversal: # Files and folders which we pretend do not exist