diff --git a/cabal-install/tests/IntegrationTests2.hs b/cabal-install/tests/IntegrationTests2.hs index 19c4aa484610987a2d89fb3e23ef437472f532b0..4ca346930edf7351a0f9fe3173ec895d4473a660 100644 --- a/cabal-install/tests/IntegrationTests2.hs +++ b/cabal-install/tests/IntegrationTests2.hs @@ -98,12 +98,13 @@ tests config = , testCase "proj conf1" (testExceptionInProjectConfig config) ] , testGroup "Target selectors" $ - [ testCaseSteps "valid" testTargetSelectors - , testCase "bad syntax" testTargetSelectorBadSyntax - , testCaseSteps "ambiguous syntax" testTargetSelectorAmbiguous - , testCase "no current pkg" testTargetSelectorNoCurrentPackage - , testCase "no targets" testTargetSelectorNoTargets - , testCase "project empty" testTargetSelectorProjectEmpty + [ testCaseSteps "valid" testTargetSelectors + , testCase "bad syntax" testTargetSelectorBadSyntax + , testCaseSteps "ambiguous syntax" testTargetSelectorAmbiguous + , testCase "no current pkg" testTargetSelectorNoCurrentPackage + , testCase "no targets" testTargetSelectorNoTargets + , testCase "project empty" testTargetSelectorProjectEmpty + , testCase "canonicalized path" testTargetSelectorCanonicalizedPath , testCase "problems (common)" (testTargetProblemsCommon config) , testCaseSteps "problems (build)" (testTargetProblemsBuild config) , testCaseSteps "problems (repl)" (testTargetProblemsRepl config) @@ -554,6 +555,28 @@ testTargetSelectorProjectEmpty = do config = mempty +-- | Ensure we don't miss primary package and produce +-- TargetSelectorNoTargetsInCwd error due to symlink or +-- drive capitalisation mismatch when no targets are given +testTargetSelectorCanonicalizedPath :: Assertion +testTargetSelectorCanonicalizedPath = do + (_, _, _, localPackages, _) <- configureProject testdir config + cwd <- getCurrentDirectory + let virtcwd = cwd </> basedir </> symlink + -- Check that the symlink is there before running test as on Windows + -- some versions/configurations of git won't pull down/create the symlink + canRunTest <- doesDirectoryExist virtcwd + when canRunTest (do + let dirActions' = (dirActions symlink) { TS.getCurrentDirectory = return virtcwd } + Right ts <- readTargetSelectorsWith dirActions' localPackages Nothing [] + ts @?= [TargetPackage TargetImplicitCwd ["p-0.1"] Nothing]) + cleanProject testdir + where + testdir = "targets/simple" + symlink = "targets/symbolic-link-to-simple" + config = mempty + + testTargetProblemsCommon :: ProjectConfig -> Assertion testTargetProblemsCommon config0 = do (_,elaboratedPlan,_) <- planProject testdir config diff --git a/cabal-install/tests/IntegrationTests2/targets/symbolic-link-to-simple b/cabal-install/tests/IntegrationTests2/targets/symbolic-link-to-simple new file mode 120000 index 0000000000000000000000000000000000000000..a8b60b7dc9e1bc259f4832a67f38988ad4727fea --- /dev/null +++ b/cabal-install/tests/IntegrationTests2/targets/symbolic-link-to-simple @@ -0,0 +1 @@ +./simple \ No newline at end of file