diff --git a/tests/integration/tests/multi-test/Main.hs b/tests/integration/tests/multi-test/Main.hs index 56f21042ea..32853b1673 100644 --- a/tests/integration/tests/multi-test/Main.hs +++ b/tests/integration/tests/multi-test/Main.hs @@ -1,17 +1,34 @@ -import Control.Monad (unless) -import Data.List (isInfixOf) -import StackTest +-- | The test's project has project packages A, B and C (which has no library). +-- +-- In terms of main libraries, the dependencies are (->- is 'depends on'): +-- +-- A ->- B +-- +-- In terms of executables (including test suites): +-- +-- B ->- A and C ->- A +-- +-- As, overall, A ->- B and B ->- A, packages A and B cannot be built +-- 'all-in-one'. +-- +-- This integration test passes when A is named myPackageA and B is named +-- 0myPackageB, but it fails when B is renamed myPackageB. That must be a bug in +-- Stack. + +import Control.Monad ( unless ) +import Data.List ( isInfixOf ) +import StackTest main :: IO () main = do - -- FIXME: Make 'clean' unnecessary (see #1411) - stack ["clean"] - stackCheckStderr ["test", "--coverage"] $ \out -> do - unless ("The coverage report for multi-test-suite's test-suite multi-test-suite-test is available at" `isInfixOf` out) $ - fail "Didn't get expected report for multi-test-suite-test" - unless ("[S-6829]" `isInfixOf` out) $ - fail "Didn't get expected empty report for multi-test-suite-test-2" - -- Test then build works too. - stack ["clean"] - stack ["test"] - stack ["build"] + -- FIXME: Make 'clean' unnecessary (see #1411) + stack ["clean"] + stackCheckStderr ["test", "--coverage"] $ \out -> do + unless ("The coverage report for myPackageA's test-suite test1 is available at" `isInfixOf` out) $ + fail "Didn't get expected report for test1" + unless ("[S-6829]" `isInfixOf` out) $ + fail "Didn't get expected empty report for test2" + -- Test then build works too. + stack ["clean"] + stack ["test"] + stack ["build"] diff --git a/tests/integration/tests/multi-test/files/.gitignore b/tests/integration/tests/multi-test/files/.gitignore new file mode 100644 index 0000000000..0f3e4a815f --- /dev/null +++ b/tests/integration/tests/multi-test/files/.gitignore @@ -0,0 +1,3 @@ +myPackageA.cabal +myPackageC.cabal +0myPackageB.cabal diff --git a/tests/integration/tests/multi-test/files/LICENSE b/tests/integration/tests/multi-test/files/LICENSE deleted file mode 100644 index d05408d876..0000000000 --- a/tests/integration/tests/multi-test/files/LICENSE +++ /dev/null @@ -1,30 +0,0 @@ -Copyright (c) 2000 - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Your name here nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tests/integration/tests/multi-test/files/Setup.hs b/tests/integration/tests/multi-test/files/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/multi-test/files/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/multi-test/files/app/Main.hs b/tests/integration/tests/multi-test/files/app/Main.hs deleted file mode 100644 index de1c1ab35c..0000000000 --- a/tests/integration/tests/multi-test/files/app/Main.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Main where - -import Lib - -main :: IO () -main = someFunc diff --git a/tests/integration/tests/multi-test/files/cyclic/Cyclic.hs b/tests/integration/tests/multi-test/files/cyclic/Cyclic.hs deleted file mode 100644 index 57c0764899..0000000000 --- a/tests/integration/tests/multi-test/files/cyclic/Cyclic.hs +++ /dev/null @@ -1,4 +0,0 @@ -module Cyclic where - -cyclic :: String -cyclic = "Hello from cyclic" diff --git a/tests/integration/tests/multi-test/files/cyclic/LICENSE b/tests/integration/tests/multi-test/files/cyclic/LICENSE deleted file mode 100644 index d05408d876..0000000000 --- a/tests/integration/tests/multi-test/files/cyclic/LICENSE +++ /dev/null @@ -1,30 +0,0 @@ -Copyright (c) 2000 - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Your name here nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tests/integration/tests/multi-test/files/cyclic/Setup.hs b/tests/integration/tests/multi-test/files/cyclic/Setup.hs deleted file mode 100644 index 9a994af677..0000000000 --- a/tests/integration/tests/multi-test/files/cyclic/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/tests/integration/tests/multi-test/files/cyclic/Spec.hs b/tests/integration/tests/multi-test/files/cyclic/Spec.hs deleted file mode 100644 index 2a7e6b6085..0000000000 --- a/tests/integration/tests/multi-test/files/cyclic/Spec.hs +++ /dev/null @@ -1,4 +0,0 @@ -import Lib (cyclicOutput) - -main :: IO () -main = cyclicOutput diff --git a/tests/integration/tests/multi-test/files/cyclic/cyclic.cabal b/tests/integration/tests/multi-test/files/cyclic/cyclic.cabal deleted file mode 100644 index 4faef11041..0000000000 --- a/tests/integration/tests/multi-test/files/cyclic/cyclic.cabal +++ /dev/null @@ -1,33 +0,0 @@ --- Initial cyclic.cabal generated by cabal init. For further --- documentation, see http://haskell.org/cabal/users-guide/ - -name: cyclic -version: 0.1.0.0 --- synopsis: --- description: --- license: -license-file: LICENSE -author: Michael Sloan -maintainer: mgsloan@gmail.com --- copyright: --- category: -build-type: Simple --- extra-source-files: -cabal-version: >=1.10 - -library - exposed-modules: Cyclic - -- other-modules: - -- other-extensions: - build-depends: base >=4.8 && <5.0 - -- hs-source-dirs: - default-language: Haskell2010 - -test-suite cyclic-test-suite - type: exitcode-stdio-1.0 - main-is: Spec.hs - build-depends: base - -- This is cyclic because multi-test-suite depends on this package. - , multi-test-suite - ghc-options: -threaded -rtsopts -with-rtsopts=-N - default-language: Haskell2010 diff --git a/tests/integration/tests/multi-test/files/multi-test-suite.cabal b/tests/integration/tests/multi-test/files/multi-test-suite.cabal deleted file mode 100644 index deb33d3572..0000000000 --- a/tests/integration/tests/multi-test/files/multi-test-suite.cabal +++ /dev/null @@ -1,58 +0,0 @@ -name: multi-test-suite -version: 0.1.0.0 -synopsis: Initial project template from stack -description: Please see README.md -homepage: http://github.com/commercialhaskell/multi-test-suite#readme -license: BSD3 -license-file: LICENSE -author: Your name here -maintainer: your.address@example.com --- copyright: -category: Web -build-type: Simple --- extra-source-files: -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5, cyclic - default-language: Haskell2010 - -executable multi-test-suite-exe - hs-source-dirs: app - main-is: Main.hs - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: base - , multi-test-suite - default-language: Haskell2010 - -test-suite multi-test-suite-test - type: exitcode-stdio-1.0 - hs-source-dirs: test - main-is: Spec.hs - build-depends: base - , multi-test-suite - ghc-options: -threaded -rtsopts -with-rtsopts=-N - default-language: Haskell2010 - -test-suite multi-test-suite-test-2 - type: exitcode-stdio-1.0 - hs-source-dirs: test-2 - main-is: Spec.hs - build-depends: base - , multi-test-suite - ghc-options: -threaded -rtsopts -with-rtsopts=-N - default-language: Haskell2010 - -test-suite multi-test-suite-test-3 - type: exitcode-stdio-1.0 - hs-source-dirs: test-3 - main-is: Spec.hs - build-depends: base - ghc-options: -threaded -rtsopts -with-rtsopts=-N - default-language: Haskell2010 - -source-repository head - type: git - location: https://github.com/commercialhaskell/multi-test-suite diff --git a/tests/integration/tests/multi-test/files/myPackageA/app/Main.hs b/tests/integration/tests/multi-test/files/myPackageA/app/Main.hs new file mode 100644 index 0000000000..df716cf71e --- /dev/null +++ b/tests/integration/tests/multi-test/files/myPackageA/app/Main.hs @@ -0,0 +1,6 @@ +module Main where + +import LibA ( funcA ) + +main :: IO () +main = funcA diff --git a/tests/integration/tests/multi-test/files/myPackageA/package.yaml b/tests/integration/tests/multi-test/files/myPackageA/package.yaml new file mode 100644 index 0000000000..7811ddfd05 --- /dev/null +++ b/tests/integration/tests/multi-test/files/myPackageA/package.yaml @@ -0,0 +1,34 @@ +spec-version: 0.36.0 + +name: myPackageA + +dependencies: +- base + +library: + source-dirs: src + dependencies: + # Only builds if this package name comes before myPackageA, alphabetically! + - 0myPackageB + +executables: + myExeA: + source-dirs: app + main: Main.hs + dependencies: + - myPackageA + +tests: + test1: + source-dirs: test1 + main: Main.hs + dependencies: + - myPackageA + test2: + source-dirs: test2 + main: Main.hs + dependencies: + - myPackageA + test3: + source-dirs: test3 + main: Main.hs diff --git a/tests/integration/tests/multi-test/files/myPackageA/src/LibA.hs b/tests/integration/tests/multi-test/files/myPackageA/src/LibA.hs new file mode 100644 index 0000000000..a7981b6f2c --- /dev/null +++ b/tests/integration/tests/multi-test/files/myPackageA/src/LibA.hs @@ -0,0 +1,9 @@ +module LibA + ( funcA + , funcB + ) where + +import LibB ( funcB ) + +funcA :: IO () +funcA = pure () diff --git a/tests/integration/tests/multi-test/files/myPackageA/test1/Main.hs b/tests/integration/tests/multi-test/files/myPackageA/test1/Main.hs new file mode 100644 index 0000000000..71c96e8fce --- /dev/null +++ b/tests/integration/tests/multi-test/files/myPackageA/test1/Main.hs @@ -0,0 +1,4 @@ +import LibA ( funcA ) + +main :: IO () +main = funcA diff --git a/tests/integration/tests/multi-test/files/test-2/Spec.hs b/tests/integration/tests/multi-test/files/myPackageA/test2/Main.hs similarity index 71% rename from tests/integration/tests/multi-test/files/test-2/Spec.hs rename to tests/integration/tests/multi-test/files/myPackageA/test2/Main.hs index c85feb952a..3ca9d54762 100644 --- a/tests/integration/tests/multi-test/files/test-2/Spec.hs +++ b/tests/integration/tests/multi-test/files/myPackageA/test2/Main.hs @@ -1,4 +1,4 @@ -import Lib +import LibA main :: IO () main = pure () diff --git a/tests/integration/tests/multi-test/files/test-3/Spec.hs b/tests/integration/tests/multi-test/files/myPackageA/test3/Main.hs similarity index 100% rename from tests/integration/tests/multi-test/files/test-3/Spec.hs rename to tests/integration/tests/multi-test/files/myPackageA/test3/Main.hs diff --git a/tests/integration/tests/multi-test/files/myPackageB/package.yaml b/tests/integration/tests/multi-test/files/myPackageB/package.yaml new file mode 100644 index 0000000000..202a258230 --- /dev/null +++ b/tests/integration/tests/multi-test/files/myPackageB/package.yaml @@ -0,0 +1,17 @@ +spec-version: 0.36.0 + +# Only builds if this package name comes before myPackageA, alphabetically! +name: 0myPackageB + +dependencies: +- base + +library: + source-dirs: src + +tests: + test: + source-dirs: test + main: Main.hs + dependencies: + - myPackageA diff --git a/tests/integration/tests/multi-test/files/myPackageB/src/LibB.hs b/tests/integration/tests/multi-test/files/myPackageB/src/LibB.hs new file mode 100644 index 0000000000..e714f965fe --- /dev/null +++ b/tests/integration/tests/multi-test/files/myPackageB/src/LibB.hs @@ -0,0 +1,6 @@ +module LibB + ( funcB + ) where + +funcB :: IO () +funcB = pure () diff --git a/tests/integration/tests/multi-test/files/myPackageB/test/Main.hs b/tests/integration/tests/multi-test/files/myPackageB/test/Main.hs new file mode 100644 index 0000000000..e7c27dd1be --- /dev/null +++ b/tests/integration/tests/multi-test/files/myPackageB/test/Main.hs @@ -0,0 +1,4 @@ +import LibA ( funcB ) + +main :: IO () +main = funcB diff --git a/tests/integration/tests/multi-test/files/myPackageC/app/Main.hs b/tests/integration/tests/multi-test/files/myPackageC/app/Main.hs new file mode 100644 index 0000000000..ca55d965a4 --- /dev/null +++ b/tests/integration/tests/multi-test/files/myPackageC/app/Main.hs @@ -0,0 +1,4 @@ +import LibC ( funcC ) + +main :: IO () +main = funcC diff --git a/tests/integration/tests/multi-test/files/myPackageC/package.yaml b/tests/integration/tests/multi-test/files/myPackageC/package.yaml new file mode 100644 index 0000000000..629f8cba45 --- /dev/null +++ b/tests/integration/tests/multi-test/files/myPackageC/package.yaml @@ -0,0 +1,22 @@ +spec-version: 0.36.0 + +name: myPackageC + +dependencies: +- base + +executables: + myExeC: + source-dirs: + - app + - src + main: Main.hs + +tests: + test: + source-dirs: + - src + - test + main: Main.hs + dependencies: + - myPackageA diff --git a/tests/integration/tests/multi-test/files/myPackageC/src/LibC.hs b/tests/integration/tests/multi-test/files/myPackageC/src/LibC.hs new file mode 100644 index 0000000000..6289d8843d --- /dev/null +++ b/tests/integration/tests/multi-test/files/myPackageC/src/LibC.hs @@ -0,0 +1,6 @@ +module LibC + ( funcC + ) where + +funcC :: IO () +funcC = pure () diff --git a/tests/integration/tests/multi-test/files/myPackageC/test/Main.hs b/tests/integration/tests/multi-test/files/myPackageC/test/Main.hs new file mode 100644 index 0000000000..0535c37e44 --- /dev/null +++ b/tests/integration/tests/multi-test/files/myPackageC/test/Main.hs @@ -0,0 +1,7 @@ +import LibA ( funcA ) +import LibC ( funcC ) + +main :: IO () +main = do + funcA + funcC diff --git a/tests/integration/tests/multi-test/files/src/Lib.hs b/tests/integration/tests/multi-test/files/src/Lib.hs deleted file mode 100644 index dc9643b828..0000000000 --- a/tests/integration/tests/multi-test/files/src/Lib.hs +++ /dev/null @@ -1,16 +0,0 @@ -module Lib - ( someFunc - , someOtherFunc - , cyclicOutput - ) where - -import Cyclic - -someFunc :: IO () -someFunc = putStrLn "someFunc" - -someOtherFunc :: IO () -someOtherFunc = putStrLn "someOtherFunc" - -cyclicOutput :: IO () -cyclicOutput = putStrLn cyclic diff --git a/tests/integration/tests/multi-test/files/stack.yaml b/tests/integration/tests/multi-test/files/stack.yaml index 002c22aefd..14a33de5df 100644 --- a/tests/integration/tests/multi-test/files/stack.yaml +++ b/tests/integration/tests/multi-test/files/stack.yaml @@ -1,5 +1,6 @@ -snapshot: lts-24.37 +snapshot: ghc-9.10.3 + packages: -- . -- sub-package -- cyclic +- myPackageA +- myPackageB +- myPackageC diff --git a/tests/integration/tests/multi-test/files/sub-package/src/Lib2.hs b/tests/integration/tests/multi-test/files/sub-package/src/Lib2.hs deleted file mode 100644 index 92ce236d56..0000000000 --- a/tests/integration/tests/multi-test/files/sub-package/src/Lib2.hs +++ /dev/null @@ -1,4 +0,0 @@ -module Lib2 where - -lib2 :: IO () -lib2 = putStrLn "lib2" diff --git a/tests/integration/tests/multi-test/files/sub-package/src/main.hs b/tests/integration/tests/multi-test/files/sub-package/src/main.hs deleted file mode 100644 index e84bf058a8..0000000000 --- a/tests/integration/tests/multi-test/files/sub-package/src/main.hs +++ /dev/null @@ -1,3 +0,0 @@ -import Lib2 - -main = lib2 diff --git a/tests/integration/tests/multi-test/files/sub-package/sub-package.cabal b/tests/integration/tests/multi-test/files/sub-package/sub-package.cabal deleted file mode 100644 index 0e94272961..0000000000 --- a/tests/integration/tests/multi-test/files/sub-package/sub-package.cabal +++ /dev/null @@ -1,31 +0,0 @@ -name: sub-package -version: 0.1.0.0 -synopsis: Initial project template from stack -description: Please see README.md -homepage: http://github.com/commercialhaskell/multi-test-suite#readme -license: BSD3 -license-file: ../LICENSE -author: Your name here -maintainer: your.address@example.com --- copyright: -category: Web -build-type: Simple --- extra-source-files: -cabal-version: >=1.10 - -executable sub-package-exe - hs-source-dirs: src - main-is: main.hs - other-modules: Lib2 - build-depends: base >= 4.7 && < 5 - default-language: Haskell2010 - -test-suite sub-package-test - type: exitcode-stdio-1.0 - hs-source-dirs: src, test - main-is: Spec.hs - other-modules: Lib2 - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: base - , multi-test-suite - default-language: Haskell2010 diff --git a/tests/integration/tests/multi-test/files/sub-package/test/Spec.hs b/tests/integration/tests/multi-test/files/sub-package/test/Spec.hs deleted file mode 100644 index 87852a7dec..0000000000 --- a/tests/integration/tests/multi-test/files/sub-package/test/Spec.hs +++ /dev/null @@ -1,7 +0,0 @@ -import Lib -import Lib2 - -main :: IO () -main = do - someOtherFunc - lib2 diff --git a/tests/integration/tests/multi-test/files/test/OtherModule.hs b/tests/integration/tests/multi-test/files/test/OtherModule.hs deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/integration/tests/multi-test/files/test/Spec.hs b/tests/integration/tests/multi-test/files/test/Spec.hs deleted file mode 100644 index 7153edaf67..0000000000 --- a/tests/integration/tests/multi-test/files/test/Spec.hs +++ /dev/null @@ -1,4 +0,0 @@ -import Lib - -main :: IO () -main = someFunc