這是一件令人氣憤的事情,因爲我已經構建了基於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」'起作用。這會有所幫助,但是這讓我對我目前的項目與其他項目有何不同之處感到困惑。 –