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

Fix bug #3150, regression introduced by a2184538.



Added tests for this case, as well as some more.  This
probably breaks the Windows build.
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 1151e7b5
......@@ -89,6 +89,24 @@ extra-source-files:
tests/PackageTests/DuplicateModuleName/tests/Foo.hs
tests/PackageTests/DuplicateModuleName/tests2/Foo.hs
tests/PackageTests/EmptyLib/empty/empty.cabal
tests/PackageTests/GhcPkgGuess/SameDirectory/SameDirectory.cabal
tests/PackageTests/GhcPkgGuess/SameDirectory/ghc
tests/PackageTests/GhcPkgGuess/SameDirectory/ghc-pkg
tests/PackageTests/GhcPkgGuess/SameDirectoryGhcVersion/SameDirectory.cabal
tests/PackageTests/GhcPkgGuess/SameDirectoryGhcVersion/ghc-7.10
tests/PackageTests/GhcPkgGuess/SameDirectoryGhcVersion/ghc-pkg-ghc-7.10
tests/PackageTests/GhcPkgGuess/SameDirectoryVersion/SameDirectory.cabal
tests/PackageTests/GhcPkgGuess/SameDirectoryVersion/ghc-7.10
tests/PackageTests/GhcPkgGuess/SameDirectoryVersion/ghc-pkg-7.10
tests/PackageTests/GhcPkgGuess/Symlink/SameDirectory.cabal
tests/PackageTests/GhcPkgGuess/Symlink/bin/ghc
tests/PackageTests/GhcPkgGuess/Symlink/bin/ghc-pkg
tests/PackageTests/GhcPkgGuess/SymlinkGhcVersion/SameDirectory.cabal
tests/PackageTests/GhcPkgGuess/SymlinkGhcVersion/bin/ghc-7.10
tests/PackageTests/GhcPkgGuess/SymlinkGhcVersion/bin/ghc-pkg-7.10
tests/PackageTests/GhcPkgGuess/SymlinkVersion/SameDirectory.cabal
tests/PackageTests/GhcPkgGuess/SymlinkVersion/bin/ghc-7.10
tests/PackageTests/GhcPkgGuess/SymlinkVersion/bin/ghc-pkg-ghc-7.10
tests/PackageTests/Haddock/CPP.hs
tests/PackageTests/Haddock/Literate.lhs
tests/PackageTests/Haddock/NoCPP.hs
......
......@@ -186,22 +186,24 @@ guessToolFromGhcPath tool ghcProg verbosity searchpath
real_path <- canonicalizePath given_path
let real_dir = takeDirectory real_path
versionSuffix path = takeVersionSuffix (dropExeExtension path)
given_suf = versionSuffix given_path
real_suf = versionSuffix real_path
guessNormal dir = dir </> toolname <.> exeExtension
guessGhcVersioned dir = dir </> (toolname ++ "-ghc"
++ versionSuffix dir)
<.> exeExtension
guessVersioned dir = dir </> (toolname ++ versionSuffix dir)
<.> exeExtension
mkGuesses dir | null (versionSuffix dir) = [guessNormal dir]
| otherwise = [guessGhcVersioned dir,
guessVersioned dir,
guessNormal dir]
guesses = mkGuesses given_dir ++
guessGhcVersioned dir suf = dir </> (toolname ++ "-ghc" ++ suf)
<.> exeExtension
guessVersioned dir suf = dir </> (toolname ++ suf)
<.> exeExtension
mkGuesses dir suf | null suf = [guessNormal dir]
| otherwise = [guessGhcVersioned dir suf,
guessVersioned dir suf,
guessNormal dir]
guesses = mkGuesses given_dir given_suf ++
if real_path == given_path
then []
else mkGuesses real_dir
else mkGuesses real_dir real_suf
info verbosity $ "looking for tool " ++ toolname
++ " near compiler in " ++ given_dir
debug verbosity $ "candidate locations: " ++ show guesses
exists <- mapM doesFileExist guesses
case [ file | (file, True) <- zip guesses exists ] of
-- If we can't find it near ghc, fall back to the usual
......
......@@ -9,7 +9,7 @@ fi
set -ex
find tests -type f \( -name '*.hs' -or -name '*.lhs' -or -name '*.c' -or -name '*.sh' \
-or -name '*.cabal' -or -name '*.hsc' -or -name '*.err' -or -name '*.out' \) -and -not -regex ".*/dist/.*" \
-or -name '*.cabal' -or -name '*.hsc' -or -name '*.err' -or -name '*.out' -or -name "ghc*" \) -and -not -regex ".*/dist/.*" \
| awk '/Check.hs$|UnitTests|PackageTester|autogen|PackageTests.hs|IntegrationTests.hs|CreatePipe|^tests\/Test/ { next } { print }' \
| LC_ALL=C sort \
| sed -e 's/^/ /' \
......
name: SameDirectory
version: 0.1.0.0
license: BSD3
author: Edward Z. Yang
maintainer: ezyang@cs.stanford.edu
build-type: Simple
cabal-version: >=1.10
library
build-depends: base
default-language: Haskell2010
#!/bin/sh
if [ -z "$WITH_GHC" ]; then
echo "Need to set WITH_GHC"
exit 1
fi
exec "$WITH_GHC" "$@"
#!/bin/sh
echo "GHC package manager version 9999999"
exit 0
name: SameDirectory
version: 0.1.0.0
license: BSD3
author: Edward Z. Yang
maintainer: ezyang@cs.stanford.edu
build-type: Simple
cabal-version: >=1.10
library
build-depends: base
default-language: Haskell2010
#!/bin/sh
if [ -z "$WITH_GHC" ]; then
echo "Need to set WITH_GHC"
exit 1
fi
exec "$WITH_GHC" "$@"
#!/bin/sh
echo "GHC package manager version 9999999"
exit 0
name: SameDirectory
version: 0.1.0.0
license: BSD3
author: Edward Z. Yang
maintainer: ezyang@cs.stanford.edu
build-type: Simple
cabal-version: >=1.10
library
build-depends: base
default-language: Haskell2010
#!/bin/sh
if [ -z "$WITH_GHC" ]; then
echo "Need to set WITH_GHC"
exit 1
fi
exec "$WITH_GHC" "$@"
#!/bin/sh
echo "GHC package manager version 9999999"
exit 0
name: SameDirectory
version: 0.1.0.0
license: BSD3
author: Edward Z. Yang
maintainer: ezyang@cs.stanford.edu
build-type: Simple
cabal-version: >=1.10
library
build-depends: base
default-language: Haskell2010
#!/bin/sh
if [ -z "$WITH_GHC" ]; then
echo "Need to set WITH_GHC"
exit 1
fi
exec "$WITH_GHC" "$@"
#!/bin/sh
echo "GHC package manager version 9999999"
exit 0
bin/ghc
\ No newline at end of file
name: SameDirectory
version: 0.1.0.0
license: BSD3
author: Edward Z. Yang
maintainer: ezyang@cs.stanford.edu
build-type: Simple
cabal-version: >=1.10
library
build-depends: base
default-language: Haskell2010
#!/bin/sh
if [ -z "$WITH_GHC" ]; then
echo "Need to set WITH_GHC"
exit 1
fi
exec "$WITH_GHC" "$@"
#!/bin/sh
echo "GHC package manager version 9999999"
exit 0
bin/ghc-7.10
\ No newline at end of file
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