-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--rerun
doesn't take effect if there are multiple test suites
#393
Comments
What I think happens here is that due to This is a conceptual problem; I don't have a good idea how to solve this. If anybody has ideas on how to approach this then I'd love to hear them. |
Maybe one way to approach this in
But I think this is still a conceptual problem with Is this already possible with |
Workaround:
You could probably write a script that solves this generically, e.g. use |
Sweet, that worked!
However, maybe we can make it easier on them. What about if there was an hspec flag that specified a directory to store results in instead of a file, where the results of running individual test suites were each named after that test suite? I'll use the name So the example could change to Thoughts? I'm not actually sure this is a good idea, but it's what occured to me 😃 |
I think the right approach is to use So I'm not sure if I'm going to burn any cycles on this. I'm still keeping this issue open for now as a reminder to improve the docs. |
As of Something like this: module UniqueFailureReport (use) where
import GHC.Fingerprint (fingerprintString)
import System.Environment (getProgName, getExecutablePath)
import Test.Hspec.Core.Runner (Config(..))
import Test.Hspec.Core.Spec (SpecWith, runIO, modifyConfig)
use :: SpecWith a -> SpecWith a
use = (uniqueFailureReportPath >>)
uniqueFailureReportPath :: SpecWith a
uniqueFailureReportPath = do
path <- runIO uniquePath
modifyConfig (setFailureReport path)
setFailureReport :: FilePath -> Config -> Config
setFailureReport path config = config { configFailureReport = Just path}
uniquePath :: IO FilePath
uniquePath = do
name <- getProgName
md5sum <- show . fingerprintString <$> getExecutablePath
return $ ".hspec-failures-" <> name <> "-" <> md5sum This can be packaged up and published to Hackage. A user can then use it by registering it anywhere in their spec, or better yet in a spec hook: -- file test/SpecHook.hs
module SpecHook where
import Test.Hspec
import qualified UniqueFailureReport
hook :: Spec -> Spec
hook = UniqueFailureReport.use I don’t plan to publish/maintain this myself, but @seagreen if you want to take responsibility of this code, then please go ahead (no attribution required). |
I'll pass on that, but I am glad to see there's a fix. |
I have an example of the problem here: https://github.com/seagreen/hspec-multiple-suites
Let me know if it would be helpful to have examples of this that don't use
stack
, as it is it's possible this is a downstream issue in stack.The text was updated successfully, but these errors were encountered: