-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression tests for overwrite policies and porgram-affixes
Add regression tests for the `program-prefix` and `program-suffix` flags combined with the overwrite-policy. In short, the overwrite-policy needs to take potential program affixes into account when deciding whether it will need to overwrite a program path during installation.
- Loading branch information
Showing
2 changed files
with
226 additions
and
0 deletions.
There are no files selected for viewing
160 changes: 160 additions & 0 deletions
160
cabal-testsuite/PackageTests/Install/ProgramAffixes/overwrite-policy.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Build profile: -w ghc-<GHCVER> -O1 | ||
In order, the following will be built: | ||
- p-1.0 (exe:p) (requires build) | ||
Configuring p-1.0... | ||
Preprocessing executable 'p' for p-1.0... | ||
Building executable 'p' for p-1.0... | ||
Installing executable p in <PATH> | ||
Warning: The directory <ROOT>/overwrite-policy.dist/home/.cabal/store/ghc-<GHCVER>/incoming/new-<RAND><ROOT>/overwrite-policy.dist/home/.cabal/store/ghc-<GHCVER>/<PACKAGE>-<HASH>/bin is not in the system search path. | ||
Symlinking 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Error: [Cabal-7149] | ||
Path '<ROOT>/overwrite-policy.dist/usr/bin/p' already exists. Use --overwrite-policy=always to overwrite. | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Symlinking 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Symlinking 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Symlinking 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p-my-suffix' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Error: [Cabal-7149] | ||
Path '<ROOT>/overwrite-policy.dist/usr/bin/p-my-suffix' already exists. Use --overwrite-policy=always to overwrite. | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Symlinking 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p-my-suffix' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Symlinking 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Symlinking 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Symlinking 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/my-prefix-p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Error: [Cabal-7149] | ||
Path '<ROOT>/overwrite-policy.dist/usr/bin/my-prefix-p' already exists. Use --overwrite-policy=always to overwrite. | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Symlinking 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/my-prefix-p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Symlinking 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Symlinking 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Symlinking 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/my-prefix-p-my-suffix' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Error: [Cabal-7149] | ||
Path '<ROOT>/overwrite-policy.dist/usr/bin/my-prefix-p-my-suffix' already exists. Use --overwrite-policy=always to overwrite. | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Symlinking 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/my-prefix-p-my-suffix' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Symlinking 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Copying 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Error: [Cabal-7149] | ||
Path '<ROOT>/overwrite-policy.dist/usr/bin/p' already exists. Use --overwrite-policy=always to overwrite. | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Copying 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Copying 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Copying 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p-my-suffix' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Error: [Cabal-7149] | ||
Path '<ROOT>/overwrite-policy.dist/usr/bin/p-my-suffix' already exists. Use --overwrite-policy=always to overwrite. | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Copying 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p-my-suffix' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Copying 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Copying 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Copying 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/my-prefix-p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Error: [Cabal-7149] | ||
Path '<ROOT>/overwrite-policy.dist/usr/bin/my-prefix-p' already exists. Use --overwrite-policy=always to overwrite. | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Copying 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/my-prefix-p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Copying 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Copying 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Copying 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/my-prefix-p-my-suffix' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Error: [Cabal-7149] | ||
Path '<ROOT>/overwrite-policy.dist/usr/bin/my-prefix-p-my-suffix' already exists. Use --overwrite-policy=always to overwrite. | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Copying 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/my-prefix-p-my-suffix' | ||
# cabal install | ||
Wrote tarball sdist to <ROOT>/overwrite-policy.dist/work/./dist/sdist/p-1.0.tar.gz | ||
Resolving dependencies... | ||
Copying 'p' to '<ROOT>/overwrite-policy.dist/usr/bin/p' |
66 changes: 66 additions & 0 deletions
66
cabal-testsuite/PackageTests/Install/ProgramAffixes/overwrite-policy.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import Test.Cabal.Prelude | ||
import System.FilePath ((</>)) | ||
import System.Directory (removeFile) | ||
|
||
main = cabalTest $ do | ||
runTestForInstallMethod "symlink" | ||
runTestForInstallMethod "copy" | ||
|
||
runTestForInstallMethod :: String -> TestM () | ||
runTestForInstallMethod method = do | ||
env <- getTestEnv | ||
let installdir = testPrefixDir env </> "bin" | ||
|
||
-- install the binary, don't overwrite anything | ||
cabal "install" | ||
["p", "--installdir", installdir, "--install-method", method, "--overwrite-policy", "never"] | ||
-- install the binary, don't overwrite anything | ||
fails $ cabal "install" | ||
["p", "--installdir", installdir, "--install-method", method, "--overwrite-policy", "never"] | ||
-- install the binary again, forcing an overwrite, should succeed. | ||
cabal "install" | ||
["p", "--installdir", installdir, "--install-method", method, "--overwrite-policy", "always"] | ||
-- remove the installed binary. | ||
liftIO $ removeFile (installdir </> "p" <.> exeExt) | ||
|
||
testPolicyForAffix installdir method ["--program-suffix", "-my-suffix"] | ||
testPolicyForAffix installdir method ["--program-prefix", "my-prefix-"] | ||
testPolicyForAffix installdir method ["--program-prefix", "my-prefix-", "--program-suffix", "-my-suffix"] | ||
-- remove the installed binaries. | ||
liftIO $ removeFile (installdir </> "p" <.> exeExt) | ||
liftIO $ removeFile (installdir </> "p-my-suffix" <.> exeExt) | ||
liftIO $ removeFile (installdir </> "my-prefix-p" <.> exeExt) | ||
liftIO $ removeFile (installdir </> "my-prefix-p-my-suffix" <.> exeExt) | ||
|
||
-- | Run a policy test for a given 'install-method' and program-affix | ||
-- (i.e., '--program-suffix' or '--program-prefix'). | ||
-- | ||
-- When a program affix is given, the installation should not be affected | ||
-- by installing the binary with no affix and vice-versa. | ||
-- So, installing the program without any affix is not affected by installations with | ||
-- some program affix. | ||
testPolicyForAffix :: FilePath -> String -> [String] -> TestM () | ||
testPolicyForAffix installdir method affixArgs = do | ||
-- install the binary again, forcing an overwrite, must succeed. | ||
-- The rest of this test assumes the binary has been installed before. | ||
cabal "install" | ||
["p", "--installdir", installdir, "--install-method", method, "--overwrite-policy", "always"] | ||
|
||
-- Install the binary with some program affix, don't need overwrite anything | ||
cabal "install" | ||
(["p", "--installdir", installdir, "--install-method", method, "--overwrite-policy", "never"] ++ affixArgs) | ||
-- Once the binary is installed, we can't overwrite it unless we are told so. | ||
fails $ cabal "install" | ||
(["p", "--installdir", installdir, "--install-method", method, "--overwrite-policy", "never"] ++ affixArgs) | ||
-- Successfully overwrite the binary if told so. | ||
cabal "install" | ||
(["p", "--installdir", installdir, "--install-method", method, "--overwrite-policy", "always"] ++ affixArgs) | ||
|
||
-- remove the installed binary. | ||
liftIO $ removeFile (installdir </> "p" <.> exeExt) | ||
-- Make sure we can still install the original program with no program affix without overwriting, | ||
-- even though, the program is already installed with some affix. | ||
cabal "install" | ||
["p", "--installdir", installdir, "--install-method", method, "--overwrite-policy", "never"] | ||
|
||
exeExt = if isWindows then "exe" else "" |