Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
2af1c1d5
Commit
2af1c1d5
authored
Jun 20, 2015
by
ttuegel
Browse files
Fix tests when CABAL_BUILDDIR is set
parent
3bb8c7a9
Changes
31
Hide whitespace changes
Inline
Side-by-side
Cabal/tests/PackageTests.hs
View file @
2af1c1d5
...
...
@@ -21,7 +21,7 @@ import PackageTests.BuildDeps.TargetSpecificDeps1.Check
import
PackageTests.BuildDeps.TargetSpecificDeps2.Check
import
PackageTests.BuildDeps.TargetSpecificDeps3.Check
import
PackageTests.BuildTestSuiteDetailedV09.Check
import
PackageTests.PackageTester
(
PackageSpec
(
..
),
compileSetup
)
import
PackageTests.PackageTester
(
PackageSpec
(
..
),
SuiteConfig
(
..
),
compileSetup
)
import
PackageTests.PathsModule.Executable.Check
import
PackageTests.PathsModule.Library.Check
import
PackageTests.PreProcess.Check
...
...
@@ -38,29 +38,31 @@ import PackageTests.OrderFlags.Check
import
PackageTests.ReexportedModules.Check
import
Distribution.Simple.Configure
(
ConfigStateFileError
(
..
),
getConfigStateFile
)
(
ConfigStateFileError
(
..
),
findDistPrefOrDefault
,
getConfigStateFile
)
import
Distribution.Simple.LocalBuildInfo
(
LocalBuildInfo
(
..
))
import
Distribution.Simple.Program.Types
(
programPath
)
import
Distribution.Simple.Program.Builtin
(
ghcProgram
,
ghcPkgProgram
,
haddockProgram
)
import
Distribution.Simple.Program.Db
(
requireProgram
)
import
Distribution.Simple.Setup
(
Flag
(
..
))
import
Distribution.Simple.Utils
(
cabalVersion
)
import
Distribution.Text
(
display
)
import
Distribution.Verbosity
(
normal
)
import
Distribution.Version
(
Version
(
Version
))
import
Control.Exception
(
try
,
throw
)
import
Distribution.Compat.Environment
(
setEnv
)
import
System.Directory
(
getCurrentDirectory
,
setCurrentDirectory
)
(
canonicalizePath
,
setCurrentDirectory
)
import
System.FilePath
((
</>
))
import
Test.Tasty
import
Test.Tasty.HUnit
tests
::
Version
->
PackageSpec
->
FilePath
->
FilePath
->
[
TestTree
]
tests
version
inplaceSpec
ghcPath
ghcPkgPath
=
tests
::
SuiteConfig
->
Version
->
[
TestTree
]
tests
config
version
=
[
testCase
"BuildDeps/SameDepsAllRound"
(
PackageTests
.
BuildDeps
.
SameDepsAllRound
.
Check
.
suite
ghcPath
)
(
PackageTests
.
BuildDeps
.
SameDepsAllRound
.
Check
.
suite
config
)
-- The two following tests were disabled by Johan Tibell as
-- they have been failing for a long time:
-- , testCase "BuildDeps/GlobalBuildDepsNotAdditive1/"
...
...
@@ -68,91 +70,98 @@ tests version inplaceSpec ghcPath ghcPkgPath =
-- , testCase "BuildDeps/GlobalBuildDepsNotAdditive2/"
-- (PackageTests.BuildDeps.GlobalBuildDepsNotAdditive2.Check.suite ghcPath)
,
testCase
"BuildDeps/InternalLibrary0"
(
PackageTests
.
BuildDeps
.
InternalLibrary0
.
Check
.
suite
version
ghcPath
)
,
testCase
"PreProcess"
(
PackageTests
.
PreProcess
.
Check
.
suite
ghcPath
)
(
PackageTests
.
BuildDeps
.
InternalLibrary0
.
Check
.
suite
config
version
)
,
testCase
"PreProcess"
(
PackageTests
.
PreProcess
.
Check
.
suite
config
)
,
testCase
"PreProcessExtraSources"
(
PackageTests
.
PreProcessExtraSources
.
Check
.
suite
ghcPath
)
,
testCase
"TestStanza"
(
PackageTests
.
TestStanza
.
Check
.
suite
ghcPath
)
(
PackageTests
.
PreProcessExtraSources
.
Check
.
suite
config
)
,
testCase
"TestStanza"
(
PackageTests
.
TestStanza
.
Check
.
suite
config
)
-- ^ The Test stanza test will eventually be required
-- only for higher versions.
,
testGroup
"TestSuiteExeV10"
(
PackageTests
.
TestSuiteExeV10
.
Check
.
checks
ghcPath
)
,
testCase
"TestOptions"
(
PackageTests
.
TestOptions
.
Check
.
suite
ghcPath
)
,
testCase
"BenchmarkStanza"
(
PackageTests
.
BenchmarkStanza
.
Check
.
suite
ghcPath
)
,
testGroup
"TestSuiteExeV10"
(
PackageTests
.
TestSuiteExeV10
.
Check
.
checks
config
)
,
testCase
"TestOptions"
(
PackageTests
.
TestOptions
.
Check
.
suite
config
)
,
testCase
"BenchmarkStanza"
(
PackageTests
.
BenchmarkStanza
.
Check
.
suite
config
)
-- ^ The benchmark stanza test will eventually be required
-- only for higher versions.
,
testCase
"BenchmarkExeV10/Test"
(
PackageTests
.
BenchmarkExeV10
.
Check
.
checkBenchmark
ghcPath
)
,
testCase
"BenchmarkOptions"
(
PackageTests
.
BenchmarkOptions
.
Check
.
suite
ghcPath
)
(
PackageTests
.
BenchmarkExeV10
.
Check
.
checkBenchmark
config
)
,
testCase
"BenchmarkOptions"
(
PackageTests
.
BenchmarkOptions
.
Check
.
suite
config
)
,
testCase
"TemplateHaskell/vanilla"
(
PackageTests
.
TemplateHaskell
.
Check
.
vanilla
ghcPath
)
(
PackageTests
.
TemplateHaskell
.
Check
.
vanilla
config
)
,
testCase
"TemplateHaskell/profiling"
(
PackageTests
.
TemplateHaskell
.
Check
.
profiling
ghcPath
)
(
PackageTests
.
TemplateHaskell
.
Check
.
profiling
config
)
,
testCase
"PathsModule/Executable"
(
PackageTests
.
PathsModule
.
Executable
.
Check
.
suite
ghcPath
)
,
testCase
"PathsModule/Library"
(
PackageTests
.
PathsModule
.
Library
.
Check
.
suite
ghcPath
)
(
PackageTests
.
PathsModule
.
Executable
.
Check
.
suite
config
)
,
testCase
"PathsModule/Library"
(
PackageTests
.
PathsModule
.
Library
.
Check
.
suite
config
)
,
testCase
"DeterministicAr"
(
PackageTests
.
DeterministicAr
.
Check
.
suite
ghcPath
ghcPkgPath
)
(
PackageTests
.
DeterministicAr
.
Check
.
suite
config
)
,
testCase
"EmptyLib/emptyLib"
(
PackageTests
.
EmptyLib
.
Check
.
emptyLib
ghcPath
)
,
testCase
"Haddock"
(
PackageTests
.
Haddock
.
Check
.
suite
ghcPath
)
(
PackageTests
.
EmptyLib
.
Check
.
emptyLib
config
)
,
testCase
"Haddock"
(
PackageTests
.
Haddock
.
Check
.
suite
config
)
,
testCase
"BuildTestSuiteDetailedV09"
(
PackageTests
.
BuildTestSuiteDetailedV09
.
Check
.
suite
inplaceSpec
ghcPath
)
(
PackageTests
.
BuildTestSuiteDetailedV09
.
Check
.
suite
config
)
,
testCase
"OrderFlags"
(
PackageTests
.
OrderFlags
.
Check
.
suite
ghcPath
)
(
PackageTests
.
OrderFlags
.
Check
.
suite
config
)
,
testCase
"TemplateHaskell/dynamic"
(
PackageTests
.
TemplateHaskell
.
Check
.
dynamic
ghcPath
)
(
PackageTests
.
TemplateHaskell
.
Check
.
dynamic
config
)
,
testCase
"ReexportedModules"
(
PackageTests
.
ReexportedModules
.
Check
.
suite
ghcPath
)
(
PackageTests
.
ReexportedModules
.
Check
.
suite
config
)
]
++
-- These tests are only required to pass on cabal version >= 1.7
(
if
version
>=
Version
[
1
,
7
]
[]
then
[
testCase
"BuildDeps/TargetSpecificDeps1"
(
PackageTests
.
BuildDeps
.
TargetSpecificDeps1
.
Check
.
suite
ghcPath
)
(
PackageTests
.
BuildDeps
.
TargetSpecificDeps1
.
Check
.
suite
config
)
,
testCase
"BuildDeps/TargetSpecificDeps2"
(
PackageTests
.
BuildDeps
.
TargetSpecificDeps2
.
Check
.
suite
ghcPath
)
(
PackageTests
.
BuildDeps
.
TargetSpecificDeps2
.
Check
.
suite
config
)
,
testCase
"BuildDeps/TargetSpecificDeps3"
(
PackageTests
.
BuildDeps
.
TargetSpecificDeps3
.
Check
.
suite
ghcPath
)
(
PackageTests
.
BuildDeps
.
TargetSpecificDeps3
.
Check
.
suite
config
)
,
testCase
"BuildDeps/InternalLibrary1"
(
PackageTests
.
BuildDeps
.
InternalLibrary1
.
Check
.
suite
ghcPath
)
(
PackageTests
.
BuildDeps
.
InternalLibrary1
.
Check
.
suite
config
)
,
testCase
"BuildDeps/InternalLibrary2"
(
PackageTests
.
BuildDeps
.
InternalLibrary2
.
Check
.
suite
ghcPath
ghcPkgPath
)
(
PackageTests
.
BuildDeps
.
InternalLibrary2
.
Check
.
suite
config
)
,
testCase
"BuildDeps/InternalLibrary3"
(
PackageTests
.
BuildDeps
.
InternalLibrary3
.
Check
.
suite
ghcPath
ghcPkgPath
)
(
PackageTests
.
BuildDeps
.
InternalLibrary3
.
Check
.
suite
config
)
,
testCase
"BuildDeps/InternalLibrary4"
(
PackageTests
.
BuildDeps
.
InternalLibrary4
.
Check
.
suite
ghcPath
ghcPkgPath
)
(
PackageTests
.
BuildDeps
.
InternalLibrary4
.
Check
.
suite
config
)
,
testCase
"PackageTests/CMain"
(
PackageTests
.
CMain
.
Check
.
checkBuild
ghcPath
)
(
PackageTests
.
CMain
.
Check
.
checkBuild
config
)
]
else
[]
)
main
::
IO
()
main
=
do
wd
<-
getCurrentDirectory
let
dbFile
=
wd
</>
"dist/package.conf.inplace"
inplaceSpec
=
PackageSpec
{
directory
=
[]
,
configOpts
=
[
"--package-db="
++
dbFile
,
"--constraint=Cabal == "
++
display
cabalVersion
]
,
distPref
=
Nothing
}
putStrLn
$
"Cabal test suite - testing cabal version "
++
display
cabalVersion
lbi
<-
getPersistBuildConfig_
(
"dist"
</>
"setup-config"
)
-- Find the builddir used to build Cabal
distPref_
<-
findDistPrefOrDefault
NoFlag
>>=
canonicalizePath
-- Use the default builddir for all of the subsequent package tests
setEnv
"CABAL_BUILDDIR"
"dist"
lbi
<-
getPersistBuildConfig_
(
distPref_
</>
"setup-config"
)
(
ghc
,
_
)
<-
requireProgram
normal
ghcProgram
(
withPrograms
lbi
)
(
ghcPkg
,
_
)
<-
requireProgram
normal
ghcPkgProgram
(
withPrograms
lbi
)
(
haddock
,
_
)
<-
requireProgram
normal
haddockProgram
(
withPrograms
lbi
)
let
ghcPath
=
programPath
ghc
ghcPkgPath
=
programPath
ghcPkg
haddockPath
=
programPath
haddock
putStrLn
$
"Using ghc: "
++
ghcPath
putStrLn
$
"Using ghc-pkg: "
++
ghcPkgPath
let
haddockPath
=
programPath
haddock
dbFile
=
distPref_
</>
"package.conf.inplace"
config
=
SuiteConfig
{
cabalDistPref
=
distPref_
,
ghcPath
=
programPath
ghc
,
ghcPkgPath
=
programPath
ghcPkg
,
inplaceSpec
=
PackageSpec
{
directory
=
[]
,
configOpts
=
[
"--package-db="
++
dbFile
,
"--constraint=Cabal == "
++
display
cabalVersion
]
,
distPref
=
Nothing
}
}
putStrLn
$
"Cabal test suite - testing cabal version "
++
display
cabalVersion
putStrLn
$
"Using ghc: "
++
ghcPath
config
putStrLn
$
"Using ghc-pkg: "
++
ghcPkgPath
config
putStrLn
$
"Using haddock: "
++
haddockPath
setCurrentDirectory
"tests"
-- Create a shared Setup executable to speed up Simple tests
compileSetup
"."
ghcPath
compileSetup
config
"."
defaultMain
$
testGroup
"Package Tests"
(
tests
cabalVersion
inplaceSpec
ghcPath
ghcPkgPath
)
(
tests
config
cabalVersion
)
-- Like Distribution.Simple.Configure.getPersistBuildConfig but
-- doesn't check that the Cabal version matches, which it doesn't when
...
...
Cabal/tests/PackageTests/BenchmarkExeV10/Check.hs
View file @
2af1c1d5
...
...
@@ -9,8 +9,8 @@ import Test.Tasty.HUnit
dir
::
FilePath
dir
=
"PackageTests"
</>
"BenchmarkExeV10"
checkBenchmark
::
FilePath
->
Assertion
checkBenchmark
ghcPath
=
do
checkBenchmark
::
SuiteConfig
->
Assertion
checkBenchmark
config
=
do
let
spec
=
PackageSpec
dir
Nothing
[
"--enable-benchmarks"
]
buildResult
<-
cabal_build
spec
ghcPath
buildResult
<-
cabal_build
config
spec
assertBuildSucceeded
buildResult
Cabal/tests/PackageTests/BenchmarkOptions/Check.hs
View file @
2af1c1d5
...
...
@@ -4,23 +4,23 @@ import PackageTests.PackageTester
import
System.FilePath
import
Test.Tasty.HUnit
suite
::
FilePath
->
Assertion
suite
ghcPath
=
do
suite
::
SuiteConfig
->
Assertion
suite
config
=
do
let
spec
=
PackageSpec
{
directory
=
"PackageTests"
</>
"BenchmarkOptions"
,
configOpts
=
[
"--enable-benchmarks"
]
,
distPref
=
Nothing
}
_
<-
cabal_build
spec
ghcPath
result
<-
cabal_bench
spec
[
"--benchmark-options=1 2 3"
]
ghcPath
_
<-
cabal_build
config
spec
result
<-
cabal_bench
config
spec
[
"--benchmark-options=1 2 3"
]
let
message
=
"
\"
cabal bench
\"
did not pass the correct options to the "
++
"benchmark executable with
\"
--benchmark-options
\"
"
assertEqual
message
True
$
successful
result
result'
<-
cabal_bench
spec
[
"--benchmark-option=1"
,
"--benchmark-option=
2
"
,
"--benchmark-option=
3
"
]
ghcPath
result'
<-
cabal_bench
config
spec
[
"--benchmark-option=
1
"
,
"--benchmark-option=
2
"
,
"--benchmark-option=3"
]
let
message'
=
"
\"
cabal bench
\"
did not pass the correct options to the "
++
"benchmark executable with
\"
--benchmark-option
\"
"
assertEqual
message'
True
$
successful
result'
Cabal/tests/PackageTests/BenchmarkStanza/Check.hs
View file @
2af1c1d5
...
...
@@ -22,12 +22,12 @@ import Distribution.Compiler
(
CompilerId
(
..
),
CompilerFlavor
(
..
),
unknownCompilerInfo
,
AbiTag
(
..
)
)
import
Distribution.Text
suite
::
FilePath
->
Assertion
suite
ghcPath
=
do
suite
::
SuiteConfig
->
Assertion
suite
config
=
do
let
dir
=
"PackageTests"
</>
"BenchmarkStanza"
pdFile
=
dir
</>
"my"
<.>
"cabal"
spec
=
PackageSpec
{
directory
=
dir
,
configOpts
=
[]
,
distPref
=
Nothing
}
result
<-
cabal_configure
spec
ghcPath
result
<-
cabal_configure
config
spec
assertOutputDoesNotContain
"unknown section type"
result
genPD
<-
readPackageDescription
silent
pdFile
let
compiler
=
unknownCompilerInfo
(
CompilerId
GHC
$
Version
[
6
,
12
,
2
]
[]
)
NoAbiTag
...
...
Cabal/tests/PackageTests/BuildDeps/InternalLibrary0/Check.hs
View file @
2af1c1d5
...
...
@@ -7,14 +7,14 @@ import System.FilePath
import
Test.Tasty.HUnit
suite
::
Version
->
FilePath
->
Assertion
suite
cabalVersion
ghcPath
=
do
suite
::
SuiteConfig
->
Version
->
Assertion
suite
config
cabalVersion
=
do
let
spec
=
PackageSpec
{
directory
=
"PackageTests"
</>
"BuildDeps"
</>
"InternalLibrary0"
,
configOpts
=
[]
,
distPref
=
Nothing
}
result
<-
cabal_build
spec
ghcPath
result
<-
cabal_build
config
spec
assertBuildFailed
result
when
(
cabalVersion
>=
Version
[
1
,
7
]
[]
)
$
do
let
sb
=
"library which is defined within the same package."
...
...
Cabal/tests/PackageTests/BuildDeps/InternalLibrary1/Check.hs
View file @
2af1c1d5
...
...
@@ -5,12 +5,12 @@ import System.FilePath
import
Test.Tasty.HUnit
suite
::
FilePath
->
Assertion
suite
ghcPath
=
do
suite
::
SuiteConfig
->
Assertion
suite
config
=
do
let
spec
=
PackageSpec
{
directory
=
"PackageTests"
</>
"BuildDeps"
</>
"InternalLibrary1"
,
configOpts
=
[]
,
distPref
=
Nothing
}
result
<-
cabal_build
spec
ghcPath
result
<-
cabal_build
config
spec
assertBuildSucceeded
result
Cabal/tests/PackageTests/BuildDeps/InternalLibrary2/Check.hs
View file @
2af1c1d5
...
...
@@ -6,8 +6,8 @@ import System.FilePath
import
Test.Tasty.HUnit
suite
::
FilePath
->
FilePath
->
Assertion
suite
ghcPath
ghcPkgPath
=
do
suite
::
SuiteConfig
->
Assertion
suite
config
=
do
let
spec
=
PackageSpec
{
directory
=
"PackageTests"
</>
"BuildDeps"
</>
"InternalLibrary2"
,
configOpts
=
[]
...
...
@@ -19,12 +19,12 @@ suite ghcPath ghcPkgPath = do
,
distPref
=
Nothing
}
unregister
"InternalLibrary2"
ghcPkgPath
iResult
<-
cabal_install
specTI
ghcPath
unregister
config
"InternalLibrary2"
iResult
<-
cabal_install
config
specTI
assertInstallSucceeded
iResult
bResult
<-
cabal_build
spec
ghcPath
bResult
<-
cabal_build
config
spec
assertBuildSucceeded
bResult
unregister
"InternalLibrary2"
ghcPkgPath
unregister
config
"InternalLibrary2"
(
_
,
_
,
output
)
<-
run
(
Just
$
directory
spec
)
(
directory
spec
</>
"dist"
</>
"build"
</>
"lemon"
</>
"lemon"
)
[]
[]
C
.
appendFile
(
directory
spec
</>
"test-log.txt"
)
(
C
.
pack
$
"
\n
dist/build/lemon/lemon
\n
"
++
output
)
...
...
Cabal/tests/PackageTests/BuildDeps/InternalLibrary3/Check.hs
View file @
2af1c1d5
...
...
@@ -6,8 +6,8 @@ import System.FilePath
import
Test.Tasty.HUnit
suite
::
FilePath
->
FilePath
->
Assertion
suite
ghcPath
ghcPkgPath
=
do
suite
::
SuiteConfig
->
Assertion
suite
config
=
do
let
spec
=
PackageSpec
{
directory
=
"PackageTests"
</>
"BuildDeps"
</>
"InternalLibrary3"
,
configOpts
=
[]
...
...
@@ -19,12 +19,12 @@ suite ghcPath ghcPkgPath = do
,
distPref
=
Nothing
}
unregister
"InternalLibrary3"
ghcPkgPath
iResult
<-
cabal_install
specTI
ghcPath
unregister
config
"InternalLibrary3"
iResult
<-
cabal_install
config
specTI
assertInstallSucceeded
iResult
bResult
<-
cabal_build
spec
ghcPath
bResult
<-
cabal_build
config
spec
assertBuildSucceeded
bResult
unregister
"InternalLibrary3"
ghcPkgPath
unregister
config
"InternalLibrary3"
(
_
,
_
,
output
)
<-
run
(
Just
$
directory
spec
)
(
directory
spec
</>
"dist"
</>
"build"
</>
"lemon"
</>
"lemon"
)
[]
[]
C
.
appendFile
(
directory
spec
</>
"test-log.txt"
)
(
C
.
pack
$
"
\n
dist/build/lemon/lemon
\n
"
++
output
)
...
...
Cabal/tests/PackageTests/BuildDeps/InternalLibrary4/Check.hs
View file @
2af1c1d5
...
...
@@ -6,8 +6,8 @@ import System.FilePath
import
Test.Tasty.HUnit
suite
::
FilePath
->
FilePath
->
Assertion
suite
ghcPath
ghcPkgPath
=
do
suite
::
SuiteConfig
->
Assertion
suite
config
=
do
let
spec
=
PackageSpec
{
directory
=
"PackageTests"
</>
"BuildDeps"
</>
"InternalLibrary4"
,
configOpts
=
[]
...
...
@@ -19,12 +19,12 @@ suite ghcPath ghcPkgPath = do
,
distPref
=
Nothing
}
unregister
"InternalLibrary4"
ghcPkgPath
iResult
<-
cabal_install
specTI
ghcPath
unregister
config
"InternalLibrary4"
iResult
<-
cabal_install
config
specTI
assertInstallSucceeded
iResult
bResult
<-
cabal_build
spec
ghcPath
bResult
<-
cabal_build
config
spec
assertBuildSucceeded
bResult
unregister
"InternalLibrary4"
ghcPkgPath
unregister
config
"InternalLibrary4"
(
_
,
_
,
output
)
<-
run
(
Just
$
directory
spec
)
(
directory
spec
</>
"dist"
</>
"build"
</>
"lemon"
</>
"lemon"
)
[]
[]
C
.
appendFile
(
directory
spec
</>
"test-log.txt"
)
(
C
.
pack
$
"
\n
dist/build/lemon/lemon
\n
"
++
output
)
...
...
Cabal/tests/PackageTests/BuildDeps/SameDepsAllRound/Check.hs
View file @
2af1c1d5
...
...
@@ -6,14 +6,14 @@ import System.FilePath
import
qualified
Control.Exception
as
E
suite
::
FilePath
->
Assertion
suite
ghcPath
=
do
suite
::
SuiteConfig
->
Assertion
suite
config
=
do
let
spec
=
PackageSpec
{
directory
=
"PackageTests"
</>
"BuildDeps"
</>
"SameDepsAllRound"
,
configOpts
=
[]
,
distPref
=
Nothing
}
result
<-
cabal_build
spec
ghcPath
result
<-
cabal_build
config
spec
do
assertEqual
"cabal build should succeed - see test-log.txt"
True
(
successful
result
)
`
E
.
catch
`
\
exc
->
do
...
...
Cabal/tests/PackageTests/BuildDeps/TargetSpecificDeps1/Check.hs
View file @
2af1c1d5
...
...
@@ -8,14 +8,14 @@ import qualified Control.Exception as E
import
Text.Regex.Posix
suite
::
FilePath
->
Assertion
suite
ghcPath
=
do
suite
::
SuiteConfig
->
Assertion
suite
config
=
do
let
spec
=
PackageSpec
{
directory
=
"PackageTests"
</>
"BuildDeps"
</>
"TargetSpecificDeps1"
,
configOpts
=
[]
,
distPref
=
Nothing
}
result
<-
cabal_build
spec
ghcPath
result
<-
cabal_build
config
spec
do
assertEqual
"cabal build should fail - see test-log.txt"
False
(
successful
result
)
assertBool
"error should be in MyLibrary.hs"
$
...
...
Cabal/tests/PackageTests/BuildDeps/TargetSpecificDeps2/Check.hs
View file @
2af1c1d5
...
...
@@ -6,14 +6,14 @@ import System.FilePath
import
qualified
Control.Exception
as
E
suite
::
FilePath
->
Assertion
suite
ghcPath
=
do
suite
::
SuiteConfig
->
Assertion
suite
config
=
do
let
spec
=
PackageSpec
{
directory
=
"PackageTests"
</>
"BuildDeps"
</>
"TargetSpecificDeps2"
,
configOpts
=
[]
,
distPref
=
Nothing
}
result
<-
cabal_build
spec
ghcPath
result
<-
cabal_build
config
spec
do
assertEqual
"cabal build should succeed - see test-log.txt"
True
(
successful
result
)
`
E
.
catch
`
\
exc
->
do
...
...
Cabal/tests/PackageTests/BuildDeps/TargetSpecificDeps3/Check.hs
View file @
2af1c1d5
...
...
@@ -8,14 +8,14 @@ import qualified Control.Exception as E
import
Text.Regex.Posix
suite
::
FilePath
->
Assertion
suite
ghcPath
=
do
suite
::
SuiteConfig
->
Assertion
suite
config
=
do
let
spec
=
PackageSpec
{
directory
=
"PackageTests"
</>
"BuildDeps"
</>
"TargetSpecificDeps3"
,
configOpts
=
[]
,
distPref
=
Nothing
}
result
<-
cabal_build
spec
ghcPath
result
<-
cabal_build
config
spec
do
assertEqual
"cabal build should fail - see test-log.txt"
False
(
successful
result
)
assertBool
"error should be in lemon.hs"
$
...
...
Cabal/tests/PackageTests/BuildTestSuiteDetailedV09/Check.hs
View file @
2af1c1d5
...
...
@@ -5,14 +5,14 @@ import System.FilePath ((</>))
import
PackageTests.PackageTester
suite
::
PackageSpec
->
FilePath
->
Assertion
suite
inplaceSpec
ghcPath
=
do
suite
::
SuiteConfig
->
Assertion
suite
config
=
do
let
dir
=
"PackageTests"
</>
"BuildTestSuiteDetailedV09"
spec
=
inplaceSpec
spec
=
(
inplaceSpec
config
)
{
directory
=
dir
,
configOpts
=
"--enable-tests"
:
configOpts
inplaceSpec
,
configOpts
=
"--enable-tests"
:
configOpts
(
inplaceSpec
config
)
}
confResult
<-
cabal_configure
spec
ghcPath
confResult
<-
cabal_configure
config
spec
assertConfigureSucceeded
confResult
buildResult
<-
cabal_build
spec
ghcPath
buildResult
<-
cabal_build
config
spec
assertBuildSucceeded
buildResult
Cabal/tests/PackageTests/CMain/Check.hs
View file @
2af1c1d5
...
...
@@ -9,12 +9,12 @@ import PackageTests.PackageTester
dir
::
FilePath
dir
=
"PackageTests"
</>
"CMain"
checkBuild
::
FilePath
->
Assertion
checkBuild
ghcPath
=
do
checkBuild
::
SuiteConfig
->
Assertion
checkBuild
config
=
do
let
spec
=
PackageSpec
{
directory
=
dir
,
distPref
=
Nothing
,
configOpts
=
[]
}
buildResult
<-
cabal_build
spec
ghcPath
buildResult
<-
cabal_build
config
spec
assertBuildSucceeded
buildResult
Cabal/tests/PackageTests/DeterministicAr/Check.hs
View file @
2af1c1d5
...
...
@@ -30,9 +30,9 @@ import Distribution.Simple.LocalBuildInfo (LocalBuildInfo, compiler, pkgKey)
assertFailure'
::
String
->
IO
a
assertFailure'
msg
=
assertFailure
msg
>>
return
{-unpossible!-}
undefined
ghcPkg_field
::
String
->
String
->
FilePath
->
IO
[
FilePath
]
ghcPkg_field
libraryName
fieldName
ghcPkgPath
=
do
(
cmd
,
exitCode
,
raw
)
<-
run
Nothing
ghcPkgPath
[]
ghcPkg_field
::
SuiteConfig
->
String
->
String
->
IO
[
FilePath
]
ghcPkg_field
config
libraryName
fieldName
=
do
(
cmd
,
exitCode
,
raw
)
<-
run
Nothing
(
ghcPkgPath
config
)
[]
[
"--user"
,
"field"
,
libraryName
,
fieldName
]
let
output
=
filter
(
'
\r
'
/=
)
raw
-- Windows
-- copypasta of PackageTester.requireSuccess
...
...
@@ -45,9 +45,9 @@ ghcPkg_field libraryName fieldName ghcPkgPath = do
++
show
prefix
++
" prefix on every line.
\n
output: "
++
output
Just
fields
->
return
fields
ghcPkg_field1
::
String
->
String
->
FilePath
->
IO
FilePath
ghcPkg_field1
libraryName
fieldName
ghcPkgPath
=
do
fields
<-
ghcPkg_field
libraryName
fieldName
ghcPkgPath
ghcPkg_field1
::
SuiteConfig
->
String
->
String
->
IO
FilePath
ghcPkg_field1
config
libraryName
fieldName
=
do
fields
<-
ghcPkg_field
config
libraryName
fieldName
case
fields
of
[
field
]
->
return
field
_
->
assertFailure'
$
"Command ghc-pkg field failed: "
...
...
@@ -58,8 +58,8 @@ ghcPkg_field1 libraryName fieldName ghcPkgPath = do
this
::
String
this
=
"DeterministicAr"
suite
::
FilePath
->
FilePath
->
Assertion
suite
ghcPath
ghcPkgPath
=
do
suite
::
SuiteConfig
->
Assertion
suite
config
=
do
let
dir
=
"PackageTests"
</>
this
let
spec
=
PackageSpec
{
directory
=
dir
...
...
@@ -67,15 +67,15 @@ suite ghcPath ghcPkgPath = do
,
distPref
=
Nothing
}
unregister
this
ghcPkgPath
iResult
<-
cabal_install
spec
ghcPath
unregister
config
this
iResult
<-
cabal_install
config
spec
assertInstallSucceeded
iResult
let
distBuild
=
dir
</>
"dist"
</>
"build"
libdir
<-
ghcPkg_field1
this
"library-dirs"
ghcPkgPath
libdir
<-
ghcPkg_field1
config
this
"library-dirs"
lbi
<-
getPersistBuildConfig
(
dir
</>
"dist"
)
mapM_
(
checkMetadata
lbi
)
[
distBuild
,
libdir
]
unregister
this
ghcPkgPath
unregister
config
this
-- Almost a copypasta of Distribution.Simple.Program.Ar.wipeMetadata
checkMetadata
::
LocalBuildInfo
->
FilePath
->
Assertion
...
...
Cabal/tests/PackageTests/EmptyLib/Check.hs
View file @
2af1c1d5
...
...
@@ -5,12 +5,12 @@ import System.FilePath
import
Test.Tasty.HUnit
-- See https://github.com/haskell/cabal/issues/1241
emptyLib
::
FilePath
->
Assertion
emptyLib
ghcPath
=
do
emptyLib
::
SuiteConfig
->
Assertion
emptyLib
config
=
do
let
spec
=
PackageSpec
{
directory
=
"PackageTests"
</>
"EmptyLib"
</>
"empty"
,
configOpts
=
[]
,
distPref
=
Nothing
}
result
<-
cabal_build
spec
ghcPath
result
<-
cabal_build
config
spec
assertBuildSucceeded
result
Cabal/tests/PackageTests/Haddock/Check.hs
View file @
2af1c1d5
...
...
@@ -9,13 +9,13 @@ import Test.Tasty.HUnit (Assertion, assertFailure)
import
Distribution.Simple.Utils
(
withFileContents
)
import
PackageTests.PackageTester
(
PackageSpec
(
..
),
assertHaddockSucceeded
,
cabal_haddock
)
(
PackageSpec
(
..
),
SuiteConfig
,
assertHaddockSucceeded
,
cabal_haddock
)
this
::
String
this
=
"Haddock"
suite
::
FilePath
->
Assertion
suite
ghcPath
=
do
suite
::
SuiteConfig
->
Assertion
suite
config
=
do
let
dir
=
"PackageTests"
</>
this
haddocksDir
=
dir
</>
"dist"
</>
"doc"
</>
"html"
</>
"Haddock"
spec
=
PackageSpec