Skip to content

Commit

Permalink
License and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
fsoikin committed Aug 2, 2024
1 parent 1e36ecd commit 33994a5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Oskar Wickstrom

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[![build](https://github.com/purescript-spec/purescript-spec-node/actions/workflows/build.yml/badge.svg)](https://github.com/purescript-spec/purescript-spec-node/actions/workflows/build.yml)

# PureScript Spec test runner for Node

The default runner for your tests if you're running on Node.

Documentation and examples here: https://purescript-spec.github.io/purescript-spec/running/
17 changes: 10 additions & 7 deletions src/Node/Config.purs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
import Effect.Aff.Class (class MonadAff, liftAff)
import Effect.Class (class MonadEffect, liftEffect)
import Options.Applicative ((<**>))
import Options.Applicative as Opt
import Partial (crashWith)
import Partial.Unsafe (unsafePartial)
Expand All @@ -58,8 +57,11 @@ fromCommandLine = fromCommandLine' defaultConfig commandLineOptionParsers

fromCommandLine' :: m a. MonadEffect m => a -> Array (OptionParser a) -> m a
fromCommandLine' defaultCfg options =
liftEffect (Opt.execParser $ optionParser options) <#>
liftEffect (Opt.customExecParser prefs $ optionParser options) <#>
\f -> f defaultCfg
where
prefs = Opt.defaultPrefs # \(Opt.ParserPrefs p) ->
Opt.ParserPrefs p { prefShowHelpOnError = true }

defaultConfig :: TestRunConfig
defaultConfig =
Expand Down Expand Up @@ -157,6 +159,7 @@ timeout :: ∀ r. OptionParser { timeout :: Maybe Milliseconds | r }
timeout = ado
seconds <- optional $ Opt.option Opt.int $ fold
[ Opt.long "timeout"
, Opt.metavar "SECONDS"
, Opt.help "timeout for each individual test case, in seconds."
]

Expand All @@ -178,8 +181,8 @@ filterByName = ado
pat <- optional $ Opt.strOption $ fold
[ Opt.long "example"
, Opt.short 'e'
, Opt.metavar "PATTERN"
, Opt.help "filter test cases by full name. Matching is case-sensitive."
, Opt.metavar "TEXT"
, Opt.help "run only tests whose full names contain the given text. Matching is case-sensitive."
]

let f = pat <#> \s -> Str.toLower >>> Str.contains (Str.Pattern $ Str.toLower s)
Expand All @@ -193,7 +196,7 @@ filterByRegex = ado
, Opt.short 'E'
, Opt.metavar "REGEX"
, Opt.help """
filter test cases by regular expression.
run only tests whose full names match the given regex.
This will unapologetically crash if the provided regex doesn't compile.
The regex is case-insensitive.
"""
Expand All @@ -208,8 +211,8 @@ filterByRegex = ado

optionParser :: a. Array (OptionParser a) -> Opt.ParserInfo (a -> a)
optionParser options =
Opt.info (combined <**> Opt.helper) $
Opt.info (Opt.helper <*> combined) $
Opt.fullDesc
<> Opt.header "CollegeVine’s very own PureScript test runner."
<> Opt.header "PureScript Spec test runner for Node"
where
combined = foldl combineOptionParsers emptyOptionParser options

0 comments on commit 33994a5

Please sign in to comment.