这是一件令人气愤的事情,因为我已经构建了基于Hspec的测试套件,其中颜色的行为都正常。但是在这个项目中,当我一次运行所有测试套件时,我无法看到颜色。当使用“堆栈测试”时,我的hspec测试输出没有着色
我project.cabal设置是这样的:
test-suite unit
type: exitcode-stdio-1.0
main-is: SpecMain.hs
hs-source-dirs: tests/unit
other-modules: WikiSpec
default-language: Haskell2010
ghc-options: -Wall -fno-warn-orphans -threaded
build-depends: base >=4.6
...
test-suite integration
type: exitcode-stdio-1.0
main-is: SpecMain.hs
hs-source-dirs: tests/integration, webapp
other-modules: ApiSpec
default-language: Haskell2010
ghc-options: -Wall -fno-warn-orphans -threaded
build-depends: base >=4.6
...
然后我SpecMain.hs文件(相同的)包含本:
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
所以,当我运行stack test
,所有的我的测试运行,但输出没有彩色。如果我运行stack build --file-watch --test
,测试会运行,但如果有任何故障,则所有输出都将显示为红色。最后,如果我运行stack test weblog:unit
或stack test weblog:integration
,那么颜色就会完全按照它们的样子。标题为白色,通过测试为绿色,测试失败为红色,未决测试为黄色。
当我进行积极的开发时,我倾向于依靠stack build --file-watch --test
,但我真的需要颜色是正确的。
有没有人知道发生了什么,我该如何解决这个问题,或者我需要提供哪些附加信息?
哼,不能用不使用hspec-discover和Stack 1.0.4的变体重现。这就是说,你使用哪个外壳?另外,你是否尝试用'--test-arguments“--color”'手动着色输出? – Zeta
这很有趣。 'stack test --test-arguments“--color”'起作用。这会有所帮助,但是这让我对我目前的项目与其他项目有何不同之处感到困惑。 –