tasty 1.0.1.1 → 1.1
raw patch · 8 files changed
+98/−15 lines, 8 files
Files
- CHANGELOG.md +75/−0
- README.md +7/−5
- Test/Tasty/Options/Env.hs +1/−0
- Test/Tasty/Patterns.hs +4/−7
- Test/Tasty/Patterns/Eval.hs +1/−1
- Test/Tasty/Patterns/Parser.hs +8/−0
- Test/Tasty/Patterns/Types.hs +1/−1
- tasty.cabal +1/−1
CHANGELOG.md view
@@ -1,6 +1,81 @@ Changes ======= +Version 1.1+-----------++**NOTE**: This major release contains some breaking changes to the semantics of patterns.+In the original pattern design I didn't notice the conflict between using `/` as+a field separator and as the AWK syntax for pattern matching `/.../`.++The new patterns have been around for a relatively short time (5 months), so+hopefully the breakage won't be too big. I'm sorry about any problems caused by+the change.++See <https://github.com/feuerbach/tasty/issues/220> for the discussion.++* The field separator in patterns is changed from slash (`/`) to period (`.`),+ and `.` is now allowed in raw patterns.++ The field separator is used to join the group names and the test+ name when comparing to a pattern such as `-p foo` or `-p /foo/`.++ If you used++ -p 'foo/bar'++ or++ -p '/foo\/bar/'++ before, now you should use++ -p 'foo.bar'+ or++ -p '/foo.bar/'++ if you meant "test/group `bar` inside group `foo`, or++ -p '/foo\/bar/'++ if you meant "test/group containing `foo/bar` in the name".++ The need for escaping the slash inside the `/.../` pattern was precisely the+ motivation for this change.++* Raw patterns (ones that are not AWK expressions) may no longer contain slashes+ (`/`).++ So++ -p 'foo/bar'++ is no longer allowed, and++ -p '/foo/'++ is now parsed as an AWK expression `/foo/`, whereas before it+ was treated as a raw pattern and converted to `/\/foo\//`.++ The reason for this change is that `/foo/` is a valid AWK expression+ and should be parsed as such.++* Raw patterns may now contain hyphens, so e.g. `-p type-checking` now works.++ In theory this makes some valid AWK expressions (such as `NF-2`) not to be+ parsed as such, but they are either unlikely to be useful or could also be+ expressed in other ways (`NF!=2`).++* Several new exports, mostly for testing/debugging patterns:++ * `TestPattern` now has a `Show` instance; `TestPattern` and `Expr` now have+ `Eq` instances.+ * The constructors of `TestPattern` are now exported.+ * `parseAwkExpr` is introduced and can be used in ghci to see how an AWK+ expression is parsed. (For parsing test patterns, which include raw+ patterns in addition to AWK expression, use `parseTestPattern`.)+ Version 1.0.1.1 ---------------
README.md view
@@ -264,7 +264,7 @@ A pattern is an [awk expression][awk]. When the expression is evaluated, the field `$1` is set to the outermost test group name, `$2` is set to the next test group name, and so on up to `$NF`, which is set to the test's own name. The field `$0`-is set to all other fields concatenated using `/` as a separator.+is set to all other fields concatenated using `.` as a separator. [awk]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html#tag_20_06_13_02 @@ -276,7 +276,7 @@ When a pattern is evaluated for the above test case, the available fields and variables are: - $0 = "One/Two/Three"+ $0 = "One.Two.Three" $1 = "One" $2 = "Two" $3 = "Three"@@ -293,9 +293,9 @@ contains `QuickCheck` As an extension to the awk expression language, if a pattern `pat` contains only-letters, digits, and characters from the set `[_/ ]`, it is treated like `/pat/`-(and therefore matched against `$0`). This is so that we can use `-p foo` as-a shortcut for `-p /foo/`.+letters, digits, and characters from the set `._ -` (period, underscore, space, hyphen),+it is treated like `/pat/` (and therefore matched against `$0`).+This is so that we can use `-p foo` as a shortcut for `-p /foo/`. The only deviation from awk that you will likely notice is that Tasty does not implement regular expression matching.@@ -701,9 +701,11 @@ * [Code testing in Haskell revisited (with Tasty)](http://lambda.jstolarek.com/2014/01/code-testing-in-haskell-revisited-with-tasty/) * [New patterns in tasty][awk-patterns-article] * [Screencast: Dynamic Test Suites in Haskell using Hspec and Tasty](https://www.youtube.com/watch?v=PGsDvgmZF7A)+* [Automatically generated directories for tasty tests][tasty-directories] [custom-options-article]: https://ro-che.info/articles/2013-12-20-tasty-custom-options.html [awk-patterns-article]: https://ro-che.info/articles/2018-01-08-tasty-new-patterns+[tasty-directories]: http://nmattia.com/posts/2018-04-30-tasty-test-names.html Maintainers -----------
Test/Tasty/Options/Env.hs view
@@ -37,6 +37,7 @@ getEnvOptions :: [OptionDescription] -> IO OptionSet getEnvOptions = getApp . foldMap lookupOpt where+ lookupOpt :: OptionDescription -> Ap IO OptionSet lookupOpt (Option (px :: Proxy v)) = do let name = proxy optionName px
Test/Tasty/Patterns.hs view
@@ -3,7 +3,7 @@ {-# LANGUAGE CPP, DeriveDataTypeable #-} module Test.Tasty.Patterns- ( TestPattern+ ( TestPattern(..) , parseTestPattern , noPattern , testPatternMatches@@ -21,7 +21,7 @@ import Options.Applicative hiding (Success) newtype TestPattern = TestPattern (Maybe Expr)- deriving Typeable+ deriving (Typeable, Show, Eq) noPattern :: TestPattern noPattern = TestPattern Nothing@@ -36,12 +36,9 @@ parseTestPattern :: String -> Maybe TestPattern parseTestPattern s | null s = Just noPattern- | all (\c -> isAlphaNum c || c `elem` "_/ ") s =+ | all (\c -> isAlphaNum c || c `elem` "._- ") s = Just . TestPattern . Just $ ERE s- | otherwise =- case runParser expr s of- Success a -> Just . TestPattern . Just $ a- _ -> Nothing+ | otherwise = TestPattern . Just <$> parseAwkExpr s testPatternMatches :: TestPattern -> Seq.Seq String -> Bool testPatternMatches pat fields =
Test/Tasty/Patterns/Eval.hs view
@@ -154,4 +154,4 @@ -- The field list should not include @$0@; it's calculated automatically. withFields :: Seq.Seq String -> M a -> Either String a withFields fields a = runReaderT a (whole Seq.<| fields)- where whole = intercalate "/" $ toList fields+ where whole = intercalate "." $ toList fields
Test/Tasty/Patterns/Parser.hs view
@@ -6,6 +6,7 @@ , runParser , ParseResult(..) , expr+ , parseAwkExpr ) where @@ -180,3 +181,10 @@ -- | The awk-like expression parser expr :: Parser Expr expr = expr4++-- | Parse an awk expression+parseAwkExpr :: String -> Maybe Expr+parseAwkExpr s =+ case runParser expr s of+ Success e -> Just e+ _ -> Nothing
Test/Tasty/Patterns/Types.hs view
@@ -27,4 +27,4 @@ | LengthFn (Maybe Expr) | MatchFn Expr String | SubstrFn Expr Expr (Maybe Expr)- deriving Show+ deriving (Show, Eq)
tasty.cabal view
@@ -2,7 +2,7 @@ -- see http://haskell.org/cabal/users-guide/ name: tasty-version: 1.0.1.1+version: 1.1 synopsis: Modern and extensible testing framework description: Tasty is a modern testing framework for Haskell. It lets you combine your unit tests, golden