|
1 | | --- Stack should explain likely Backpack signature mistakes with a Backpack |
2 | | --- warning, not the custom-preprocessor warning. |
| 1 | +-- | Stack explains likely Backpack signature mistakes with a useful warning, |
| 2 | +-- and not an inappropriate warning about custom preprocessors. |
| 3 | +-- |
| 4 | +-- See: https://github.com/commercialhaskell/stack/issues/6937 |
3 | 5 |
|
4 | | -import Control.Monad ( unless, when ) |
5 | | -import Data.List ( isInfixOf ) |
6 | | -import StackTest |
| 6 | +import Control.Monad ( unless, when ) |
| 7 | +import Data.List ( isInfixOf ) |
| 8 | +import StackTest |
7 | 9 |
|
8 | 10 | main :: IO () |
9 | 11 | main = |
10 | 12 | stackErrStderr ["build"] $ \err -> do |
11 | | - expect err "Found Backpack signature file for Cabal entry" |
12 | | - expect err "Logger" |
13 | | - expect err "not listed in the component's" |
14 | | - expect err "signatures" |
| 13 | + expectMessage "Found Backpack signature file for Cabal entry" err |
| 14 | + expectMessage "Logger" err |
| 15 | + expectMessage "not listed in the component's" err |
| 16 | + expectMessage "signatures" err |
15 | 17 | when ("custom-preprocessor-extensions" `isInfixOf` err) $ |
16 | 18 | error $ |
17 | | - "Expected no custom-preprocessor warning for Logger.hsig, got: " |
18 | | - ++ show err |
| 19 | + "Expected no custom-preprocessor warning for Logger.hsig, got:\n\n" |
| 20 | + ++ err |
19 | 21 |
|
20 | | -expect :: String -> String -> IO () |
21 | | -expect err msg = |
22 | | - unless (msg `isInfixOf` err) $ |
23 | | - error $ "Expected " ++ show msg ++ " in stderr, got: " ++ show err |
| 22 | +expectMessage :: String -> String -> IO () |
| 23 | +expectMessage msg stderr = do |
| 24 | + unless (words msg `isInfixOf` words stderr) $ |
| 25 | + error $ "Expected " ++ show msg ++ " in stderr, got:\n\n" ++ stderr |
0 commit comments