diff --git a/cabal-testsuite/PackageTests/Configure/include/HsZlibConfig.h.in b/cabal-testsuite/PackageTests/Configure/include/HsZlibConfig.h.in index aa500c7d2ce..b276a09c56f 100644 --- a/cabal-testsuite/PackageTests/Configure/include/HsZlibConfig.h.in +++ b/cabal-testsuite/PackageTests/Configure/include/HsZlibConfig.h.in @@ -3,12 +3,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_STDIO_H + /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H @@ -45,5 +45,7 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* Define to 1 if you have the ANSI C header files. */ +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ #undef STDC_HEADERS diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/A.cabal b/cabal-testsuite/PackageTests/ShowBuildInfo/A/A.cabal index 5a1e2977b66..a1420d9676e 100644 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/A/A.cabal +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/A/A.cabal @@ -18,6 +18,6 @@ executable A test-suite A-tests type: exitcode-stdio-1.0 main-is: Test.hs - build-depends: base >=4 + build-depends: base >=4, A hs-source-dirs: src default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/B/B.cabal b/cabal-testsuite/PackageTests/ShowBuildInfo/A/B/B.cabal similarity index 79% rename from cabal-testsuite/PackageTests/ShowBuildInfo/B/B.cabal rename to cabal-testsuite/PackageTests/ShowBuildInfo/A/B/B.cabal index 1400971ae35..e81b9eb3a1d 100644 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/B/B.cabal +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/A/B/B.cabal @@ -4,7 +4,7 @@ version: 0.1.0.0 license: BSD-3-Clause library - exposed-modules: A + exposed-modules: B build-depends: base >=4.0.0.0, A - hs-source-dirs: src + hs-source-dirs: lib default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/B/src/A.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/A/B/lib/A.hs similarity index 65% rename from cabal-testsuite/PackageTests/ShowBuildInfo/B/src/A.hs rename to cabal-testsuite/PackageTests/ShowBuildInfo/A/B/lib/A.hs index 6b02eec8ec0..8b74dfe6b43 100644 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/B/src/A.hs +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/A/B/lib/A.hs @@ -1,4 +1,4 @@ -module A where +module B where foo :: Int -> Int foo = id diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/Setup.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/A/Setup.hs deleted file mode 100644 index 9a994af677b..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/A/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-exe-exact.out b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-B-lib.out similarity index 100% rename from cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-exe-exact.out rename to cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-B-lib.out diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-B-lib.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-B-lib.test.hs new file mode 100644 index 00000000000..f3ad330757e --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-B-lib.test.hs @@ -0,0 +1,9 @@ +import Test.Cabal.Prelude +import Test.Cabal.DecodeShowBuildInfo + +main = cabalTest $ do + buildInfo <- runShowBuildInfo ["lib:B"] + assertCommonBuildInfo buildInfo + assertEqual "Number of Components" 1 (length $ components buildInfo) + let [libComp] = components buildInfo + assertLibComponent libComp "lib" ["B"] ["lib"] \ No newline at end of file diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-exact-unit-id-file.out b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-B-outer-lib.out similarity index 100% rename from cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-exact-unit-id-file.out rename to cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-B-outer-lib.out diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-B-outer-lib.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-B-outer-lib.test.hs new file mode 100644 index 00000000000..cbe6553cedb --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-B-outer-lib.test.hs @@ -0,0 +1,10 @@ +import Test.Cabal.Prelude +import Test.Cabal.DecodeShowBuildInfo + +main = cabalTest $ do + buildInfo <- runShowBuildInfo ["lib:B", "lib:A"] + assertCommonBuildInfo buildInfo + assertEqual "Number of Components" 2 (length $ components buildInfo) + let [libAComp, libBComp] = components buildInfo + assertLibComponent libAComp "lib" ["A"] ["src"] + assertLibComponent libBComp "lib" ["B"] ["lib"] diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-all.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-all.test.hs index aa2d0142358..ce34607f1b4 100644 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-all.test.hs +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-all.test.hs @@ -2,8 +2,11 @@ import Test.Cabal.Prelude import Test.Cabal.DecodeShowBuildInfo main = cabalTest $ do - buildInfo <- runShowBuildInfo ["-v0"] -- hide verbose output so we can parse - let comps = components buildInfo - assertEqual "Components, exactly three" 3 (length comps) - assertEqual "Test components, exactly one" 1 $ - length $ filter (\c -> "test" == componentType c) comps + buildInfo <- runShowBuildInfo ["all", "--enable-tests"] + assertCommonBuildInfo buildInfo + assertEqual "Number of Components" 4 (length $ components buildInfo) + let [libAComp, exeComp, testComp, libBComp] = components buildInfo + assertExeComponent exeComp "exe:A" ["Main.hs"] ["src"] + assertLibComponent libAComp "lib" ["A"] ["src"] + assertLibComponent libBComp "lib" ["B"] ["lib"] + assertTestComponent testComp "test:A-tests" ["Test.hs"] ["src"] diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-exe-exact.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-exe-exact.test.hs deleted file mode 100644 index 66c0d3bfd32..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-exe-exact.test.hs +++ /dev/null @@ -1,18 +0,0 @@ -import Test.Cabal.Prelude -import Test.Cabal.DecodeShowBuildInfo - -main = cabalTest $ do - buildInfo <- runShowBuildInfo ["exe:A", "-v0"] - assertEqual "Cabal Version" cabalVersionLibrary (cabalVersion buildInfo) - assertEqual "Compiler flavour" "ghc" (flavour $ compiler buildInfo) - assertBool "Compiler id" (and $ zipWith (==) "ghc" (compilerId $ compiler buildInfo)) - assertBool "Compiler path non-empty" (not . null . path $ compiler buildInfo) - assertEqual "Components, exactly one" 1 (length $ components buildInfo) - let [component] = components buildInfo - assertEqual "Component type" "exe" (componentType component) - assertEqual "Component name" "exe:A" (componentName component) - assertEqual "Component unit-id" "A-0.1.0.0-inplace-A" (componentUnitId component) - assertBool "Component compiler args are non-empty" (not . null $ componentCompilerArgs component) - assertEqual "Component modules" [] (componentModules component) - assertEqual "Component source files" ["Main.hs"] (componentSrcFiles component) - assertEqual "Component source directories" ["src"] (componentHsSrcDirs component) diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-exact-unit-id.out b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-exe.out similarity index 100% rename from cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-exact-unit-id.out rename to cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-exe.out diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-exe.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-exe.test.hs new file mode 100644 index 00000000000..213de15a7e4 --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-exe.test.hs @@ -0,0 +1,13 @@ +import Test.Cabal.Prelude +import Test.Cabal.DecodeShowBuildInfo + +main = cabalTest $ do + buildInfo <- runShowBuildInfo ["exe:A"] + assertCommonBuildInfo buildInfo + assertEqual "Number of Components" 1 (length $ components buildInfo) + let [exeComp] = components buildInfo + assertExeComponent exeComp "exe:A" ["Main.hs"] ["src"] + + -- Must not have library as a dependency as "exe:A" does not depend on it. + assertBool "Does not contain library as dependency" + (all (/= "A-0.1.0.0-inplace") $ componentCompilerArgs exeComp) \ No newline at end of file diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-exact-unit-id-file.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-exact-unit-id-file.test.hs deleted file mode 100644 index 1c710f65022..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-exact-unit-id-file.test.hs +++ /dev/null @@ -1,36 +0,0 @@ -import Test.Cabal.Prelude -import Test.Cabal.DecodeShowBuildInfo - -main = cabalTest $ withSourceCopy $ do - cwd <- fmap testCurrentDir getTestEnv - let fp = cwd "unit.json" - _ <- cabal' "show-build-info" ["--buildinfo-json-output=" ++ fp, "--unit-ids-json=A-0.1.0.0-inplace A-0.1.0.0-inplace-A", "-v0"] - buildInfo <- decodeBuildInfoFile fp - assertEqual "Cabal Version" cabalVersionLibrary (cabalVersion buildInfo) - assertEqual "Compiler flavour" "ghc" (flavour $ compiler buildInfo) - assertBool "Compiler id" (and $ zipWith (==) "ghc" (compilerId $ compiler buildInfo)) - assertBool "Compiler path non-empty" (not . null . path $ compiler buildInfo) - assertEqual "Components, exactly two" 2 (length $ components buildInfo) - let [libBuildInfo, exeBuildInfo] = components buildInfo - assertExe exeBuildInfo - assertLib libBuildInfo - where - assertExe :: ComponentInfo -> TestM () - assertExe component = do - assertEqual "Component type" "exe" (componentType component) - assertEqual "Component name" "exe:A" (componentName component) - assertEqual "Component unit-id" "A-0.1.0.0-inplace-A" (componentUnitId component) - assertBool "Component compiler args are non-empty" (not . null $ componentCompilerArgs component) - assertEqual "Component modules" [] (componentModules component) - assertEqual "Component source files" ["Main.hs"] (componentSrcFiles component) - assertEqual "Component source directories" ["src"] (componentHsSrcDirs component) - - assertLib :: ComponentInfo -> TestM () - assertLib component = do - assertEqual "Component type" "lib" (componentType component) - assertEqual "Component name" "lib" (componentName component) - assertEqual "Component unit-id" "A-0.1.0.0-inplace" (componentUnitId component) - assertBool "Component compiler args are non-empty" (not . null $ componentCompilerArgs component) - assertEqual "Component modules" ["A"] (componentModules component) - assertEqual "Component source files" [] (componentSrcFiles component) - assertEqual "Component source directories" ["src"] (componentHsSrcDirs component) diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-exact-unit-id.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-exact-unit-id.test.hs deleted file mode 100644 index 0816c11abd3..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-exact-unit-id.test.hs +++ /dev/null @@ -1,32 +0,0 @@ -import Test.Cabal.Prelude -import Test.Cabal.DecodeShowBuildInfo - -main = cabalTest $ do - buildInfo <- runShowBuildInfo ["--unit-ids-json=A-0.1.0.0-inplace A-0.1.0.0-inplace-A", "-v0"] - assertEqual "Cabal Version" cabalVersionLibrary (cabalVersion buildInfo) - assertEqual "Compiler flavour" "ghc" (flavour $ compiler buildInfo) - assertBool "Compiler id" (and $ zipWith (==) "ghc" (compilerId $ compiler buildInfo)) - assertBool "Compiler path non-empty" (not . null . path $ compiler buildInfo) - let [libBuildInfo, exeBuildInfo] = components buildInfo - assertExe exeBuildInfo - assertLib libBuildInfo - where - assertExe :: ComponentInfo -> TestM () - assertExe component = do - assertEqual "Component type" "exe" (componentType component) - assertEqual "Component name" "exe:A" (componentName component) - assertEqual "Component unit-id" "A-0.1.0.0-inplace-A" (componentUnitId component) - assertBool "Component compiler args are non-empty" (not . null $ componentCompilerArgs component) - assertEqual "Component modules" [] (componentModules component) - assertEqual "Component source files" ["Main.hs"] (componentSrcFiles component) - assertEqual "Component source directories" ["src"] (componentHsSrcDirs component) - - assertLib :: ComponentInfo -> TestM () - assertLib component = do - assertEqual "Component type" "lib" (componentType component) - assertEqual "Component name" "lib" (componentName component) - assertEqual "Component unit-id" "A-0.1.0.0-inplace" (componentUnitId component) - assertBool "Component compiler args are non-empty" (not . null $ componentCompilerArgs component) - assertEqual "Component modules" ["A"] (componentModules component) - assertEqual "Component source files" [] (componentSrcFiles component) - assertEqual "Component source directories" ["src"] (componentHsSrcDirs component) diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-exact.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-exact.test.hs deleted file mode 100644 index 880fe8ac71b..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-exact.test.hs +++ /dev/null @@ -1,32 +0,0 @@ -import Test.Cabal.Prelude -import Test.Cabal.DecodeShowBuildInfo - -main = cabalTest $ do - buildInfo <- runShowBuildInfo ["exe:A", "lib:A", "-v0"] - assertEqual "Cabal Version" cabalVersionLibrary (cabalVersion buildInfo) - assertEqual "Compiler flavour" "ghc" (flavour $ compiler buildInfo) - assertBool "Compiler id" (and $ zipWith (==) "ghc" (compilerId $ compiler buildInfo)) - assertBool "Compiler path non-empty" (not . null . path $ compiler buildInfo) - let [libBuildInfo, exeBuildInfo] = components buildInfo - assertExe exeBuildInfo - assertLib libBuildInfo - where - assertExe :: ComponentInfo -> TestM () - assertExe component = do - assertEqual "Component type" "exe" (componentType component) - assertEqual "Component name" "exe:A" (componentName component) - assertEqual "Component unit-id" "A-0.1.0.0-inplace-A" (componentUnitId component) - assertBool "Component compiler args are non-empty" (not . null $ componentCompilerArgs component) - assertEqual "Component modules" [] (componentModules component) - assertEqual "Component source files" ["Main.hs"] (componentSrcFiles component) - assertEqual "Component source directories" ["src"] (componentHsSrcDirs component) - - assertLib :: ComponentInfo -> TestM () - assertLib component = do - assertEqual "Component type" "lib" (componentType component) - assertEqual "Component name" "lib" (componentName component) - assertEqual "Component unit-id" "A-0.1.0.0-inplace" (componentUnitId component) - assertBool "Component compiler args are non-empty" (not . null $ componentCompilerArgs component) - assertEqual "Component modules" ["A"] (componentModules component) - assertEqual "Component source files" [] (componentSrcFiles component) - assertEqual "Component source directories" ["src"] (componentHsSrcDirs component) diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-targets-file.out b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-targets-file.out new file mode 100644 index 00000000000..3b4215e5719 --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-targets-file.out @@ -0,0 +1,4 @@ +# cabal show-build-info +Resolving dependencies... +Configuring library for A-0.1.0.0.. +Configuring executable 'A' for A-0.1.0.0.. diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-targets-file.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-targets-file.test.hs new file mode 100644 index 00000000000..f0160428fd7 --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-targets-file.test.hs @@ -0,0 +1,13 @@ +import Test.Cabal.Prelude +import Test.Cabal.DecodeShowBuildInfo + +main = cabalTest $ withSourceCopy $ do + cwd <- fmap testCurrentDir getTestEnv + let fp = cwd "unit.json" + _ <- cabal' "show-build-info" ["--buildinfo-json-output=" ++ fp, "exe:A", "lib:A"] + buildInfo <- decodeBuildInfoFile fp + assertCommonBuildInfo buildInfo + assertEqual "Number of Components" 2 (length $ components buildInfo) + let [libBuildInfo, exeBuildInfo] = components buildInfo + assertExeComponent exeBuildInfo "exe:A" ["Main.hs"] ["src"] + assertLibComponent libBuildInfo "lib" ["A"] ["src"] diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-exact.out b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-targets.out similarity index 100% rename from cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-exact.out rename to cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-targets.out diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-targets.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-targets.test.hs new file mode 100644 index 00000000000..4ab4185b8be --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-multiple-targets.test.hs @@ -0,0 +1,9 @@ +import Test.Cabal.Prelude +import Test.Cabal.DecodeShowBuildInfo + +main = cabalTest $ do + buildInfo <- runShowBuildInfo ["exe:A", "lib:A"] + assertCommonBuildInfo buildInfo + let [libBuildInfo, exeBuildInfo] = components buildInfo + assertExeComponent exeBuildInfo "exe:A" ["Main.hs"] ["src"] + assertLibComponent libBuildInfo "lib" ["A"] ["src"] \ No newline at end of file diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/B/build-info-lib-exact.out b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-no-target.out similarity index 100% rename from cabal-testsuite/PackageTests/ShowBuildInfo/B/build-info-lib-exact.out rename to cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-no-target.out diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-no-target.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-no-target.test.hs new file mode 100644 index 00000000000..6e11334d323 --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-no-target.test.hs @@ -0,0 +1,12 @@ +import Test.Cabal.Prelude +import Test.Cabal.DecodeShowBuildInfo + +main = cabalTest $ do + buildInfo <- runShowBuildInfo [] + assertCommonBuildInfo buildInfo + let comps = components buildInfo + assertEqual "Number of Components" 2 (length comps) + assertBool "Contains main component executable" + (any (\c -> "exe:A" == componentName c) comps) + assertBool "Contains main component library" + (any (\c -> "lib" == componentName c) comps) diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/C/build-info-all-internal-deps.out b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-test.out similarity index 100% rename from cabal-testsuite/PackageTests/ShowBuildInfo/C/build-info-all-internal-deps.out rename to cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-test.out diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-test.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-test.test.hs new file mode 100644 index 00000000000..1d1df200639 --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-test.test.hs @@ -0,0 +1,13 @@ +import Test.Cabal.Prelude +import Test.Cabal.DecodeShowBuildInfo + +main = cabalTest $ do + buildInfo <- runShowBuildInfo ["test:A-tests"] + assertCommonBuildInfo buildInfo + assertEqual "Number of Components" 1 (length $ components buildInfo) + let [testComp] = components buildInfo + assertTestComponent testComp "test:A-tests" ["Test.hs"] ["src"] + + -- Must have library as a dependency as "test:A-tests" depends on it. + assertBool "Contains internal dependency" + (any (== "A-0.1.0.0-inplace") $ componentCompilerArgs testComp) diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-unknown.out b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-unknown.out index 72752bfec16..53db13639c8 100644 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-unknown.out +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-unknown.out @@ -1,11 +1,4 @@ # cabal show-build-info -cabal: Internal error in target matching. It should always be possible to find a syntax that's sufficiently qualified to give an unambiguous match. However when matching 'exe:B' we found exe:B (unknown-component) which does not have an unambiguous syntax. The possible syntax and the targets they match are as follows: -'exe:B' which matches exe:B (unknown-component), :pkg:exe:lib:exe:module:B (unknown-module), :pkg:exe:lib:exe:file:B (unknown-file) # cabal show-build-info -Resolving dependencies... -cabal: No unit B-inplace-0.1.0.0 # cabal show-build-info -cabal: No unit B-inplace-0.1.0.0 # cabal show-build-info -cabal: Internal error in target matching. It should always be possible to find a syntax that's sufficiently qualified to give an unambiguous match. However when matching 'exe:B' we found exe:B (unknown-component) which does not have an unambiguous syntax. The possible syntax and the targets they match are as follows: -'exe:B' which matches exe:B (unknown-component), :pkg:exe:lib:exe:module:B (unknown-module), :pkg:exe:lib:exe:file:B (unknown-file) diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-unknown.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-unknown.test.hs index b07607b3779..20ef51ac600 100644 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-unknown.test.hs +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/A/build-info-unknown.test.hs @@ -1,14 +1,15 @@ import Test.Cabal.Prelude main = cabalTest $ do - r <- fails $ cabal' "show-build-info" ["exe:B"] + r <- fails $ cabal' "show-build-info" ["exe:B", "-v1"] assertOutputContains "Internal error in target matching." r - r <- fails $ cabal' "show-build-info" ["--unit-ids-json=B-inplace-0.1.0.0"] - assertOutputContains "No unit B-inplace-0.1.0.0" r + r <- fails $ cabal' "show-build-info" ["C", "-v1"] + assertOutputContains "Cannot show-build-info the package C, it is not in this project (either directly or indirectly)." r - r <- fails $ cabal' "show-build-info" ["--unit-ids-json=A-0.1.0.0-inplace B-inplace-0.1.0.0"] - assertOutputContains "No unit B-inplace-0.1.0.0" r - - r <- fails $ cabal' "show-build-info" ["--unit-ids-json=A-0.1.0.0-inplace", "exe:B"] + r <- fails $ cabal' "show-build-info" ["lib:C", "-v1"] assertOutputContains "Internal error in target matching." r + + r <- fails $ cabal' "show-build-info" ["benchmarks", "-v1"] + assertOutputContains "Cannot show-build-info the benchmarks in the package A-0.1.0.0 because it does not contain any benchmarks." r + diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/A/cabal.project b/cabal-testsuite/PackageTests/ShowBuildInfo/A/cabal.project index e6fdbadb439..9a091f69b3b 100644 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/A/cabal.project +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/A/cabal.project @@ -1 +1 @@ -packages: . +packages: . ./B/ diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/B/Setup.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/B/Setup.hs deleted file mode 100644 index 9a994af677b..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/B/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/B/build-info-lib-exact.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/B/build-info-lib-exact.test.hs deleted file mode 100644 index c836df828ca..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/B/build-info-lib-exact.test.hs +++ /dev/null @@ -1,18 +0,0 @@ -import Test.Cabal.Prelude -import Test.Cabal.DecodeShowBuildInfo - -main = cabalTest $ do - buildInfo <- runShowBuildInfo ["lib:B", "-v0"] - assertEqual "Cabal Version" cabalVersionLibrary (cabalVersion buildInfo) - assertEqual "Compiler flavour" "ghc" (flavour $ compiler buildInfo) - assertBool "Compiler id" (and $ zipWith (==) "ghc" (compilerId $ compiler buildInfo)) - assertBool "Compiler path non-empty" (not . null . path $ compiler buildInfo) - assertEqual "Components, exactly one" 1 (length $ components buildInfo) - let [component] = components buildInfo - assertEqual "Component type" "lib" (componentType component) - assertEqual "Component name" "lib" (componentName component) - assertEqual "Component unit-id" "B-0.1.0.0-inplace" (componentUnitId component) - assertBool "Component compiler args are non-empty" (not . null $ componentCompilerArgs component) - assertEqual "Component modules" ["A"] (componentModules component) - assertEqual "Component source files" [] (componentSrcFiles component) - assertEqual "Component source directories" ["src"] (componentHsSrcDirs component) diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/B/cabal.project b/cabal-testsuite/PackageTests/ShowBuildInfo/B/cabal.project deleted file mode 100644 index b957b20d5c5..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/B/cabal.project +++ /dev/null @@ -1,2 +0,0 @@ -packages: . - ../A diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/C/C.cabal b/cabal-testsuite/PackageTests/ShowBuildInfo/C/C.cabal deleted file mode 100644 index 6fe31714e7a..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/C/C.cabal +++ /dev/null @@ -1,15 +0,0 @@ -cabal-version: 2.4 -name: C -version: 0.1.0.0 -license: BSD-3-Clause - -library - exposed-modules: Lib - build-depends: base - default-language: Haskell2010 - -test-suite tests - type: exitcode-stdio-1.0 - main-is: Test.hs - build-depends: base, C - default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/C/Lib.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/C/Lib.hs deleted file mode 100644 index 12f5889322c..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/C/Lib.hs +++ /dev/null @@ -1,3 +0,0 @@ -module Lib where - -f = 42 diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/C/Test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/C/Test.hs deleted file mode 100644 index 76a9bdb5d48..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/C/Test.hs +++ /dev/null @@ -1 +0,0 @@ -main = pure () diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/C/build-info-all-internal-deps.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/C/build-info-all-internal-deps.test.hs deleted file mode 100644 index db3e0adfd2b..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/C/build-info-all-internal-deps.test.hs +++ /dev/null @@ -1,9 +0,0 @@ -import Test.Cabal.Prelude -import Test.Cabal.DecodeShowBuildInfo - -main = cabalTest $ do - buildInfo <- runShowBuildInfo ["-v0"] - let comps = components buildInfo - assertEqual "Components, exactly three" 2 (length comps) - assertEqual "Test components, exactly one" 1 $ - length $ filter (\c -> "test" == componentType c) comps diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/C/cabal.project b/cabal-testsuite/PackageTests/ShowBuildInfo/C/cabal.project deleted file mode 100644 index e6fdbadb439..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/C/cabal.project +++ /dev/null @@ -1 +0,0 @@ -packages: . diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/Complex.cabal b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/Complex.cabal index b104678143d..d8ea0a46eca 100644 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/Complex.cabal +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/Complex.cabal @@ -1,47 +1,72 @@ -cabal-version: 2.4 -name: Complex -version: 0.1.0.0 -license: MIT +cabal-version: 2.4 +name: Complex +version: 0.1.0.0 +license: MIT library - build-depends: base - hs-source-dirs: src - default-language: Haskell2010 - exposed-modules: Lib - other-modules: Paths_Complex + build-depends: base + hs-source-dirs: src doesnt-exist + default-language: Haskell2010 + exposed-modules: + A + B + + autogen-modules: Paths_Complex + other-modules: + C + D + Paths_Complex - ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall + ghc-options: -Wall executable Complex - main-is: Main.lhs - build-depends: base - hs-source-dirs: src - default-language: Haskell2010 - other-modules: Paths_Complex - ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wredundant-constraints - -with-rtsopts=-T + main-is: Main.lhs + build-depends: + , base + , Complex + + hs-source-dirs: app + autogen-modules: Paths_Complex + other-modules: + Other + Paths_Complex + + ghc-options: + -threaded -rtsopts "-with-rtsopts=-N -T" -Wredundant-constraints + + default-language: Haskell2010 test-suite unit-test - type: exitcode-stdio-1.0 - hs-source-dirs: test - build-depends: base - main-is: Main.hs + type: exitcode-stdio-1.0 + hs-source-dirs: test + build-depends: + , another-framework + , base + + main-is: UnitMain.hs + default-language: Haskell2010 test-suite func-test - type: exitcode-stdio-1.0 - hs-source-dirs: test - build-depends: base - main-is: Main.hs + type: exitcode-stdio-1.0 + hs-source-dirs: test + build-depends: + , base + , Complex + , test-framework + + main-is: FuncMain.hs + default-language: Haskell2010 benchmark complex-benchmarks - type: exitcode-stdio-1.0 - main-is: Main.hs - other-modules: - Paths_Complex - hs-source-dirs: - benchmark - ghc-options: -Wall -rtsopts -threaded -with-rtsopts=-N + type: exitcode-stdio-1.0 + main-is: Main.hs + other-modules: Paths_Complex + autogen-modules: Paths_Complex + hs-source-dirs: benchmark + ghc-options: -Wall -rtsopts -threaded -with-rtsopts=-N build-depends: - base + , base , Complex + , criterion ^>=1.1.4 + default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/Setup.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/Setup.hs deleted file mode 100644 index 9a994af677b..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/app/Main.lhs b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/app/Main.lhs new file mode 100644 index 00000000000..c1ea21ba48c --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/app/Main.lhs @@ -0,0 +1,8 @@ +module Main where + +import A +import Other + +main = do + print foo + print bar diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/app/Other.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/app/Other.hs new file mode 100644 index 00000000000..5d0685b1815 --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/app/Other.hs @@ -0,0 +1,3 @@ +module Other where + +bar = () diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/benchmark/Main.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/benchmark/Main.hs new file mode 100644 index 00000000000..7753bcff18c --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/benchmark/Main.hs @@ -0,0 +1,3 @@ +module Main where + +main = pure () diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/cabal.project b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/cabal.project index e6fdbadb439..b5bc61b1b15 100644 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/cabal.project +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/cabal.project @@ -1 +1,4 @@ packages: . + +tests: True +benchmarks: True \ No newline at end of file diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/exe.out b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/exe.out deleted file mode 100644 index 6fbda9790b7..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/exe.out +++ /dev/null @@ -1 +0,0 @@ -# cabal show-build-info diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/exe.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/exe.test.hs deleted file mode 100644 index 990bd65bcb2..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/exe.test.hs +++ /dev/null @@ -1,34 +0,0 @@ -import Test.Cabal.Prelude -import Test.Cabal.DecodeShowBuildInfo - -main = cabalTest $ do - buildInfo <- runShowBuildInfo ["exe:Complex", "-v0"] - assertEqual "Cabal Version" cabalVersionLibrary (cabalVersion buildInfo) - assertEqual "Compiler flavour" "ghc" (flavour $ compiler buildInfo) - assertBool "Compiler id" (and $ zipWith (==) "ghc" (compilerId $ compiler buildInfo)) - assertBool "Compiler path non-empty" (not . null . path $ compiler buildInfo) - assertEqual "Components, exactly one" 1 (length $ components buildInfo) - let [component] = components buildInfo - assertEqual "Component type" "exe" (componentType component) - assertEqual "Component name" "exe:Complex" (componentName component) - assertEqual "Component unit-id" "Complex-0.1.0.0-inplace-Complex" (componentUnitId component) - assertBool "Component compiler args are non-empty" (not . null $ componentCompilerArgs component) - assertBool "Component ghc-options contains all specified in .cabal" - (all - (`elem` componentCompilerArgs component) - [ "-threaded" - , "-rtsopts" - , "-with-rtsopts=-N" - , "-with-rtsopts=-T" - , "-Wredundant-constraints" - ] - ) - assertBool "Component ghc-options does not contain -Wall" - (all - (`notElem` componentCompilerArgs component) - [ "-Wall" - ] - ) - assertEqual "Component modules" ["Paths_Complex"] (componentModules component) - assertEqual "Component source files" ["Main.lhs"] (componentSrcFiles component) - assertEqual "Component source directories" ["src"] (componentHsSrcDirs component) diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/lib.out b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/lib.out deleted file mode 100644 index 6fbda9790b7..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/lib.out +++ /dev/null @@ -1 +0,0 @@ -# cabal show-build-info diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/lib.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/lib.test.hs deleted file mode 100644 index 51eaf075e6e..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/lib.test.hs +++ /dev/null @@ -1,33 +0,0 @@ -import Test.Cabal.Prelude -import Test.Cabal.DecodeShowBuildInfo - -main = cabalTest $ do - buildInfo <- runShowBuildInfo ["lib:Complex", "-v0"] - assertEqual "Cabal Version" cabalVersionLibrary (cabalVersion buildInfo) - assertEqual "Compiler flavour" "ghc" (flavour $ compiler buildInfo) - assertBool "Compiler id" (and $ zipWith (==) "ghc" (compilerId $ compiler buildInfo)) - assertBool "Compiler path non-empty" (not . null . path $ compiler buildInfo) - assertEqual "Components, exactly one" 1 (length $ components buildInfo) - let [component] = components buildInfo - assertEqual "Component type" "lib" (componentType component) - assertEqual "Component name" "lib" (componentName component) - assertEqual "Component unit-id" "Complex-0.1.0.0-inplace" (componentUnitId component) - assertBool "Component compiler args are non-empty" (not . null $ componentCompilerArgs component) - assertBool "Component ghc-options contains all specified in .cabal" - (all - (`elem` componentCompilerArgs component) - [ "-threaded" - , "-rtsopts" - , "-with-rtsopts=-N" - , "-Wall" - ] - ) - assertBool "Component ghc-options does not contain -Wredundant-constraints" - (all - (`notElem` componentCompilerArgs component) - [ "-Wredundant-constraints" - ] - ) - assertEqual "Component modules" ["Lib", "Paths_Complex"] (componentModules component) - assertEqual "Component source files" [] (componentSrcFiles component) - assertEqual "Component source directories" ["src"] (componentHsSrcDirs component) diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/repo/another-framework-0.8.1.1/another-framework.cabal b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/repo/another-framework-0.8.1.1/another-framework.cabal new file mode 100644 index 00000000000..173443e1906 --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/repo/another-framework-0.8.1.1/another-framework.cabal @@ -0,0 +1,8 @@ +name: another-framework +version: 0.8.1.1 +build-type: Simple +cabal-version: >= 1.10 + +library + build-depends: base + default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/repo/criterion-1.1.4.0/criterion.cabal b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/repo/criterion-1.1.4.0/criterion.cabal new file mode 100644 index 00000000000..e7cdc916530 --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/repo/criterion-1.1.4.0/criterion.cabal @@ -0,0 +1,8 @@ +name: criterion +version: 1.1.4.0 +build-type: Simple +cabal-version: >= 1.10 + +library + build-depends: base, ghc-prim + default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/repo/test-framework-0.8.1.1/test-framework.cabal b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/repo/test-framework-0.8.1.1/test-framework.cabal new file mode 100644 index 00000000000..2235e2eeb39 --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/repo/test-framework-0.8.1.1/test-framework.cabal @@ -0,0 +1,8 @@ +name: test-framework +version: 0.8.1.1 +build-type: Simple +cabal-version: >= 1.10 + +library + build-depends: base + default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/single.out b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/single.out new file mode 100644 index 00000000000..22e1a2aa8a9 --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/single.out @@ -0,0 +1,40 @@ +# cabal v2-update +Downloading the latest package list from test-local-repo +# cabal show-build-info +Resolving dependencies... +Configuring library for Complex-0.1.0.0.. +Warning: 'hs-source-dirs: doesnt-exist' directory does not exist. +Preprocessing library for Complex-0.1.0.0.. +Building library for Complex-0.1.0.0.. +Configuring executable 'Complex' for Complex-0.1.0.0.. +Warning: The package has an extraneous version range for a dependency on an internal library: Complex >=0 && ==0.1.0.0, Complex >=0 && ==0.1.0.0, Complex >=0 && ==0.1.0.0. This version range includes the current package but isn't needed as the current package's library will always be used. +Warning: 'hs-source-dirs: doesnt-exist' directory does not exist. +{"cabal-version":"","compiler":{"flavour":"ghc","compiler-id":"ghc-","path":""},"components":[{"type":"exe","name":"exe:Complex","unit-id":"Complex-0.1.0.0-inplace-Complex","compiler-args":["-fbuilding-cabal-package","-O","-outputdir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/x/Complex/build","-odir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/x/Complex/build","-hidir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/x/Complex/build","-stubdir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/x/Complex/build","-i","-i/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/x/Complex/build","-iapp","-i/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/x/Complex/build/Complex/autogen","-i/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/x/Complex/build/global-autogen","-I/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/x/Complex/build/Complex/autogen","-I/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/x/Complex/build/global-autogen","-I/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/x/Complex/build","-optP-include","-optP/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/x/Complex/build/Complex/autogen/cabal_macros.h","-hide-all-packages","-Wmissing-home-modules","-no-user-package-db","-package-db","/single.dist/home/.cabal/store/ghc-/package.db","-package-db","/single.dist/work/./dist/packagedb/ghc-","-package-id","Complex-0.1.0.0-","-package-id","base-","-XHaskell2010","-threaded","-rtsopts","-with-rtsopts=-N -T","-Wredundant-constraints"],"modules":["Other","Paths_Complex"],"src-files":["Main.lhs"],"hs-src-dirs":["app"],"src-dir":"/","cabal-file":"./Complex.cabal"}],"project-root":"/"} +# cabal show-build-info +{"cabal-version":"","compiler":{"flavour":"ghc","compiler-id":"ghc-","path":""},"components":[{"type":"lib","name":"lib","unit-id":"Complex-0.1.0.0-inplace","compiler-args":["-fbuilding-cabal-package","-O","-outputdir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/build","-odir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/build","-hidir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/build","-stubdir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/build","-i","-i/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/build","-isrc","-idoesnt-exist","-i/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/build/autogen","-i/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/build/global-autogen","-I/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/build/autogen","-I/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/build/global-autogen","-I/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/build","-optP-include","-optP/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/build/autogen/cabal_macros.h","-this-unit-id","Complex-0.1.0.0-inplace","-hide-all-packages","-Wmissing-home-modules","-no-user-package-db","-package-db","/single.dist/home/.cabal/store/ghc-/package.db","-package-db","/single.dist/work/./dist/packagedb/ghc-","-package-id","base-","-XHaskell2010","-Wall"],"modules":["A","B","C","D","Paths_Complex"],"src-files":[],"hs-src-dirs":["src","doesnt-exist"],"src-dir":"/","cabal-file":"./Complex.cabal"}],"project-root":"/"} +# cabal show-build-info +Configuring library for criterion-1.1.4.0.. +Preprocessing library for criterion-1.1.4.0.. +Building library for criterion-1.1.4.0.. +Installing library in +Configuring benchmark 'complex-benchmarks' for Complex-0.1.0.0.. +Warning: The package has an extraneous version range for a dependency on an internal library: Complex >=0 && ==0.1.0.0, Complex >=0 && ==0.1.0.0, Complex >=0 && ==0.1.0.0. This version range includes the current package but isn't needed as the current package's library will always be used. +Warning: 'hs-source-dirs: doesnt-exist' directory does not exist. +{"cabal-version":"","compiler":{"flavour":"ghc","compiler-id":"ghc-","path":""},"components":[{"type":"bench","name":"bench:complex-benchmarks","unit-id":"Complex-0.1.0.0-inplace-complex-benchmarks","compiler-args":["-fbuilding-cabal-package","-O","-outputdir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/b/complex-benchmarks/build","-odir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/b/complex-benchmarks/build","-hidir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/b/complex-benchmarks/build","-stubdir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/b/complex-benchmarks/build","-i","-i/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/b/complex-benchmarks/build","-ibenchmark","-i/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/b/complex-benchmarks/build/complex-benchmarks/autogen","-i/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/b/complex-benchmarks/build/global-autogen","-I/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/b/complex-benchmarks/build/complex-benchmarks/autogen","-I/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/b/complex-benchmarks/build/global-autogen","-I/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/b/complex-benchmarks/build","-optP-include","-optP/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/b/complex-benchmarks/build/complex-benchmarks/autogen/cabal_macros.h","-hide-all-packages","-Wmissing-home-modules","-no-user-package-db","-package-db","/single.dist/home/.cabal/store/ghc-/package.db","-package-db","/single.dist/work/./dist/packagedb/ghc-","-package-id","Complex-0.1.0.0-","-package-id","base-","-package-id","criterion-1.1.4.0-","-XHaskell2010","-Wall","-rtsopts","-threaded","-with-rtsopts=-N"],"modules":["Paths_Complex"],"src-files":["Main.hs"],"hs-src-dirs":["benchmark"],"src-dir":"/","cabal-file":"./Complex.cabal"}],"project-root":"/"} +# cabal show-build-info +Configuring library for test-framework-0.8.1.1.. +Preprocessing library for test-framework-0.8.1.1.. +Building library for test-framework-0.8.1.1.. +Installing library in +Configuring test suite 'func-test' for Complex-0.1.0.0.. +Warning: The package has an extraneous version range for a dependency on an internal library: Complex >=0 && ==0.1.0.0, Complex >=0 && ==0.1.0.0, Complex >=0 && ==0.1.0.0. This version range includes the current package but isn't needed as the current package's library will always be used. +Warning: 'hs-source-dirs: doesnt-exist' directory does not exist. +{"cabal-version":"","compiler":{"flavour":"ghc","compiler-id":"ghc-","path":""},"components":[{"type":"test","name":"test:func-test","unit-id":"Complex-0.1.0.0-inplace-func-test","compiler-args":["-fbuilding-cabal-package","-O","-outputdir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/func-test/build","-odir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/func-test/build","-hidir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/func-test/build","-stubdir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/func-test/build","-i","-i/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/func-test/build","-itest","-i/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/func-test/build/func-test/autogen","-i/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/func-test/build/global-autogen","-I/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/func-test/build/func-test/autogen","-I/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/func-test/build/global-autogen","-I/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/func-test/build","-optP-include","-optP/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/func-test/build/func-test/autogen/cabal_macros.h","-hide-all-packages","-Wmissing-home-modules","-no-user-package-db","-package-db","/single.dist/home/.cabal/store/ghc-/package.db","-package-db","/single.dist/work/./dist/packagedb/ghc-","-package-id","Complex-0.1.0.0-","-package-id","base-","-package-id","test-framework-0.8.1.1-","-XHaskell2010"],"modules":[],"src-files":["FuncMain.hs"],"hs-src-dirs":["test"],"src-dir":"/","cabal-file":"./Complex.cabal"}],"project-root":"/"} +# cabal show-build-info +Configuring library for another-framework-0.8.1.1.. +Preprocessing library for another-framework-0.8.1.1.. +Building library for another-framework-0.8.1.1.. +Installing library in +Configuring test suite 'unit-test' for Complex-0.1.0.0.. +Warning: 'hs-source-dirs: doesnt-exist' directory does not exist. +{"cabal-version":"","compiler":{"flavour":"ghc","compiler-id":"ghc-","path":""},"components":[{"type":"test","name":"test:unit-test","unit-id":"Complex-0.1.0.0-inplace-unit-test","compiler-args":["-fbuilding-cabal-package","-O","-outputdir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/unit-test/build","-odir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/unit-test/build","-hidir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/unit-test/build","-stubdir","/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/unit-test/build","-i","-i/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/unit-test/build","-itest","-i/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/unit-test/build/unit-test/autogen","-i/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/unit-test/build/global-autogen","-I/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/unit-test/build/unit-test/autogen","-I/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/unit-test/build/global-autogen","-I/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/unit-test/build","-optP-include","-optP/single.dist/work/./dist/build//ghc-/Complex-0.1.0.0/t/unit-test/build/unit-test/autogen/cabal_macros.h","-hide-all-packages","-Wmissing-home-modules","-no-user-package-db","-package-db","/single.dist/home/.cabal/store/ghc-/package.db","-package-db","/single.dist/work/./dist/packagedb/ghc-","-package-id","another-framework-0.8.1.1-","-package-id","base-","-XHaskell2010"],"modules":[],"src-files":["UnitMain.hs"],"hs-src-dirs":["test"],"src-dir":"/","cabal-file":"./Complex.cabal"}],"project-root":"/"} diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/single.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/single.test.hs new file mode 100644 index 00000000000..f3d0622d0ff --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/single.test.hs @@ -0,0 +1,33 @@ +import Test.Cabal.Prelude +import Test.Cabal.DecodeShowBuildInfo + +main = cabalTest $ withRepo "repo" $ do + runShowBuildInfoWithMarker ["exe:Complex"] >>= + (\buildInfo -> do + assertCommonBuildInfo buildInfo + let [exeComp] = components buildInfo + assertExeComponent' exeComp "exe:Complex" ["Other", "Paths_Complex"] ["Main.lhs"] ["app"]) + + runShowBuildInfoWithMarker ["lib:Complex"] >>= + (\buildInfo -> do + assertCommonBuildInfo buildInfo + let [libComp] = components buildInfo + assertLibComponent libComp "lib" ["A", "B", "C", "D", "Paths_Complex"] ["src", "doesnt-exist"]) + + runShowBuildInfoWithMarker ["benchmark:complex-benchmarks"] >>= + (\buildInfo -> do + assertCommonBuildInfo buildInfo + let [benchComp] = components buildInfo + assertBenchComponent' benchComp "bench:complex-benchmarks" ["Paths_Complex"] ["Main.hs"] ["benchmark"]) + + runShowBuildInfoWithMarker ["test:func-test"] >>= + (\buildInfo -> do + assertCommonBuildInfo buildInfo + let [testComp] = components buildInfo + assertTestComponent testComp "test:func-test" ["FuncMain.hs"] ["test"]) + + runShowBuildInfoWithMarker ["test:unit-test"] >>= + (\buildInfo -> do + assertCommonBuildInfo buildInfo + let [testComp] = components buildInfo + assertTestComponent testComp "test:unit-test" ["UnitMain.hs"] ["test"]) diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/A.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/A.hs new file mode 100644 index 00000000000..18032f68988 --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/A.hs @@ -0,0 +1,5 @@ +module A where + +import D + +foo = d diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/B.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/B.hs new file mode 100644 index 00000000000..93b0222a65d --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/B.hs @@ -0,0 +1,3 @@ +module B where + +b = 1 diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/C.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/C.hs new file mode 100644 index 00000000000..419eb7eca64 --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/C.hs @@ -0,0 +1,5 @@ +module C where + +import B + +c = b diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/D.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/D.hs new file mode 100644 index 00000000000..d9be40b5ba2 --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/D.hs @@ -0,0 +1,5 @@ +module D where + +import C + +d = c diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/Lib.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/Lib.hs deleted file mode 100644 index 5d35e3e9617..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/Lib.hs +++ /dev/null @@ -1,4 +0,0 @@ -module Lib where - -foo :: Int -> Int -foo = (+1) \ No newline at end of file diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/Main.lhs b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/Main.lhs deleted file mode 100644 index a1b75006b8d..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/src/Main.lhs +++ /dev/null @@ -1,9 +0,0 @@ -module Main where - -import Lib - -main :: IO () -main = do - let i = foo 5 - putStrLn "Hello, Haskell!" - print i diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/test/Main.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/test/FuncMain.hs similarity index 100% rename from cabal-testsuite/PackageTests/ShowBuildInfo/Complex/test/Main.hs rename to cabal-testsuite/PackageTests/ShowBuildInfo/Complex/test/FuncMain.hs diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/test/UnitMain.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/test/UnitMain.hs new file mode 100644 index 00000000000..b3549c2fe3d --- /dev/null +++ b/cabal-testsuite/PackageTests/ShowBuildInfo/Complex/test/UnitMain.hs @@ -0,0 +1 @@ +main = return () diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/D/D.cabal b/cabal-testsuite/PackageTests/ShowBuildInfo/D/D.cabal deleted file mode 100644 index 0af36bee5bb..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/D/D.cabal +++ /dev/null @@ -1,9 +0,0 @@ -cabal-version: 2.4 -name: D -version: 0.1.0.0 -license: BSD-3-Clause - -library - exposed-modules: Lib - build-depends: base, D1 - default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/D/D1/D1.cabal b/cabal-testsuite/PackageTests/ShowBuildInfo/D/D1/D1.cabal deleted file mode 100644 index 09118f6e84e..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/D/D1/D1.cabal +++ /dev/null @@ -1,9 +0,0 @@ -cabal-version: 2.4 -name: D1 -version: 0.1.0.0 -license: BSD-3-Clause - -library - exposed-modules: Lib1 - build-depends: base - default-language: Haskell2010 diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/D/D1/Lib1.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/D/D1/Lib1.hs deleted file mode 100644 index 50919006b5f..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/D/D1/Lib1.hs +++ /dev/null @@ -1,3 +0,0 @@ -module Lib1 where - -bar = 42 diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/D/Lib.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/D/Lib.hs deleted file mode 100644 index 638711c17e5..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/D/Lib.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Lib where - --- Point of this is to make sure we can still get the build info even if one of --- the components doesn't compile -foo :: String -foo = 42 diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/D/build-info-prune-deps.out b/cabal-testsuite/PackageTests/ShowBuildInfo/D/build-info-prune-deps.out deleted file mode 100644 index 8a876417a2c..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/D/build-info-prune-deps.out +++ /dev/null @@ -1,2 +0,0 @@ -# cabal clean -# cabal show-build-info diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/D/build-info-prune-deps.test.hs b/cabal-testsuite/PackageTests/ShowBuildInfo/D/build-info-prune-deps.test.hs deleted file mode 100644 index e3c0edb3651..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/D/build-info-prune-deps.test.hs +++ /dev/null @@ -1,8 +0,0 @@ -import Test.Cabal.Prelude - -main = cabalTest $ do - -- Make sure the vendored dependency D1 gets built - cabal' "clean" [] - r <- cabal' "show-build-info" ["-v1", "D", "D1"] - assertOutputContains "Building library for D1-0.1.0.0.." r - assertOutputDoesNotContain "Building library for D-0.1.0.0.." r diff --git a/cabal-testsuite/PackageTests/ShowBuildInfo/D/cabal.project b/cabal-testsuite/PackageTests/ShowBuildInfo/D/cabal.project deleted file mode 100644 index e7083db0d01..00000000000 --- a/cabal-testsuite/PackageTests/ShowBuildInfo/D/cabal.project +++ /dev/null @@ -1,2 +0,0 @@ -packages: . - ./D1 diff --git a/cabal-testsuite/src/Test/Cabal/DecodeShowBuildInfo.hs b/cabal-testsuite/src/Test/Cabal/DecodeShowBuildInfo.hs index 5b33be70a7d..355559ff06c 100644 --- a/cabal-testsuite/src/Test/Cabal/DecodeShowBuildInfo.hs +++ b/cabal-testsuite/src/Test/Cabal/DecodeShowBuildInfo.hs @@ -2,50 +2,63 @@ module Test.Cabal.DecodeShowBuildInfo where import Test.Cabal.Prelude -import qualified Distribution.Simple.Utils as U (cabalVersion) import Distribution.Text (display) import qualified Data.Text as T import qualified Data.Text.Encoding as T import Data.Aeson +import GHC.Stack.Types import GHC.Generics +-- | Run 'show-build-info' silencing all output using '-v0'. +-- This is necessary to make sure no stray output from 'show-build-info' makes +-- parsing impossible. runShowBuildInfo :: [String] -> TestM BuildInfo runShowBuildInfo args = do - r <- cabal' "show-build-info" args - case eitherDecodeStrict (T.encodeUtf8 . T.pack $ resultOutput r) of - Left err -> fail $ "Could not parse show-build-info command: " ++ err - Right buildInfos -> return buildInfos + r <- cabal' "show-build-info" ("-v0":args) + decodeShowBuildInfo (resultOutput r) + +-- | Same as 'runShowBuildInfo' but does not require the verbosity '-v0'. +-- Uses "-vverbose +markoutput +nowrap" to extract the relevant json output. +runShowBuildInfoWithMarker :: [String] -> TestM BuildInfo +runShowBuildInfoWithMarker args = do + r <- cabal' "show-build-info" args + decodeShowBuildInfo (last . lines . getMarkedOutput $ resultOutput r) + +decodeShowBuildInfo :: String -> TestM BuildInfo +decodeShowBuildInfo s = case eitherDecodeStrict (T.encodeUtf8 $ T.pack s) of + Left err -> fail $ "Could not parse show-build-info command: " ++ err + Right buildInfos -> return buildInfos decodeBuildInfoFile :: FilePath -> TestM BuildInfo decodeBuildInfoFile fp = do - shouldExist fp - res <- liftIO $ eitherDecodeFileStrict fp - case res of - Left err -> fail $ "Could not parse show-build-info file: " ++ err - Right buildInfos -> return buildInfos + shouldExist fp + res <- liftIO $ eitherDecodeFileStrict fp + case res of + Left err -> fail $ "Could not parse show-build-info file: " ++ err + Right buildInfos -> return buildInfos data BuildInfo = BuildInfo - { cabalVersion :: String - , compiler :: CompilerInfo - , components :: [ComponentInfo] - } deriving (Generic, Show) + { cabalVersion :: String + , compiler :: CompilerInfo + , components :: [ComponentInfo] + } deriving (Generic, Show) data CompilerInfo = CompilerInfo - { flavour :: String - , compilerId :: String - , path :: String - } deriving (Generic, Show) + { flavour :: String + , compilerId :: String + , path :: String + } deriving (Generic, Show) data ComponentInfo = ComponentInfo - { componentType :: String - , componentName :: String - , componentUnitId :: String - , componentCompilerArgs :: [String] - , componentModules :: [String] - , componentSrcFiles :: [FilePath] - , componentHsSrcDirs :: [FilePath] - , componentSrcDir :: FilePath - } deriving (Generic, Show) + { componentType :: String + , componentName :: String + , componentUnitId :: String + , componentCompilerArgs :: [String] + , componentModules :: [String] + , componentSrcFiles :: [FilePath] + , componentHsSrcDirs :: [FilePath] + , componentSrcDir :: FilePath + } deriving (Generic, Show) instance ToJSON BuildInfo where toEncoding = genericToEncoding defaultOptions @@ -62,5 +75,50 @@ instance ToJSON ComponentInfo where instance FromJSON ComponentInfo where parseJSON = genericParseJSON defaultOptions { fieldLabelModifier = drop 10 . camelTo2 '-' } -cabalVersionLibrary :: String -cabalVersionLibrary = display U.cabalVersion +-- ----------------------------------------------------------- +-- Assertion Helpers to define succinct test cases +-- ----------------------------------------------------------- + +assertCommonBuildInfo :: (HasCallStack, MonadIO m) => BuildInfo -> m () +assertCommonBuildInfo buildInfo = do + assertEqual "Cabal Version" (display cabalVersionLibrary) (cabalVersion buildInfo) + assertEqual "Compiler flavour" "ghc" (flavour $ compiler buildInfo) + assertBool "Compiler id" (and $ zipWith (==) "ghc" (compilerId $ compiler buildInfo)) + assertBool "Compiler path non-empty" (not . null . path $ compiler buildInfo) + +assertExeComponent :: (HasCallStack, MonadIO m) => ComponentInfo -> String -> [String] -> [String] -> m () +assertExeComponent = assertExecutableComp "exe" + +assertExeComponent' :: (HasCallStack, MonadIO m) => ComponentInfo -> String -> [String] -> [String] -> [String] -> m () +assertExeComponent' component compName modules sourceFiles sourceDirs = + assertArbitraryComp "exe" compName (not . null) (not . null) modules sourceFiles sourceDirs component + +assertLibComponent :: (HasCallStack, MonadIO m) => ComponentInfo -> String -> [String] -> [String] -> m () +assertLibComponent component compName modules sourceDirs = + assertArbitraryComp "lib" compName (not . null) (not . null) modules [] sourceDirs component + +assertTestComponent :: (HasCallStack, MonadIO m) => ComponentInfo -> String -> [String] -> [String] -> m () +assertTestComponent = assertExecutableComp "test" + +assertBenchComponent :: (HasCallStack, MonadIO m) => ComponentInfo -> String -> [String] -> [String] -> m () +assertBenchComponent = assertExecutableComp "bench" + +assertBenchComponent' :: (HasCallStack, MonadIO m) => ComponentInfo -> String -> [String] -> [String] -> [String] -> m () +assertBenchComponent' component compName modules sourceFiles sourceDirs = + assertArbitraryComp "bench" compName (not . null) (not . null) modules sourceFiles sourceDirs component + +assertExecutableComp :: (HasCallStack, MonadIO m) => String -> ComponentInfo -> String -> [String] -> [String] -> m () +assertExecutableComp compType component compName sourceFiles sourceDirs = + assertArbitraryComp compType compName (not . null) (not . null) [] sourceFiles sourceDirs component + +assertArbitraryComp :: (HasCallStack, MonadIO m) => String -> String -> + (String -> Bool) -> ([String] -> Bool) -> [String] -> [FilePath] -> + [FilePath] -> ComponentInfo -> m () +assertArbitraryComp compType compName unitIdPred compilerArgsPred modules sourceFiles sourceDirs component = do + assertEqual "Component type" compType (componentType component) + assertEqual "Component name" compName (componentName component) + assertBool "Component Unit Id" (unitIdPred $ componentUnitId component) + assertBool "Component compiler args" (compilerArgsPred $ componentCompilerArgs component) + assertEqual "Component modules" modules (componentModules component) + assertEqual "Component source files" sourceFiles (componentSrcFiles component) + assertEqual "Component source directories" sourceDirs (componentHsSrcDirs component) diff --git a/cabal-testsuite/src/Test/Cabal/Monad.hs b/cabal-testsuite/src/Test/Cabal/Monad.hs index c320282c301..e7625951f90 100644 --- a/cabal-testsuite/src/Test/Cabal/Monad.hs +++ b/cabal-testsuite/src/Test/Cabal/Monad.hs @@ -47,6 +47,8 @@ module Test.Cabal.Monad ( CommonArgs(..), renderCommonArgs, commonArgParser, + -- * Version Constants + cabalVersionLibrary, ) where import Test.Cabal.Script @@ -62,9 +64,11 @@ import Distribution.Simple.Program.Db import Distribution.Simple.Program import Distribution.Simple.Configure ( configCompilerEx ) +import qualified Distribution.Simple.Utils as U (cabalVersion) import Distribution.Text import Distribution.Verbosity +import Distribution.Version import Data.Monoid ((<>), mempty) import qualified Control.Exception as E @@ -398,6 +402,9 @@ mkNormalizerEnv = do list_out <- liftIO $ readProcess (programPath ghc_pkg_program) ["list", "--global", "--simple-output"] "" tmpDir <- liftIO $ getTemporaryDirectory + ghc_program <- requireProgramM ghcProgram + let ghcPath = programPath ghc_program + return NormalizerEnv { normalizerRoot = addTrailingPathSeparator (testSourceDir env), @@ -407,11 +414,19 @@ mkNormalizerEnv = do = addTrailingPathSeparator tmpDir, normalizerGhcVersion = compilerVersion (testCompiler env), + normalizerGhcPath + = ghcPath, normalizerKnownPackages = mapMaybe simpleParse (words list_out), normalizerPlatform - = testPlatform env + = testPlatform env, + normalizerCabalVersion + = cabalVersionLibrary } + where + +cabalVersionLibrary :: Version +cabalVersionLibrary = U.cabalVersion requireProgramM :: Program -> TestM ConfiguredProgram requireProgramM program = do diff --git a/cabal-testsuite/src/Test/Cabal/OutputNormalizer.hs b/cabal-testsuite/src/Test/Cabal/OutputNormalizer.hs index 4e6aec19890..12347fc2258 100644 --- a/cabal-testsuite/src/Test/Cabal/OutputNormalizer.hs +++ b/cabal-testsuite/src/Test/Cabal/OutputNormalizer.hs @@ -49,6 +49,15 @@ normalizeOutput nenv = "/incoming/new-" -- Normalize architecture . resub (posixRegexEscape (display (normalizerPlatform nenv))) "" + -- Remove ghc path from show-build-info output + . resub ("\"path\":\"" ++ posixRegexEscape (normalizerGhcPath nenv) ++ "\"}") + "\"path\":\"\"}" + -- Remove cabal version output from show-build-info output + . resub ("{\"cabal-version\":\"" ++ posixRegexEscape (display (normalizerCabalVersion nenv)) ++ "\"") + "{\"cabal-version\":\"\"" + -- + . resub ("\"-package-id\",\"([^\\-][A-Za-z0-9.\\-]+)(-[A-Za-z0-9.]+)\"") + "\"-package-id\",\"\\1-\"" -- Some GHC versions are chattier than others . resub "^ignoring \\(possibly broken\\) abi-depends field for packages" "" -- Normalize the current GHC version. Apply this BEFORE packageIdRegex, @@ -72,8 +81,10 @@ data NormalizerEnv = NormalizerEnv , normalizerTmpDir :: FilePath , normalizerGblTmpDir :: FilePath , normalizerGhcVersion :: Version + , normalizerGhcPath :: FilePath , normalizerKnownPackages :: [PackageId] , normalizerPlatform :: Platform + , normalizerCabalVersion :: Version } posixSpecialChars :: [Char]