Skip to content
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

Fix a Windows build error in the test suite #288

Merged
merged 2 commits into from
Nov 17, 2022
Merged

Conversation

RyanGlScott
Copy link
Contributor

The definition of withApp was mistakenly guarded behind CPP that is not reachable on Windows, but withApp is also needed outside of the CPP:

[1 of 2] Compiling Web.ScottySpec   ( test\Web\ScottySpec.hs, C:\\msys64\home\winferno\scotty\dist-newstyle\build\x86_64-windows\ghc-9.4.2\scotty-0.12\t\spec\build\spec\spec-tmp\Web\ScottySpec.o )

test\Web\ScottySpec.hs:49:9: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> SpecWith (st19, Network.Wai.Application)
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM () a9
   |
49 |         withApp (route "/scotty" $ html "") $ do
   |         ^^^^^^^

test\Web\ScottySpec.hs:53:9: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> SpecWith (st19, Network.Wai.Application)
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM () ()
   |
53 |         withApp (route "/scotty" $ html "") $ do
   |         ^^^^^^^

test\Web\ScottySpec.hs:59:9: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> SpecWith (st18, Network.Wai.Application)
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM () b0
   |
59 |         withApp (addroute method "/scotty" $ html "") $ do
   |         ^^^^^^^

test\Web\ScottySpec.hs:64:7: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM
                (st17, Network.Wai.Application) ()
           -> SpecWith ()
   |
64 |       withApp (matchAny "/scotty" $ html "") $ do
   |       ^^^^^^^

test\Web\ScottySpec.hs:70:7: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> SpecWith (st16, Network.Wai.Application)
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM () a8
   |
70 |       withApp (notFound $ html "my custom not found page") $ do
   |       ^^^^^^^

test\Web\ScottySpec.hs:74:7: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> SpecWith (st15, Network.Wai.Application)
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM () a7
   |
74 |       withApp (notFound $ status status400 >> html "my custom not found page") $ do
   |       ^^^^^^^

test\Web\ScottySpec.hs:79:9: error:
    Variable not in scope:
      withApp
        :: m0 () -> SpecWith (st14, Network.Wai.Application) -> SpecWith ()
   |
79 |         withApp (return ()) $ do
   |         ^^^^^^^

test\Web\ScottySpec.hs:84:7: error:
    Variable not in scope:
      withApp
        :: Web.Scotty.Internal.Types.ScottyT TL.Text IO ()
           -> SpecWith (st13, Network.Wai.Application)
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM () a6
   |
84 |       withApp (defaultHandler text >> Scotty.get "/" (liftAndCatchIO $ E.throwIO E.DivideByZero)) $ do
   |       ^^^^^^^

test\Web\ScottySpec.hs:88:7: error:
    Variable not in scope:
      withApp
        :: Web.Scotty.Internal.Types.ScottyT TL.Text IO ()
           -> SpecWith (st12, Network.Wai.Application)
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM () a5
   |
88 |       withApp (defaultHandler (\_ -> status status503) >> Scotty.get "/" (liftAndCatchIO $ E.throwIO E.DivideByZero)) $ do
   |       ^^^^^^^

test\Web\ScottySpec.hs:93:9: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> SpecWith (st11, Network.Wai.Application) -> SpecWith ()
   |
93 |         withApp (Scotty.get "/" $ liftAndCatchIO $ E.throwIO E.DivideByZero) $ do
   |         ^^^^^^^

test\Web\ScottySpec.hs:98:5: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> SpecWith (st10, Network.Wai.Application)
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM () a4
   |
98 |     withApp (Scotty.get "/" $ (undefined `EL.catch` ((\_ -> html "") :: E.SomeException -> ActionM ()))) $ do
   |     ^^^^^^^

test\Web\ScottySpec.hs:102:5: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> SpecWith (st9, Network.Wai.Application)
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM () a3
    |
102 |     withApp (Scotty.get "/dictionary" $ empty <|> param "word1" <|> empty <|> param "word2" >>= text) $
    |     ^^^^^^^

test\Web\ScottySpec.hs:109:7: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM
                (st8, Network.Wai.Application) ()
           -> SpecWith ()
    |
109 |       withApp (Scotty.matchAny "/search" $ param "query" >>= text) $ do
    |       ^^^^^^^

test\Web\ScottySpec.hs:122:7: error:
    Variable not in scope:
      withApp
        :: Web.Scotty.Internal.Types.ScottyT TL.Text IO ()
           -> SpecWith (st7, Network.Wai.Application) -> SpecWith ()
    |
122 |       withApp (Scotty.setMaxRequestBodySize 1 >> Scotty.matchAny "/upload" (do status status200)) $ do
    |       ^^^^^^^

test\Web\ScottySpec.hs:133:7: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM
                (st6, Network.Wai.Application) ()
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM () a2
    |
133 |       withApp (Scotty.get "/scotty" $ text modernGreekText) $ do
    |       ^^^^^^^

test\Web\ScottySpec.hs:140:7: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> SpecWith (st5, Network.Wai.Application)
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM () ()
    |
140 |       withApp (Scotty.get "/scotty" $ setHeader "Content-Type" "text/somethingweird" >> text modernGreekText) $ do
    |       ^^^^^^^

test\Web\ScottySpec.hs:148:7: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM
                (st4, Network.Wai.Application) ()
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM () a1
    |
148 |       withApp (Scotty.get "/scotty" $ html russianLanguageTextInHtml) $ do
    |       ^^^^^^^

test\Web\ScottySpec.hs:155:7: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> SpecWith (st3, Network.Wai.Application)
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM () ()
    |
155 |       withApp (Scotty.get "/scotty" $ setHeader "Content-Type" "text/somethingweird" >> html russianLanguageTextInHtml) $ do
    |       ^^^^^^^

test\Web\ScottySpec.hs:160:7: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> SpecWith (st2, Network.Wai.Application) -> SpecWith ()
    |
160 |       withApp (Scotty.get "/scotty" $ setHeader "Content-Type" "text/somethingweird" >> json (Just (5::Int))) $ do
    |       ^^^^^^^

test\Web\ScottySpec.hs:165:7: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> SpecWith (st1, Network.Wai.Application)
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM () a0
    |
165 |       withApp (Scotty.get "/scotty" $ finish) $ do
    |       ^^^^^^^

test\Web\ScottySpec.hs:169:7: error:
    Variable not in scope:
      withApp
        :: ScottyM ()
           -> SpecWith (st0, Network.Wai.Application)
           -> hspec-core-2.10.5:Test.Hspec.Core.Spec.Monad.SpecM () ()
    |
169 |       withApp (Scotty.get "/scotty" $ status status400 >> finish >> status status200) $ do
    |       ^^^^^^^

The definition of `withApp` was mistakenly guarded behind CPP that is not
reachable on Windows, but `withApp` is also needed outside of the CPP.
@friedbrice
Copy link
Member

Thank you!

@friedbrice
Copy link
Member

actually, let me change the version number before we merge this... <.<

@friedbrice friedbrice merged commit ff4fa83 into master Nov 17, 2022
@friedbrice friedbrice deleted the fix-windows-build branch November 17, 2022 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants