avoid two test failures with LANG=C
Log.Remote.prop_parse_show_Config failed on an input of fromList [("\28162","")] in LANG=C, encodeBS "\28162" == "\STX=", while in UTF-8 locale, encodeBS "\28162" == "\230\184\130". So in the C locale, the String that's the parsed Map key ends up being encoded differently than it was in the input Map. Logs.Presence.Pure.prop_parse_build_log was failing in LANG=C because the Arbitrary LogLine for some reason sometimes generated LogInfo values containing \n or \r, despite using suchThat to prevent that. I don't understand why at all, but switching the suchThat to filter the ByteString instead of the String before conversion with encodeBS somehow avoids the problem. Both of these suggest something wonky with encodeBS in LANG=C, but I *think* it's not a problem except for with test data generated by Arbitrary.
This commit is contained in:
parent
facdeea47e
commit
928e08904d
2 changed files with 7 additions and 5 deletions
|
@ -15,6 +15,7 @@ import Utility.QuickCheck
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import qualified Data.ByteString.Lazy as L
|
import qualified Data.ByteString.Lazy as L
|
||||||
import qualified Data.ByteString as S
|
import qualified Data.ByteString as S
|
||||||
|
import qualified Data.ByteString.Char8 as C8
|
||||||
import qualified Data.Attoparsec.ByteString.Lazy as A
|
import qualified Data.Attoparsec.ByteString.Lazy as A
|
||||||
import Data.Attoparsec.ByteString.Char8 (char, anyChar)
|
import Data.Attoparsec.ByteString.Char8 (char, anyChar)
|
||||||
import Data.ByteString.Builder
|
import Data.ByteString.Builder
|
||||||
|
@ -116,10 +117,10 @@ instance Arbitrary LogLine where
|
||||||
arbitrary = LogLine
|
arbitrary = LogLine
|
||||||
<$> arbitrary
|
<$> arbitrary
|
||||||
<*> elements [minBound..maxBound]
|
<*> elements [minBound..maxBound]
|
||||||
<*> (LogInfo . encodeBS <$> arbinfo)
|
<*> (LogInfo <$> arbinfo)
|
||||||
where
|
where
|
||||||
arbinfo = arbitrary `suchThat`
|
arbinfo = (encodeBS <$> arbitrary) `suchThat`
|
||||||
(\c -> '\n' `notElem` c && '\r' `notElem` c)
|
(\b -> C8.notElem '\n' b && C8.notElem '\r' b)
|
||||||
|
|
||||||
prop_parse_build_log :: [LogLine] -> Bool
|
prop_parse_build_log :: [LogLine] -> Bool
|
||||||
prop_parse_build_log l = parseLog (toLazyByteString (buildLog l)) == l
|
prop_parse_build_log l = parseLog (toLazyByteString (buildLog l)) == l
|
||||||
|
|
|
@ -92,8 +92,9 @@ prop_isomorphic_configEscape s = s == (configUnEscape . configEscape) s
|
||||||
|
|
||||||
prop_parse_show_Config :: RemoteConfig -> Bool
|
prop_parse_show_Config :: RemoteConfig -> Bool
|
||||||
prop_parse_show_Config c
|
prop_parse_show_Config c
|
||||||
-- whitespace and '=' are not supported in keys
|
-- whitespace and '=' are not supported in config keys; limit to
|
||||||
| any (\k -> any isSpace k || elem '=' k) (M.keys c) = True
|
-- alphanumerics for simplicity
|
||||||
|
| any (all isAlphaNum) (M.keys c) = True
|
||||||
| otherwise = A.parseOnly remoteConfigParser (encodeBS $ showConfig c) ~~ Right c
|
| otherwise = A.parseOnly remoteConfigParser (encodeBS $ showConfig c) ~~ Right c
|
||||||
where
|
where
|
||||||
normalize v = sort . M.toList <$> v
|
normalize v = sort . M.toList <$> v
|
||||||
|
|
Loading…
Reference in a new issue