Skip to content

Commit

Permalink
Try using hackage-repo-tool for cabal-testsuite on AppVeyor.
Browse files Browse the repository at this point in the history
  • Loading branch information
grayjay committed Mar 12, 2018
1 parent 59bb50b commit d547107
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
11 changes: 7 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ build_script:
- Setup build
- Setup test --show-details=streaming --test-option=--hide-successes
- Setup install
# hackage-repo-tool doesn't build on Windows:
# https://github.com/well-typed/hackage-security/issues/175
# - echo "" | cabal install hackage-repo-tool --allow-newer=Cabal,time --constraint="Cabal == 2.3.0.0"
- cd ..\cabal-testsuite
- cd ..
- git clone https://github.com/haskell/hackage-security.git
- cd hackage-security\hackage-security
- echo "" | cabal install --allow-newer=Cabal,time --constraint="Cabal == 2.3.0.0"
- cd ..\hackage-repo-tool
- echo "" | cabal install --allow-newer=Cabal,time --constraint="Cabal == 2.3.0.0"
- cd ..\..\cabal-testsuite
- ghc --make -threaded -i Setup.hs -package Cabal-2.3.0.0
- echo "" | ..\appveyor-retry cabal install --only-dependencies --enable-tests
- Setup configure --user --ghc-option=-Werror --enable-tests
Expand Down
2 changes: 1 addition & 1 deletion cabal-testsuite/PackageTests/CustomDep/cabal.test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ main = cabalTest $ do
-- database, don't record the output
recordMode DoNotRecord $ do
-- TODO: Hack, delete me
withEnvFilter (/= "HOME") $ do
withEnvFilter (`notElem` ["HOME", "CABAL_CONFIG"]) $ do
cabal "new-build" ["all"]
2 changes: 1 addition & 1 deletion cabal-testsuite/PackageTests/CustomPlain/cabal.test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ main = cabalTest $ do
-- Regression test for #4393
recordMode DoNotRecord $ do
-- TODO: Hack; see also CustomDep/cabal.test.hs
withEnvFilter (/= "HOME") $ do
withEnvFilter (`notElem` ["HOME", "CABAL_CONFIG"]) $ do
-- On -v2, we don't have vQuiet set, which suppressed
-- the error
cabal "new-build" ["-v1"]
16 changes: 9 additions & 7 deletions cabal-testsuite/Test/Cabal/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module Test.Cabal.Monad (
resub,
-- * Derived values from 'TestEnv'
testCurrentDir,
testCaseName,
testWorkDir,
testPrefixDir,
testDistDir,
Expand Down Expand Up @@ -316,7 +317,8 @@ runTestM mode m = do
-- Try to avoid Unicode output
[ ("LC_ALL", Just "C")
-- Hermetic builds (knot-tied)
, ("HOME", Just (testHomeDir env))],
, ("HOME", Just (testHomeDir env))
, ("CABAL_CONFIG", Just (testUserCabalConfigFile env))],
testShouldFail = False,
testRelativeCurrentDir = ".",
testHavePackageDb = False,
Expand Down Expand Up @@ -588,15 +590,15 @@ testCurrentDir env =
then testSourceCopyDir env
else testSourceDir env) </> testRelativeCurrentDir env

testName :: TestEnv -> String
testName env = testSubName env <.> testMode env
testCaseName :: TestEnv -> String
testCaseName env = testSubName env <.> testMode env

-- | The absolute path to the directory containing all the
-- files for ALL tests associated with a test (respecting
-- subtests.) To clean, you ONLY need to delete this directory.
testWorkDir :: TestEnv -> FilePath
testWorkDir env =
testSourceDir env </> (testName env <.> "dist")
testSourceDir env </> (testCaseName env <.> "dist")

-- | The absolute prefix where installs go.
testPrefixDir :: TestEnv -> FilePath
Expand Down Expand Up @@ -644,16 +646,16 @@ testUserCabalConfigFile env = testHomeDir env </> ".cabal" </> "config"

-- | The file where the expected output of the test lives
testExpectFile :: TestEnv -> FilePath
testExpectFile env = testSourceDir env </> testName env <.> "out"
testExpectFile env = testSourceDir env </> testCaseName env <.> "out"

-- | Where we store the actual output
testActualFile :: TestEnv -> FilePath
testActualFile env = testWorkDir env </> testName env <.> "comp.out"
testActualFile env = testWorkDir env </> testCaseName env <.> "comp.out"

-- | Where we will write the normalized actual file (for diffing)
testNormalizedActualFile :: TestEnv -> FilePath
testNormalizedActualFile env = testActualFile env <.> "normalized"

-- | Where we will write the normalized expected file (for diffing)
testNormalizedExpectFile :: TestEnv -> FilePath
testNormalizedExpectFile env = testWorkDir env </> testName env <.> "out.normalized"
testNormalizedExpectFile env = testWorkDir env </> testCaseName env <.> "out.normalized"
4 changes: 2 additions & 2 deletions cabal-testsuite/Test/Cabal/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ src `archiveTo` dst = do
-- TODO: Consider using the @tar@ library?
let (src_parent, src_dir) = splitFileName src
-- TODO: --format ustar, like createArchive?
tar ["-czf", dst, "-C", src_parent, src_dir]
tar ["-czf", dst, "--force-local", "-C", src_parent, src_dir]

infixr 4 `archiveTo`

Expand Down Expand Up @@ -512,7 +512,7 @@ withRepo repo_dir m = do
let package_cache = testHomeDir env </> ".cabal" </> "packages"
liftIO $ appendFile (testUserCabalConfigFile env)
$ unlines [ "repository test-local-repo"
, " url: file:" ++ testRepoDir env
, " url: file:" ++ testCaseName env ++ ".dist/repo"
, " secure: True"
-- TODO: Hypothetically, we could stick in the
-- correct key here
Expand Down

0 comments on commit d547107

Please sign in to comment.