mirror of
https://github.com/codedownio/sandwich.git
synced 2024-09-11 11:56:32 +03:00
Working on website, demos, arg parsing
This commit is contained in:
parent
6893b203a6
commit
a295764bed
2
sandwich-demos/.gitignore
vendored
Normal file
2
sandwich-demos/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.stack-work/
|
||||
*~
|
3
sandwich-demos/.hlint.yaml
Normal file
3
sandwich-demos/.hlint.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
- ignore: {name: "Redundant bracket"}
|
||||
- ignore: {name: "Use <$>"}
|
3
sandwich-demos/ChangeLog.md
Normal file
3
sandwich-demos/ChangeLog.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Changelog for sandwich-webdriver
|
||||
|
||||
## Unreleased changes
|
30
sandwich-demos/LICENSE
Normal file
30
sandwich-demos/LICENSE
Normal file
@ -0,0 +1,30 @@
|
||||
Copyright Tom McLaughlin (c) 2020
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* Neither the name of Tom McLaughlin nor the names of other
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1
sandwich-demos/README.md
Normal file
1
sandwich-demos/README.md
Normal file
@ -0,0 +1 @@
|
||||
# sandwich-webdriver
|
2
sandwich-demos/Setup.hs
Normal file
2
sandwich-demos/Setup.hs
Normal file
@ -0,0 +1,2 @@
|
||||
import Distribution.Simple
|
||||
main = defaultMain
|
26
sandwich-demos/app/TUI.hs
Normal file
26
sandwich-demos/app/TUI.hs
Normal file
@ -0,0 +1,26 @@
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
module Main where
|
||||
|
||||
import Control.Concurrent
|
||||
import Control.Monad.IO.Class
|
||||
import Data.Maybe
|
||||
import Data.String.Interpolate.IsString
|
||||
import Data.Time.Clock
|
||||
import Test.Sandwich
|
||||
import Test.Sandwich.Formatters.Print
|
||||
import Test.Sandwich.Formatters.TerminalUI
|
||||
|
||||
simple :: TopSpec
|
||||
simple = do
|
||||
it "does the thing 1" $ do
|
||||
2 `shouldBe` 2
|
||||
|
||||
testOptions = defaultOptions {
|
||||
optionsTestArtifactsDirectory = TestArtifactsGeneratedDirectory "test_runs" (show <$> getCurrentTime)
|
||||
}
|
||||
|
||||
main :: IO ()
|
||||
main = runSandwichWithCommandLineArgs testOptions simple
|
71
sandwich-demos/package.yaml
Normal file
71
sandwich-demos/package.yaml
Normal file
@ -0,0 +1,71 @@
|
||||
name: sandwich-demos
|
||||
version: 0.1.0.0
|
||||
github: "githubuser/sandwich-demos"
|
||||
license: BSD3
|
||||
author: "Tom McLaughlin"
|
||||
maintainer: "example@example.com"
|
||||
copyright: "2020 Tom McLaughlin"
|
||||
|
||||
extra-source-files:
|
||||
- README.md
|
||||
- ChangeLog.md
|
||||
|
||||
# Metadata used when publishing your package
|
||||
# synopsis: Short description of your package
|
||||
# category: Web
|
||||
|
||||
# To avoid duplicated efforts in documentation and dealing with the
|
||||
# complications of embedding Haddock markup inside cabal files, it is
|
||||
# common to point users to the README.md file.
|
||||
description: Please see the README on GitHub at <https://github.com/githubuser/sandwich-demos#readme>
|
||||
|
||||
dependencies:
|
||||
- aeson
|
||||
- async
|
||||
- base >= 4.7 && < 5
|
||||
- containers
|
||||
- convertible
|
||||
- data-default
|
||||
- directory
|
||||
- exceptions
|
||||
- filepath
|
||||
- http-client
|
||||
- http-conduit
|
||||
- interpolate
|
||||
- lifted-base
|
||||
- monad-control
|
||||
- monad-logger
|
||||
- mtl
|
||||
- network
|
||||
- process
|
||||
- random
|
||||
- retry
|
||||
- safe
|
||||
- safe-exceptions
|
||||
- sandwich
|
||||
- temporary
|
||||
- text
|
||||
- time
|
||||
- transformers
|
||||
- transformers-base
|
||||
- unix
|
||||
- unordered-containers
|
||||
|
||||
default-extensions:
|
||||
- OverloadedStrings
|
||||
- QuasiQuotes
|
||||
- NamedFieldPuns
|
||||
- RecordWildCards
|
||||
- ScopedTypeVariables
|
||||
- FlexibleContexts
|
||||
- FlexibleInstances
|
||||
- LambdaCase
|
||||
|
||||
executables:
|
||||
tui-demo:
|
||||
main: TUI.hs
|
||||
source-dirs: app
|
||||
ghc-options:
|
||||
- -threaded
|
||||
- -rtsopts
|
||||
- -with-rtsopts=-N
|
67
sandwich-demos/sandwich-demos.cabal
Normal file
67
sandwich-demos/sandwich-demos.cabal
Normal file
@ -0,0 +1,67 @@
|
||||
cabal-version: 1.12
|
||||
|
||||
-- This file has been generated from package.yaml by hpack version 0.33.0.
|
||||
--
|
||||
-- see: https://github.com/sol/hpack
|
||||
--
|
||||
-- hash: ce8e12e40826efc60e15befa61c4ea4804e47e81c582468706a3f8efa287c41a
|
||||
|
||||
name: sandwich-demos
|
||||
version: 0.1.0.0
|
||||
description: Please see the README on GitHub at <https://github.com/githubuser/sandwich-demos#readme>
|
||||
homepage: https://github.com/githubuser/sandwich-demos#readme
|
||||
bug-reports: https://github.com/githubuser/sandwich-demos/issues
|
||||
author: Tom McLaughlin
|
||||
maintainer: example@example.com
|
||||
copyright: 2020 Tom McLaughlin
|
||||
license: BSD3
|
||||
license-file: LICENSE
|
||||
build-type: Simple
|
||||
extra-source-files:
|
||||
README.md
|
||||
ChangeLog.md
|
||||
|
||||
source-repository head
|
||||
type: git
|
||||
location: https://github.com/githubuser/sandwich-demos
|
||||
|
||||
executable tui-demo
|
||||
main-is: TUI.hs
|
||||
other-modules:
|
||||
Paths_sandwich_demos
|
||||
hs-source-dirs:
|
||||
app
|
||||
default-extensions: OverloadedStrings QuasiQuotes NamedFieldPuns RecordWildCards ScopedTypeVariables FlexibleContexts FlexibleInstances LambdaCase
|
||||
ghc-options: -threaded -rtsopts -with-rtsopts=-N
|
||||
build-depends:
|
||||
aeson
|
||||
, async
|
||||
, base >=4.7 && <5
|
||||
, containers
|
||||
, convertible
|
||||
, data-default
|
||||
, directory
|
||||
, exceptions
|
||||
, filepath
|
||||
, http-client
|
||||
, http-conduit
|
||||
, interpolate
|
||||
, lifted-base
|
||||
, monad-control
|
||||
, monad-logger
|
||||
, mtl
|
||||
, network
|
||||
, process
|
||||
, random
|
||||
, retry
|
||||
, safe
|
||||
, safe-exceptions
|
||||
, sandwich
|
||||
, temporary
|
||||
, text
|
||||
, time
|
||||
, transformers
|
||||
, transformers-base
|
||||
, unix
|
||||
, unordered-containers
|
||||
default-language: Haskell2010
|
@ -1,4 +1,4 @@
|
||||
Copyright Author name here (c) 2020
|
||||
Copyright Tom McLaughlin (c) 2020
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@ -13,7 +13,7 @@ modification, are permitted provided that the following conditions are met:
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* Neither the name of Author name here nor the names of other
|
||||
* Neither the name of Tom McLaughlin nor the names of other
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
|
@ -24,4 +24,4 @@ testOptions = defaultOptions {
|
||||
}
|
||||
|
||||
main :: IO ()
|
||||
main = runSandwich testOptions defaultTerminalUIFormatter simple
|
||||
main = runSandwich testOptions simple
|
||||
|
@ -2,9 +2,9 @@ name: sandwich-quickcheck
|
||||
version: 0.1.0.0
|
||||
github: "githubuser/sandwich-quickcheck"
|
||||
license: BSD3
|
||||
author: "Author name here"
|
||||
author: "Tom McLaughlin"
|
||||
maintainer: "example@example.com"
|
||||
copyright: "2020 Author name here"
|
||||
copyright: "2020 Tom McLaughlin"
|
||||
|
||||
extra-source-files:
|
||||
- README.md
|
||||
|
@ -11,9 +11,9 @@ version: 0.1.0.0
|
||||
description: Please see the README on GitHub at <https://github.com/githubuser/sandwich-quickcheck#readme>
|
||||
homepage: https://github.com/githubuser/sandwich-quickcheck#readme
|
||||
bug-reports: https://github.com/githubuser/sandwich-quickcheck/issues
|
||||
author: Author name here
|
||||
author: Tom McLaughlin
|
||||
maintainer: example@example.com
|
||||
copyright: 2020 Author name here
|
||||
copyright: 2020 Tom McLaughlin
|
||||
license: BSD3
|
||||
license-file: LICENSE
|
||||
build-type: Simple
|
||||
|
@ -1,8 +0,0 @@
|
||||
|
||||
resolver: lts-16.15
|
||||
|
||||
packages:
|
||||
- .
|
||||
- ../sandwich
|
||||
|
||||
extra-deps: []
|
@ -1,4 +1,4 @@
|
||||
Copyright Author name here (c) 2020
|
||||
Copyright Tom McLaughlin (c) 2020
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@ -13,7 +13,7 @@ modification, are permitted provided that the following conditions are met:
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* Neither the name of Author name here nor the names of other
|
||||
* Neither the name of Tom McLaughlin nor the names of other
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
|
||||
resolver: lts-16.15
|
||||
|
||||
packages:
|
||||
- .
|
||||
- ../sandwich
|
||||
|
||||
extra-deps: []
|
@ -1,12 +0,0 @@
|
||||
# This file was autogenerated by Stack.
|
||||
# You should not edit this file by hand.
|
||||
# For more information, please see the documentation at:
|
||||
# https://docs.haskellstack.org/en/stable/lock_files
|
||||
|
||||
packages: []
|
||||
snapshots:
|
||||
- completed:
|
||||
size: 532380
|
||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/15.yaml
|
||||
sha256: 3b5f2a699aa5ed3abbc30410062bf743926f0868ce3eeb5655370c6c6cc1a9f4
|
||||
original: lts-16.15
|
@ -1,4 +1,4 @@
|
||||
Copyright Author name here (c) 2020
|
||||
Copyright Tom McLaughlin (c) 2020
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@ -13,7 +13,7 @@ modification, are permitted provided that the following conditions are met:
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* Neither the name of Author name here nor the names of other
|
||||
* Neither the name of Tom McLaughlin nor the names of other
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
|
@ -2,9 +2,9 @@ name: sandwich-webdriver
|
||||
version: 0.1.0.0
|
||||
github: "githubuser/sandwich-webdriver"
|
||||
license: BSD3
|
||||
author: "Author name here"
|
||||
author: "Tom McLaughlin"
|
||||
maintainer: "example@example.com"
|
||||
copyright: "2020 Author name here"
|
||||
copyright: "2020 Tom McLaughlin"
|
||||
|
||||
extra-source-files:
|
||||
- README.md
|
||||
|
@ -11,9 +11,9 @@ version: 0.1.0.0
|
||||
description: Please see the README on GitHub at <https://github.com/githubuser/sandwich-webdriver#readme>
|
||||
homepage: https://github.com/githubuser/sandwich-webdriver#readme
|
||||
bug-reports: https://github.com/githubuser/sandwich-webdriver/issues
|
||||
author: Author name here
|
||||
author: Tom McLaughlin
|
||||
maintainer: example@example.com
|
||||
copyright: 2020 Author name here
|
||||
copyright: 2020 Tom McLaughlin
|
||||
license: BSD3
|
||||
license-file: LICENSE
|
||||
build-type: Simple
|
||||
|
@ -1,10 +0,0 @@
|
||||
|
||||
resolver: lts-16.15
|
||||
|
||||
packages:
|
||||
- .
|
||||
- ../sandwich
|
||||
|
||||
extra-deps:
|
||||
- git: https://github.com/codedownio/hs-webdriver
|
||||
commit: 96400ea0ba6ef118033d6a727ef4f57c31a187ca
|
@ -1,23 +0,0 @@
|
||||
# This file was autogenerated by Stack.
|
||||
# You should not edit this file by hand.
|
||||
# For more information, please see the documentation at:
|
||||
# https://docs.haskellstack.org/en/stable/lock_files
|
||||
|
||||
packages:
|
||||
- completed:
|
||||
name: webdriver
|
||||
version: 0.9.0.1
|
||||
git: https://github.com/codedownio/hs-webdriver
|
||||
pantry-tree:
|
||||
size: 2934
|
||||
sha256: ed9af2f807e88ba033a28f02de751ada83bf7a24309b6259d8cbba084edfc526
|
||||
commit: 96400ea0ba6ef118033d6a727ef4f57c31a187ca
|
||||
original:
|
||||
git: https://github.com/codedownio/hs-webdriver
|
||||
commit: 96400ea0ba6ef118033d6a727ef4f57c31a187ca
|
||||
snapshots:
|
||||
- completed:
|
||||
size: 532380
|
||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/15.yaml
|
||||
sha256: 3b5f2a699aa5ed3abbc30410062bf743926f0868ce3eeb5655370c6c6cc1a9f4
|
||||
original: lts-16.15
|
@ -1,4 +1,4 @@
|
||||
Copyright Author name here (c) 2020
|
||||
Copyright Tom McLaughlin (c) 2020
|
||||
|
||||
All rights reserved.
|
||||
|
||||
@ -13,7 +13,7 @@ modification, are permitted provided that the following conditions are met:
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* Neither the name of Author name here nor the names of other
|
||||
* Neither the name of Tom McLaughlin nor the names of other
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
|
@ -2,9 +2,9 @@ name: sandwich
|
||||
version: 0.1.0.0
|
||||
github: "githubuser/sandwich"
|
||||
license: BSD3
|
||||
author: "Author name here"
|
||||
author: "Tom McLaughlin"
|
||||
maintainer: "example@example.com"
|
||||
copyright: "2020 Author name here"
|
||||
copyright: "2020 Tom McLaughlin"
|
||||
|
||||
extra-source-files:
|
||||
- README.md
|
||||
@ -39,6 +39,7 @@ dependencies:
|
||||
- monad-control
|
||||
- monad-logger
|
||||
- mtl
|
||||
- optparse-applicative
|
||||
- pretty-show
|
||||
- process
|
||||
- random
|
||||
|
@ -4,16 +4,16 @@ cabal-version: 1.12
|
||||
--
|
||||
-- see: https://github.com/sol/hpack
|
||||
--
|
||||
-- hash: b2b4a3e7c1e6780d6bccbc94c449be36d74f2ed6d24dd2eee12c8a1e22b55ee3
|
||||
-- hash: 8510529efc40f85f305835f5067c69329cc2a16c46de90a2cfd75ffe70d95c31
|
||||
|
||||
name: sandwich
|
||||
version: 0.1.0.0
|
||||
description: Please see the README on GitHub at <https://github.com/githubuser/sandwich#readme>
|
||||
homepage: https://github.com/githubuser/sandwich#readme
|
||||
bug-reports: https://github.com/githubuser/sandwich/issues
|
||||
author: Author name here
|
||||
author: Tom McLaughlin
|
||||
maintainer: example@example.com
|
||||
copyright: 2020 Author name here
|
||||
copyright: 2020 Tom McLaughlin
|
||||
license: BSD3
|
||||
license-file: LICENSE
|
||||
build-type: Simple
|
||||
@ -40,6 +40,7 @@ library
|
||||
Test.Sandwich.Internal
|
||||
Test.Sandwich.Internal.Formatters
|
||||
other-modules:
|
||||
Test.Sandwich.ArgParsing
|
||||
Test.Sandwich.Formatters.Common.Count
|
||||
Test.Sandwich.Formatters.Common.Util
|
||||
Test.Sandwich.Formatters.Print.CallStacks
|
||||
@ -97,6 +98,7 @@ library
|
||||
, monad-control
|
||||
, monad-logger
|
||||
, mtl
|
||||
, optparse-applicative
|
||||
, pretty-show
|
||||
, process
|
||||
, random
|
||||
@ -140,6 +142,7 @@ executable sandwich-exe
|
||||
, monad-control
|
||||
, monad-logger
|
||||
, mtl
|
||||
, optparse-applicative
|
||||
, pretty-show
|
||||
, process
|
||||
, random
|
||||
@ -189,6 +192,7 @@ executable sandwich-test
|
||||
, monad-control
|
||||
, monad-logger
|
||||
, mtl
|
||||
, optparse-applicative
|
||||
, pretty-show
|
||||
, process
|
||||
, random
|
||||
@ -239,6 +243,7 @@ test-suite sandwich-test-suite
|
||||
, monad-control
|
||||
, monad-logger
|
||||
, mtl
|
||||
, optparse-applicative
|
||||
, pretty-show
|
||||
, process
|
||||
, random
|
||||
|
@ -8,6 +8,7 @@ module Test.Sandwich (
|
||||
-- * Running tests
|
||||
runSandwich
|
||||
, runSandwich'
|
||||
, runSandwichWithCommandLineArgs
|
||||
, runSandwichTree
|
||||
, startSandwichTree
|
||||
|
||||
@ -59,6 +60,7 @@ import Control.Concurrent.Async
|
||||
import Control.Concurrent.STM
|
||||
import qualified Control.Exception as E
|
||||
import Control.Monad
|
||||
import Control.Monad.IO.Class
|
||||
import Control.Monad.Logger
|
||||
import Data.Either
|
||||
import Data.IORef
|
||||
@ -66,6 +68,7 @@ import Data.String.Interpolate.IsString
|
||||
import System.Directory
|
||||
import System.FilePath
|
||||
import System.Posix.Signals
|
||||
import Test.Sandwich.ArgParsing
|
||||
import Test.Sandwich.Contexts
|
||||
import Test.Sandwich.Expectations
|
||||
import Test.Sandwich.Formatters.Common.Count
|
||||
@ -87,6 +90,12 @@ import Test.Sandwich.Util
|
||||
runSandwich :: Options -> TopSpec -> IO ()
|
||||
runSandwich options spec = void $ runSandwich' options spec
|
||||
|
||||
-- | Run the spec, configuring the options from the command line
|
||||
runSandwichWithCommandLineArgs :: Options -> TopSpec -> IO ()
|
||||
runSandwichWithCommandLineArgs baseOptions spec = do
|
||||
(options, repeatCount) <- liftIO $ addOptionsFromArgs baseOptions
|
||||
void $ runSandwich' options spec
|
||||
|
||||
-- | Run the spec and return the number of failures
|
||||
runSandwich' :: Options -> TopSpec -> IO (ExitReason, Int)
|
||||
runSandwich' options spec = do
|
||||
@ -151,7 +160,7 @@ startSandwichTree' baseContext (Options {..}) spec' = do
|
||||
runSandwichTree :: Options -> TopSpec -> IO [RunNode BaseContext]
|
||||
runSandwichTree options spec = do
|
||||
rts <- startSandwichTree options spec
|
||||
_ <- mapM_ waitForTree rts
|
||||
mapM_ waitForTree rts
|
||||
return rts
|
||||
|
||||
baseContextFromOptions :: Options -> IO BaseContext
|
||||
|
198
sandwich/src/Test/Sandwich/ArgParsing.hs
Normal file
198
sandwich/src/Test/Sandwich/ArgParsing.hs
Normal file
@ -0,0 +1,198 @@
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE CPP #-}
|
||||
|
||||
module Test.Sandwich.ArgParsing where
|
||||
|
||||
import Control.Monad.Logger
|
||||
import Data.Maybe
|
||||
import qualified Data.Text as T
|
||||
import Data.Time.Clock.POSIX
|
||||
import Options.Applicative
|
||||
import qualified Options.Applicative as OA
|
||||
import System.IO
|
||||
import Test.Sandwich.Formatters.LogSaver
|
||||
import Test.Sandwich.Formatters.Print.Types
|
||||
import Test.Sandwich.Formatters.TerminalUI
|
||||
import Test.Sandwich.Formatters.TerminalUI.Types
|
||||
import Test.Sandwich.Options
|
||||
import Test.Sandwich.Types.RunTree
|
||||
|
||||
#if MIN_VERSION_time(1,9,0)
|
||||
import Data.Time.Format.ISO8601
|
||||
formatTime = T.unpack . T.replace ":" "_" . T.pack . iso8601Show
|
||||
#else
|
||||
formatTime = show
|
||||
#endif
|
||||
|
||||
|
||||
commandLineOptionsWithInfo :: ParserInfo CommandLineOptions
|
||||
commandLineOptionsWithInfo = OA.info (commandLineOptions <**> helper)
|
||||
(
|
||||
fullDesc
|
||||
<> progDesc "Run tests with Sandwich"
|
||||
<> header "Sandwich test runner"
|
||||
)
|
||||
|
||||
-- * FormatterType
|
||||
|
||||
data FormatterType = Print | TUI | Auto
|
||||
|
||||
instance Show FormatterType where
|
||||
show Print = "print"
|
||||
show TUI = "tui"
|
||||
show Auto = "auto"
|
||||
|
||||
instance Read FormatterType where
|
||||
readsPrec _ "print" = [(Print, "")]
|
||||
readsPrec _ "tui" = [(TUI, "")]
|
||||
readsPrec _ "auto" = [(Auto, "")]
|
||||
readsPrec _ _ = []
|
||||
|
||||
-- * DisplayType
|
||||
|
||||
data DisplayType = Current | Headless | Xvfb
|
||||
|
||||
instance Show DisplayType where
|
||||
show Current = "current"
|
||||
show Headless = "headless"
|
||||
show Xvfb = "xvfb"
|
||||
|
||||
instance Read DisplayType where
|
||||
readsPrec _ "current" = [(Current, "")]
|
||||
readsPrec _ "headless" = [(Headless, "")]
|
||||
readsPrec _ "xvfb" = [(Xvfb, "")]
|
||||
readsPrec _ _ = []
|
||||
|
||||
-- * CommandLineOptions
|
||||
|
||||
data CommandLineOptions = CommandLineOptions {
|
||||
-- sandwich
|
||||
optFormatter :: FormatterType
|
||||
, optLogLevel :: Maybe LogLevel
|
||||
, optTreeFilter :: Maybe String
|
||||
, optRepeatCount :: Int
|
||||
, optFixedRoot :: Maybe String
|
||||
|
||||
-- sandwich-webdriver
|
||||
, optFirefox :: Bool
|
||||
, optPoolSize :: Int
|
||||
, optDisplay :: DisplayType
|
||||
, optFluxbox :: Bool
|
||||
, optIndividualVideos :: Bool
|
||||
, optErrorVideos :: Bool
|
||||
|
||||
-- sandwich-slack
|
||||
, optSlackToken :: Maybe String
|
||||
, optSlackChannel :: Maybe String
|
||||
, optSlackTopMessage :: Maybe String
|
||||
|
||||
} deriving Show
|
||||
|
||||
commandLineOptions :: Parser CommandLineOptions
|
||||
commandLineOptions = CommandLineOptions
|
||||
-- sandwich
|
||||
<$> formatter
|
||||
<*> logLevel
|
||||
<*> optional (strOption (long "filter" <> short 'f' <> help "Filter test tree by string matching text example labels" <> metavar "STRING"))
|
||||
<*> option auto (long "repeat" <> short 'r' <> showDefault <> help "Repeat the test N times and report how many failures occur" <> value 1 <> metavar "INT")
|
||||
<*> optional (strOption (long "fixed-root" <> help "Store test artifacts at a fixed path" <> metavar "STRING"))
|
||||
|
||||
-- sandwich-webdriver
|
||||
<*> flag False True (long "firefox" <> help "Use Firefox for Selenium tests (instead of the default of Chrome).")
|
||||
<*> option auto (long "pool-size" <> short 'p' <> showDefault <> help "WebDriver pool size" <> value 4 <> metavar "INT")
|
||||
<*> display
|
||||
<*> flag False True (long "fluxbox" <> help "Launch fluxbox as window manager when using Xvfb")
|
||||
<*> flag False True (long "individual-videos" <> help "Record individual videos of each test.")
|
||||
<*> flag False True (long "error-videos" <> help "Record videos of each test but delete them unless there was an exception")
|
||||
|
||||
-- sandwich-slack
|
||||
<*> optional (strOption (long "slack-token" <> help "Slack token to use with the Slack formatter" <> metavar "STRING"))
|
||||
<*> optional (strOption (long "slack-channel" <> help "Slack channel to use with the Slack formatter" <> metavar "STRING"))
|
||||
<*> optional (strOption (long "slack-top-message" <> help "Top message to display on Slack progress bars" <> metavar "STRING"))
|
||||
|
||||
formatter :: Parser FormatterType
|
||||
formatter =
|
||||
flag' Print (long "print" <> help "Print to stdout")
|
||||
<|> flag' TUI (long "tui" <> help "Open terminal UI app")
|
||||
<|> flag Auto Auto (long "auto" <> help "Automatically decide which formatter to use")
|
||||
|
||||
logLevel :: Parser (Maybe LogLevel)
|
||||
logLevel =
|
||||
flag' (Just LevelDebug) (long "debug" <> help "Log level DEBUG")
|
||||
<|> flag' (Just LevelInfo) (long "info" <> help "Log level INFO")
|
||||
<|> flag' (Just LevelWarn) (long "warn" <> help "Log level WARN")
|
||||
<|> flag (Just LevelWarn) (Just LevelError) (long "error" <> help "Log level ERROR")
|
||||
|
||||
display :: Parser DisplayType
|
||||
display =
|
||||
flag' Current (long "current" <> help "Open browser in current display")
|
||||
<|> flag' Headless (long "headless" <> help "Run browser in headless mode")
|
||||
<|> flag Current Xvfb (long "xvfb" <> help "Run browser in Xvfb session")
|
||||
|
||||
|
||||
addOptionsFromArgs :: Options -> IO (Options, Int)
|
||||
addOptionsFromArgs baseOptions = do
|
||||
CommandLineOptions {..} <- OA.execParser commandLineOptionsWithInfo
|
||||
|
||||
let printFormatter = SomeFormatter $ defaultPrintFormatter { printFormatterLogLevel = optLogLevel }
|
||||
let tuiFormatter = SomeFormatter $ defaultTerminalUIFormatter { terminalUILogLevel = optLogLevel }
|
||||
|
||||
mainFormatter <- case (optRepeatCount, optFormatter) of
|
||||
(x, _) | x /= 1 -> return printFormatter
|
||||
(_, Auto) -> hIsTerminalDevice stdout >>= \case
|
||||
True -> return printFormatter
|
||||
False -> return tuiFormatter
|
||||
(_, TUI) -> return tuiFormatter
|
||||
(_, Print) -> return printFormatter
|
||||
|
||||
-- let slackFormatter = case (optSlackToken, optSlackChannel) of
|
||||
-- (Just token, Just channel) -> Just $ SomeFormatter $ defaultSlackFormatter {
|
||||
-- slackFormatterSlackConfig = SlackConfig (convert token)
|
||||
-- , slackFormatterTopMessage = optSlackTopMessage
|
||||
-- , slackFormatterChannel = channel
|
||||
-- , slackFormatterVisibilityThreshold = Just 50
|
||||
-- }
|
||||
-- _ -> Nothing
|
||||
|
||||
let options = baseOptions {
|
||||
optionsTestArtifactsDirectory = case optFixedRoot of
|
||||
Nothing -> TestArtifactsGeneratedDirectory "test_runs" (formatTime <$> getCurrentTime)
|
||||
Just path -> TestArtifactsFixedDirectory path
|
||||
, optionsFilterTree = TreeFilter <$> optTreeFilter
|
||||
, optionsFormatters = catMaybes [Just mainFormatter, Just $ SomeFormatter defaultLogSaverFormatter]
|
||||
-- , optionsFormatters = catMaybes [Just mainFormatter, Just $ SomeFormatter defaultLogSaverFormatter, slackFormatter]
|
||||
}
|
||||
|
||||
-- let runMode = case optDisplay of
|
||||
-- Headless -> RunHeadless defaultHeadlessConfig
|
||||
-- Xvfb -> RunInXvfb (defaultXvfbConfig { xvfbStartFluxbox = optFluxbox })
|
||||
-- Current -> Normal
|
||||
|
||||
-- let toolsRoot = "/tmp/tools"
|
||||
-- seleniumPath <- (runStdoutLoggingT $ obtainSelenium toolsRoot DownloadSeleniumDefault) >>= \case
|
||||
-- Left err -> error [i|Failed to get selenium JAR: #{err}|]
|
||||
-- Right x -> return x
|
||||
-- chromeDriverPath <- (runStdoutLoggingT $ obtainChromeDriver toolsRoot DownloadChromeDriverAutodetect) >>= \case
|
||||
-- Left err -> error [i|Failed to get chromedriver: #{err}|]
|
||||
-- Right x -> return x
|
||||
-- geckoDriverPath <- (runStdoutLoggingT $ obtainGeckoDriver toolsRoot DownloadGeckoDriverAutodetect) >>= \case
|
||||
-- Left err -> error [i|Failed to get geckodriver: #{err}|]
|
||||
-- Right x -> return x
|
||||
|
||||
-- httpManager <- newManager (defaultManagerSettings { managerResponseTimeout = responseTimeoutMicro 60000000 })
|
||||
|
||||
-- let wdOptions = (defaultWdOptions "/tmp/tools") {
|
||||
-- capabilities = if optFirefox then firefoxCapabilities else chromeCapabilities
|
||||
-- , saveSeleniumMessageHistory = Always
|
||||
-- , seleniumToUse = UseSeleniumAt seleniumPath
|
||||
-- , chromeDriverToUse = UseChromeDriverAt chromeDriverPath
|
||||
-- , geckoDriverToUse = UseGeckoDriverAt geckoDriverPath
|
||||
-- , runMode = runMode
|
||||
-- , httpManager = Just httpManager
|
||||
-- , httpRetryCount = 3
|
||||
-- }
|
||||
|
||||
return (options, optRepeatCount)
|
@ -1,12 +1,7 @@
|
||||
{-# LANGUAGE StandaloneDeriving #-}
|
||||
{-# LANGUAGE ViewPatterns #-}
|
||||
{-# LANGUAGE TypeOperators #-}
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
{-# LANGUAGE NamedFieldPuns #-}
|
||||
{-# LANGUAGE GADTs #-}
|
||||
{-# LANGUAGE DeriveFunctor #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
-- |
|
||||
|
||||
module Test.Sandwich.Types.RunTree where
|
||||
|
||||
|
@ -1,7 +0,0 @@
|
||||
|
||||
resolver: lts-16.15
|
||||
|
||||
packages:
|
||||
- .
|
||||
|
||||
extra-deps: []
|
@ -1,12 +0,0 @@
|
||||
# This file was autogenerated by Stack.
|
||||
# You should not edit this file by hand.
|
||||
# For more information, please see the documentation at:
|
||||
# https://docs.haskellstack.org/en/stable/lock_files
|
||||
|
||||
packages: []
|
||||
snapshots:
|
||||
- completed:
|
||||
size: 532380
|
||||
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/15.yaml
|
||||
sha256: 3b5f2a699aa5ed3abbc30410062bf743926f0868ce3eeb5655370c6c6cc1a9f4
|
||||
original: lts-16.15
|
11
stack.yaml
Normal file
11
stack.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
resolver: lts-16.15
|
||||
|
||||
packages:
|
||||
- ./sandwich
|
||||
- ./sandwich-demos
|
||||
- ./sandwich-quickcheck
|
||||
- ./sandwich-slack
|
||||
- ./sandwich-webdriver
|
||||
|
||||
extra-deps: []
|
9152
website/package-lock.json
generated
Normal file
9152
website/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -109,7 +109,8 @@ class Index extends React.Component {
|
||||
'To make your landing page more attractive, use illustrations! Check out ' +
|
||||
'[**unDraw**](https://undraw.co/) which provides you with customizable illustrations which are free to use. ' +
|
||||
'The illustrations you see on this page are from unDraw.',
|
||||
image: `${baseUrl}img/undraw_code_review.svg`,
|
||||
image: `${baseUrl}videos/lalala.webm`,
|
||||
/* image: `${baseUrl}img/undraw_code_review.svg`, */
|
||||
imageAlign: 'left',
|
||||
title: 'Wonderful SVG Illustrations',
|
||||
},
|
||||
@ -137,7 +138,7 @@ class Index extends React.Component {
|
||||
{
|
||||
content:
|
||||
'Each new Docusaurus project has **randomly-generated** theme colors.',
|
||||
image: `${baseUrl}img/undraw_youtube_tutorial.svg`,
|
||||
image: `${baseUrl}img/lalala.gif`,
|
||||
imageAlign: 'right',
|
||||
title: 'Randomly Generated Theme Colors',
|
||||
},
|
||||
|
BIN
website/static/img/lalala.gif
Normal file
BIN
website/static/img/lalala.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 280 KiB |
Loading…
Reference in New Issue
Block a user