@@ -3,10 +3,10 @@ module Tests.Old (tests) where
33import Test.Framework (testGroup, Test )
44import Test.Framework.Providers.HUnit
55import Test.HUnit ( assertBool )
6−import System.Environment ( getArgs )
6+import System.Environment.Executable (getExecutablePath)
77import System.IO ( openTempFile, stderr )
88import System.Process ( runProcess, waitForProcess )
9−import System.FilePath ( (</>), (<.>) )
9+import System.FilePath ( (</>), (<.>), takeDirectory )
1010import System.Directory
1111import System.Exit
1212import Data.Algorithm.Diff
@@ -225,11 +225,16 @@ testWithNormalize :: (String -> String) -- ^ Normalize function for output
225225 -> FilePath -- ^ Norm (for test results) filepath
226226 -> Test
227227testWithNormalize normalizer testname opts inp norm = testCase testname $ do
228− args <- getArgs
229− let buildDir = case args of
230− (x:_) -> ".." </> x
231− _ -> error "test-pandoc: missing buildDir argument"
232− let pandocPath = buildDir </> "pandoc" </> "pandoc"
228+ -- find pandoc executable relative to test-pandoc
229+ -- First, try in same directory (e.g. if both in ~/.cabal/bin)
230+ -- Second, try ../pandoc (e.g. if in dist/XXX/build/test-pandoc)
231+ pandocPath <- do
232+ testExePath <- getExecutablePath
233+ let testExeDir = takeDirectory testExePath
234+ found <- doesFileExist (testExeDir </> "pandoc")
235+ return $ if found
236+ then testExeDir </> "pandoc"
237+ else testExeDir </> ".." </> "pandoc" </> "pandoc"
233238 (outputPath, hOut) <- openTempFile "" "pandoc-test"
234239 let inpPath = inp
235240 let normPath = norm