Commit 69d90bd1 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Port user-config to cabal-testsuite


Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 7f2f63ce
......@@ -66,15 +66,6 @@ Extra-Source-Files:
tests/IntegrationTests/sandbox-sources/remove_nonexistent_source.sh
tests/IntegrationTests/sandbox-sources/report_success_removing_source.out
tests/IntegrationTests/sandbox-sources/report_success_removing_source.sh
tests/IntegrationTests/user-config/common.sh
tests/IntegrationTests/user-config/doesnt_overwrite_without_f.err
tests/IntegrationTests/user-config/doesnt_overwrite_without_f.sh
tests/IntegrationTests/user-config/overwrites_with_f.out
tests/IntegrationTests/user-config/overwrites_with_f.sh
tests/IntegrationTests/user-config/runs_without_error.out
tests/IntegrationTests/user-config/runs_without_error.sh
tests/IntegrationTests/user-config/uses_CABAL_CONFIG.out
tests/IntegrationTests/user-config/uses_CABAL_CONFIG.sh
tests/IntegrationTests2/build/keep-going/cabal.project
tests/IntegrationTests2/build/keep-going/p/P.hs
tests/IntegrationTests2/build/keep-going/p/p.cabal
......
-- This is the configuration file for the 'cabal' command line tool.
-- The available configuration options are listed below.
-- Some of them have default values listed.
-- Lines (like this one) beginning with '--' are comments.
-- Be careful with spaces and indentation because they are
-- used to indicate layout for nested sections.
repository hackage.haskell.org
url: http://hackage.haskell.org/
-- default-user-config:
-- require-sandbox: False
-- ignore-sandbox: False
-- ignore-expiry: False
-- http-transport:
remote-repo-cache: /home/gman/.cabal/packages
-- local-repo:
-- logs-dir:
world-file: /home/gman/.cabal/world
-- verbose: 1
-- compiler: ghc
-- with-compiler:
-- with-hc-pkg:
-- program-prefix:
-- program-suffix:
-- library-vanilla: True
-- library-profiling:
-- shared:
-- executable-dynamic: False
-- profiling:
-- executable-profiling:
-- profiling-detail:
-- library-profiling-detail:
-- optimization: True
-- debug-info: False
-- library-for-ghci:
-- split-objs: False
-- executable-stripping: True
-- library-stripping: True
-- configure-option:
-- user-install: True
-- package-db:
-- flags:
-- extra-include-dirs:
-- extra-lib-dirs:
extra-prog-path: /home/gman/.cabal/bin
-- tests: False
-- coverage: False
-- library-coverage:
-- exact-configuration: False
-- benchmarks: False
-- relocatable: False
-- cabal-lib-version:
-- constraint:
-- preference:
-- solver: choose
-- allow-newer: False
-- documentation: False
-- doc-index-file: $datadir/doc/$arch-$os-$compiler/index.html
-- max-backjumps: 2000
-- reorder-goals: False
-- shadow-installed-packages: False
-- strong-flags: False
-- reinstall: False
-- avoid-reinstalls: False
-- force-reinstalls: False
-- upgrade-dependencies: False
-- root-cmd:
-- symlink-bindir:
build-summary: /home/gman/.cabal/logs/build.log
-- build-log:
remote-build-reporting: anonymous
-- report-planning-failure: False
-- one-shot: False
-- run-tests:
jobs: $ncpus
-- offline: False
-- username:
-- password:
-- password-command:
-- builddir:
haddock
-- keep-temp-files: False
-- hoogle: False
-- html: False
-- html-location:
-- for-hackage: False
-- executables: False
-- tests: False
-- benchmarks: False
-- all:
-- internal: False
-- css:
-- hyperlink-source: False
-- hscolour-css:
-- contents-location:
install-dirs user
-- prefix: /home/gman/.cabal
-- bindir: $prefix/bin
-- libdir: $prefix/lib
-- libsubdir: $abi/$libname
-- libexecdir: $prefix/libexec
-- datadir: $prefix/share
-- datasubdir: $abi/$pkgid
-- docdir: $datadir/doc/$abi/$pkgid
-- htmldir: $docdir/html
-- haddockdir: $htmldir
-- sysconfdir: $prefix/etc
install-dirs global
-- prefix: /usr/local
-- bindir: $prefix/bin
-- libdir: $prefix/lib
-- libsubdir: $abi/$libname
-- libexecdir: $prefix/libexec
-- datadir: $prefix/share
-- datasubdir: $abi/$pkgid
-- docdir: $datadir/doc/$abi/$pkgid
-- htmldir: $docdir/html
-- haddockdir: $htmldir
-- sysconfdir: $prefix/etc
program-locations
-- alex-location:
-- ar-location:
-- c2hs-location:
-- cpphs-location:
-- gcc-location:
-- ghc-location:
-- ghc-pkg-location:
-- ghcjs-location:
-- ghcjs-pkg-location:
-- greencard-location:
-- haddock-location:
-- happy-location:
-- haskell-suite-location:
-- haskell-suite-pkg-location:
-- hmake-location:
-- hpc-location:
-- hsc2hs-location:
-- hscolour-location:
-- jhc-location:
-- ld-location:
-- lhc-location:
-- lhc-pkg-location:
-- pkg-config-location:
-- strip-location:
-- tar-location:
-- uhc-location:
program-default-options
-- alex-options:
-- ar-options:
-- c2hs-options:
-- cpphs-options:
-- gcc-options:
-- ghc-options:
-- ghc-pkg-options:
-- ghcjs-options:
-- ghcjs-pkg-options:
-- greencard-options:
-- haddock-options:
-- happy-options:
-- haskell-suite-options:
-- haskell-suite-pkg-options:
-- hmake-options:
-- hpc-options:
-- hsc2hs-options:
-- hscolour-options:
-- jhc-options:
-- ld-options:
-- lhc-options:
-- lhc-pkg-options:
-- pkg-config-options:
-- strip-options:
-- tar-options:
-- uhc-options:
# Helper to run Cabal
cabal() {
"$CABAL" $CABAL_ARGS_NO_CONFIG_FILE "$@"
}
die() {
echo "die: $@"
exit 1
}
. ./common.sh
rm -f ./cabal-config
cabal --config-file=./cabal-config user-config init > /dev/null
! cabal --config-file=./cabal-config user-config init
Writing default configuration to ./cabal-config
Writing default configuration to ./cabal-config
. ./common.sh
rm -f ./cabal-config
cabal --config-file=./cabal-config user-config init \
|| die "Couldn't create config file"
cabal --config-file=./cabal-config user-config -f init \
|| die "Couldn't create config file"
test -e ./cabal-config || die "Config file doesn't exist"
rm -f ./cabal-config
. ./common.sh
rm -f ./cabal-config
cabal --config-file=./cabal-config user-config init \
|| die "Couldn't create config file"
test -e ./cabal-config || die "Config file doesn't exist"
rm -f ./cabal-config
. ./common.sh
export CABAL_CONFIG=./my-config
cabal user-config init || die "Couldn't create config file"
test -e ./my-config || die "Config file doesn't exist"
# cabal user-config
Writing default configuration to <ROOT>/cabal.dist/cabal-config
# cabal user-config
cabal: <ROOT>/cabal.dist/cabal-config already exists.
# cabal user-config
Writing default configuration to <ROOT>/cabal.dist/cabal-config
# cabal user-config
Writing default configuration to <ROOT>/cabal.dist/cabal-config2
import Test.Cabal.Prelude
main = cabalTest $ do
workdir <- fmap testWorkDir getTestEnv
let conf = workdir </> "cabal-config"
cabalG ["--config-file", conf] "user-config" ["init"]
shouldExist conf
fails $ cabalG ["--config-file", workdir </> "cabal-config"] "user-config" ["init"]
cabalG ["--config-file", conf] "user-config" ["-f", "init"]
shouldExist conf
let conf2 = workdir </> "cabal-config2"
withEnv [("CABAL_CONFIG", Just conf2)] $ do
cabal "user-config" ["init"]
shouldExist conf2
......@@ -231,18 +231,24 @@ cabal "sandbox" _ =
cabal cmd args = void (cabal' cmd args)
cabal' :: String -> [String] -> TestM Result
cabal' "sandbox" _ =
cabal' = cabalG' []
cabalG :: [String] -> String -> [String] -> TestM ()
cabalG global_args cmd args = void (cabalG' global_args cmd args)
cabalG' :: [String] -> String -> [String] -> TestM Result
cabalG' _ "sandbox" _ =
-- NB: We don't just auto-pass this through, because it's
-- possible that the first argument isn't the sub-sub-command.
-- So make sure the user specifies it correctly.
error "Use cabal_sandbox' instead"
cabal' cmd args = do
cabalG' global_args cmd args = do
env <- getTestEnv
let extra_args
-- Sandboxes manage dist dir
| testHaveSandbox env
= install_args
| cmd == "update" || cmd == "outdated"
| cmd == "update" || cmd == "outdated" || cmd == "user-config"
= [ ]
-- new-build commands are affected by testCabalProjectFile
| "new-" `isPrefixOf` cmd
......@@ -256,12 +262,13 @@ cabal' cmd args = do
| cmd == "install"
|| cmd == "build" = [ "-j1" ]
| otherwise = []
global_args
extra_global_args
| testHaveSandbox env
= [ "--sandbox-config-file", testSandboxConfigFile env ]
| otherwise
= []
cabal_args = global_args
cabal_args = extra_global_args
++ global_args
++ [ cmd, marked_verbose ]
++ extra_args
++ args
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment