Commit 043bbd9d authored by refold's avatar refold
Browse files

Add a test for withSandboxBinDirOnSearchPath.

parent b41b92c3
......@@ -15,7 +15,8 @@ module Distribution.Client.Sandbox (
sandboxBuild,
sandboxInstall,
dumpPackageEnvironment
dumpPackageEnvironment,
withSandboxBinDirOnSearchPath
) where
import Distribution.Client.Setup
......
......@@ -172,6 +172,7 @@ Test-Suite unit-tests
hs-source-dirs: tests
build-depends:
base,
filepath,
test-framework,
test-framework-hunit,
HUnit,
......
......@@ -3,13 +3,16 @@ module Main
import Test.Framework
import qualified UnitTests.Distribution.Client.Sandbox
import qualified UnitTests.Distribution.Client.Targets
tests :: [Test]
tests = [
testGroup "Distribution.Client.Targets"
UnitTests.Distribution.Client.Targets.tests
]
testGroup "Distribution.Client.Sandbox"
UnitTests.Distribution.Client.Sandbox.tests
,testGroup "Distribution.Client.Targets"
UnitTests.Distribution.Client.Targets.tests
]
main :: IO ()
main = defaultMain tests
module UnitTests.Distribution.Client.Sandbox (
tests
) where
import Distribution.Client.Sandbox (withSandboxBinDirOnSearchPath)
import Test.Framework as TF (Test)
import Test.Framework.Providers.HUnit (testCase)
import Test.HUnit (Assertion, assertBool, assertEqual)
import System.FilePath (getSearchPath, (</>))
tests :: [TF.Test]
tests = [ testCase "sandboxBinDirOnSearchPath" sandboxBinDirOnSearchPathTest
, testCase "oldSearchPathRestored" oldSearchPathRestoreTest
]
sandboxBinDirOnSearchPathTest :: Assertion
sandboxBinDirOnSearchPathTest =
withSandboxBinDirOnSearchPath "foo" $ do
r <- getSearchPath
assertBool "'foo/bin' not on search path" $ ("foo" </> "bin") `elem` r
oldSearchPathRestoreTest :: Assertion
oldSearchPathRestoreTest = do
r <- getSearchPath
withSandboxBinDirOnSearchPath "foo" $ return ()
r' <- getSearchPath
assertEqual "Old search path wasn't restored" r r'
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