Skip to content

Commit

Permalink
Merge pull request #29 from aviaviavi/grep-cases
Browse files Browse the repository at this point in the history
grep to filter test cases
  • Loading branch information
aviaviavi authored Jul 18, 2018
2 parents 7a1c3fe + 17575e2 commit 04676fd
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 137 deletions.
18 changes: 4 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ Once you've written a spec, simply run it with:
If all your tests pass, curl-runnings will cleanly exit with a 0 code. A code of
1 will be returned if any tests failed.

You can also select specific test cases by filtering via regex by using the
`--grep` flag. Just make sure your case isn't referencing data from previous
examples that won't get run!

For more info:

```curl-runnings --help ```
Expand All @@ -102,17 +106,3 @@ For more info:

Contributions in any form are welcome and encouraged. Don't be shy! :D

### Roadmap

- [x] Json specifications for tests
- [x] Yaml specifications for tests
- [ ] Dhall specifications for tests
- [ ] More specification features
- [x] Reference values from previous json responses in matchers
- [x] Environment variable interpolation
- [ ] Call out to arbitrary shell commands in and between test cases
- [ ] Timeouts
- [ ] Support for non-json content type
- [ ] Retry logic
- [ ] A DSL for writing test specs

13 changes: 7 additions & 6 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,28 @@ import Testing.CurlRunnings.Types
-- | Command line flags
data CurlRunnings = CurlRunnings
{ file :: FilePath
, grep :: Maybe T.Text
} deriving (Show, Data, Typeable, Eq)

-- | cmdargs object
argParser :: CurlRunnings
argParser =
CurlRunnings {file = def &= typFile &= help "File to run"} &=
CurlRunnings {file = def &= typFile &= help "File to run", grep = def &= help "Regex to filter test cases by name"} &=
summary ("curl-runnings " ++ showVersion version) &=
program "curl-runnings" &=
verbosity &=
help "Use the --file or -f flag to specify an intput file spec to run"

runFile :: FilePath -> Verbosity -> IO ()
runFile "" _ =
runFile :: FilePath -> Verbosity -> Maybe T.Text -> IO ()
runFile "" _ _ =
putStrLn
"Please specify an input file with the --file (-f) flag or use --help for more information"
runFile path verbosityLevel = do
runFile path verbosityLevel regexp = do
home <- getEnv "HOME"
suite <- decodeFile . T.unpack $ T.replace "~" (T.pack home) (T.pack path)
case suite of
Right s -> do
results <- runSuite s $ toLogLevel verbosityLevel
results <- runSuite (s { suiteCaseFilter = regexp }) $ toLogLevel verbosityLevel
if any isFailing results
then putStrLn (T.unpack $ makeRed "Some tests failed") >>
exitWith (ExitFailure 1)
Expand All @@ -53,4 +54,4 @@ main :: IO ()
main = do
userArgs <- cmdArgs argParser
verbosityLevel <- getVerbosity
runFile (file userArgs) verbosityLevel
runFile (file userArgs) verbosityLevel (grep userArgs)
5 changes: 3 additions & 2 deletions curl-runnings.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
--
-- see: https://github.com/sol/hpack
--
-- hash: 54edbac6796242d948bec056fc052da66e68a038e47c65233a4600b0321666a3
-- hash: 8ef22999ea1898841e719329745691890631e19500f94c71ae498066d285f192

name: curl-runnings
version: 0.8.3
version: 0.8.4
synopsis: A framework for declaratively writing curl based API tests
description: Please see the README on Github at <https://github.com/aviaviavi/curl-runnings#readme>
category: Testing
Expand Down Expand Up @@ -45,6 +45,7 @@ library
, http-types >=0.9.1
, megaparsec >=6.3.0
, pretty-simple >=2.0.2.1
, regex-posix >=0.95.2
, text >=1.2.2.2
, unordered-containers >=0.2.8.0
, vector >=0.12.0
Expand Down
3 changes: 2 additions & 1 deletion package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: curl-runnings
version: 0.8.3
version: 0.8.4
github: aviaviavi/curl-runnings
license: MIT
author: Avi Press
Expand Down Expand Up @@ -42,6 +42,7 @@ library:
- http-types >=0.9.1
- megaparsec >=6.3.0
- pretty-simple >=2.0.2.1
- regex-posix >=0.95.2
- text >=1.2.2.2
- unordered-containers >=0.2.8.0
- vector >=0.12.0
Expand Down
Loading

0 comments on commit 04676fd

Please sign in to comment.