This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "snap".

The branch, master has been updated
       via  c249a4ee0faccc6bb621aec5bc1a27707fd1d690 (commit)
      from  7dda19bcf9f8df5325c3a6503f493ab1435000a5 (commit)


Summary of changes:
 .gitignore                    |    2 +-
 test/snap-testsuite.cabal     |    1 +
 test/suite/Snap/TestCommon.hs |   68 +++++++++++++++++++++++++++++++++++------
 3 files changed, 60 insertions(+), 11 deletions(-)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c249a4ee0faccc6bb621aec5bc1a27707fd1d690
Author: Gregory Collins <[email protected]>
Date:   Sat Jun 18 16:29:13 2011 -0400

    (Hopefully) fix cabal-dev issues with testsuite

diff --git a/.gitignore b/.gitignore
index f34d3ac..b718843 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,4 +12,4 @@ dist/
 **/.DS_Store
 docs/templates/out
 cabal-dev/
-test/cabal-dev
+test/test-cabal-dev
diff --git a/test/snap-testsuite.cabal b/test/snap-testsuite.cabal
index 7e6c0c2..4c07f2e 100644
--- a/test/snap-testsuite.cabal
+++ b/test/snap-testsuite.cabal
@@ -13,6 +13,7 @@ Executable testsuite
     bytestring == 0.9.*,
     directory,
     filepath,
+    Glob == 0.5.*,
     HUnit >= 1.2 && < 2,
     http-enumerator >= 0.6.5.3 && <0.7,
     process == 1.*,
diff --git a/test/suite/Snap/TestCommon.hs b/test/suite/Snap/TestCommon.hs
index 537c807..416c42f 100644
--- a/test/suite/Snap/TestCommon.hs
+++ b/test/suite/Snap/TestCommon.hs
@@ -1,13 +1,21 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+
 module Snap.TestCommon where
 
 import Control.Concurrent
 import Control.Exception
-import Control.Monad     (when)
+import Control.Monad (forM_, when)
+import Data.Maybe
+import Data.Monoid
+import Prelude hiding (catch)
 import System.Cmd
 import System.Directory
+import System.Environment
 import System.Exit
 import System.FilePath
-import System.Process
+import System.FilePath.Glob
+import System.Process hiding (cwd)
+
 
 testGeneratedProject :: String  -- ^ project name and directory
                      -> String  -- ^ arguments to @snap init@
@@ -25,13 +33,23 @@ testGeneratedProject projName snapInitArgs cabalInstallArgs 
httpPort
                           removeDirectoryRecursive projectPath) $ do
             makeWorkDirectory projectPath
             setCurrentDirectory projectPath
-            systemOrDie $ "snap init " ++ snapInitArgs
-            systemOrDie $ "cabal-dev " ++ cabalDevArgs
-                            ++ " add-source ../../../snap-core"
-            systemOrDie $ "cabal-dev " ++ cabalDevArgs
-                            ++ " add-source ../../../snap-server"
-            systemOrDie $ "cabal-dev " ++ cabalDevArgs
-                            ++ " add-source ../.."
+            snapExe <- findSnap
+            systemOrDie $ snapExe ++ " init " ++ snapInitArgs
+
+            snapCoreSrc   <- fromEnv "SNAP_CORE_SRC" "../../../snap-core"
+            snapServerSrc <- fromEnv "SNAP_SERVER_SRC" "../../../snap-server"
+            xmlhtmlSrc    <- fromEnv "XMLHTML_SRC" "../../../xmlhtml"
+            heistSrc      <- fromEnv "HEIST_SRC" "../../../heist"
+            let snapSrc   =  "../.."
+
+            forM_ [ "snap-core", "snap-server", "xmlhtml", "heist", "snap" ]
+                  (pkgCleanUp sandbox)
+
+            forM_ [ snapCoreSrc, snapServerSrc, xmlhtmlSrc, heistSrc
+                  , snapSrc] $ \s ->
+                systemOrDie $ "cabal-dev " ++ cabalDevArgs
+                                ++ " add-source " ++ s
+
             systemOrDie $ "cabal-dev install " ++ args
             let cmd = ("." </> "dist" </> "build" </> projName </> projName)
                       ++ " -p " ++ show httpPort
@@ -40,6 +58,10 @@ testGeneratedProject projName snapInitArgs cabalInstallArgs 
httpPort
             waitABit
             return (cwd, projectPath, pHandle)
 
+    fromEnv name def = do
+        r <- getEnv name `catch` \(_::SomeException) -> return ""
+        if r == "" then return def else return r
+
     cleanup (cwd, projectPath, pHandle) = do
         setCurrentDirectory cwd
         terminateProcess pHandle
@@ -48,10 +70,36 @@ testGeneratedProject projName snapInitArgs cabalInstallArgs 
httpPort
 
     waitABit = threadDelay $ 2*10^(6::Int)
 
-    cabalDevArgs = "-s ../cabal-dev" </> projName
+    sandbox = "../test-cabal-dev" </> projName
+
+    cabalDevArgs = "-s " ++ sandbox
+
+    pkgCleanUp d pkg = do
+        paths <- globDir1 (compile $ "packages*conf/" ++ pkg ++ "-*") d
+        forM_ paths
+              (\x -> (rm x `catch` \(_::SomeException) -> return ()))
+      where
+        rm x = do
+            putStrLn $ "removing " ++ x
+            removeFile x
 
     args = cabalDevArgs ++ " " ++ cabalInstallArgs 
 
+    gimmeIfExists p = do
+        b <- doesFileExist p
+        if b then return (Just p) else return Nothing
+
+
+    findSnap = do
+        home <- fromEnv "HOME" "."
+        p1 <- gimmeIfExists "../../dist/build/snap/snap"
+        p2 <- gimmeIfExists $ home </> ".cabal/bin/snap"
+        p3 <- findExecutable "snap"
+
+        return $ fromMaybe (error "couldn't find snap executable")
+                           (getFirst $ mconcat $ map First [p1,p2,p3])
+              
+
 systemOrDie :: String -> IO ()
 systemOrDie s = do
     putStrLn $ "Running \"" ++ s ++ "\""
-----------------------------------------------------------------------


hooks/post-receive
-- 
snap
_______________________________________________
Snap mailing list
[email protected]
https://mailman-mail5.webfaction.com/listinfo/snap

Reply via email to