[commit: packages/Cabal] ghc-head: Use pre-order traversal when simplifying CondTree's. (cf0cf07)

git at git.haskell.org git at git.haskell.org
Mon Aug 26 23:24:46 CEST 2013


Repository : ssh://git@git.haskell.org/Cabal

On branch  : ghc-head
Link       : http://git.haskell.org/?p=packages/Cabal.git;a=commit;h=cf0cf077ab6836584fc3bf51d867e63824811d4d

>---------------------------------------------------------------

commit cf0cf077ab6836584fc3bf51d867e63824811d4d
Author: Oleksandr Manzyuk <manzyuk at gmail.com>
Date:   Sat May 4 11:55:30 2013 +0300

    Use pre-order traversal when simplifying CondTree's.
    
    Fixes #676.


>---------------------------------------------------------------

cf0cf077ab6836584fc3bf51d867e63824811d4d
 Cabal/Cabal.cabal                                  |    5 ++++-
 .../PackageDescription/Configuration.hs            |    2 +-
 Cabal/tests/PackageTests.hs                        |    3 +++
 .../SameDepsAllRound => OrderFlags}/Check.hs       |   11 ++++++-----
 Cabal/tests/PackageTests/OrderFlags/Foo.hs         |    8 ++++++++
 Cabal/tests/PackageTests/OrderFlags/my.cabal       |   20 ++++++++++++++++++++
 6 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/Cabal/Cabal.cabal b/Cabal/Cabal.cabal
index fddae9a..0ce9cfb 100644
--- a/Cabal/Cabal.cabal
+++ b/Cabal/Cabal.cabal
@@ -83,6 +83,8 @@ extra-source-files:
   tests/PackageTests/CMain/foo.c
   tests/PackageTests/CMain/my.cabal
   tests/PackageTests/EmptyLib/empty/empty.cabal
+  tests/PackageTests/OrderFlags/Foo.hs
+  tests/PackageTests/OrderFlags/my.cabal
   tests/PackageTests/PathsModule/Executable/Main.hs
   tests/PackageTests/PathsModule/Executable/my.cabal
   tests/PackageTests/PathsModule/Library/my.cabal
@@ -248,8 +250,9 @@ test-suite package-tests
     PackageTests.BuildDeps.TargetSpecificDeps2.Check
     PackageTests.BuildDeps.TargetSpecificDeps3.Check
     PackageTests.BuildTestSuiteDetailedV09.Check
-    PackageTests.EmptyLib.Check
     PackageTests.CMain.Check
+    PackageTests.EmptyLib.Check
+    PackageTests.OrderFlags.Check
     PackageTests.PackageTester
     PackageTests.PathsModule.Executable.Check
     PackageTests.PathsModule.Library.Check
diff --git a/Cabal/Distribution/PackageDescription/Configuration.hs b/Cabal/Distribution/PackageDescription/Configuration.hs
index 1706168..7ee6273 100644
--- a/Cabal/Distribution/PackageDescription/Configuration.hs
+++ b/Cabal/Distribution/PackageDescription/Configuration.hs
@@ -326,7 +326,7 @@ simplifyCondTree :: (Monoid a, Monoid d) =>
                  -> CondTree v d a
                  -> (d, a)
 simplifyCondTree env (CondNode a d ifs) =
-    foldr mappend (d, a) $ catMaybes $ map simplifyIf ifs
+    mconcat $ (d, a) : catMaybes (map simplifyIf ifs)
   where
     simplifyIf (cnd, t, me) =
         case simplifyCondition cnd env of
diff --git a/Cabal/tests/PackageTests.hs b/Cabal/tests/PackageTests.hs
index 7cec438..e9fd48d 100644
--- a/Cabal/tests/PackageTests.hs
+++ b/Cabal/tests/PackageTests.hs
@@ -40,6 +40,7 @@ import PackageTests.EmptyLib.Check
 import PackageTests.TestOptions.Check
 import PackageTests.TestStanza.Check
 import PackageTests.TestSuiteExeV10.Check
+import PackageTests.OrderFlags.Check
 
 hunit :: TestName -> HUnit.Test -> Test
 hunit name test = testGroup name $ hUnitTestToTests test
@@ -81,6 +82,8 @@ tests version inplaceSpec =
       PackageTests.EmptyLib.Check.emptyLib
     , hunit "BuildTestSuiteDetailedV09"
       $ PackageTests.BuildTestSuiteDetailedV09.Check.suite inplaceSpec
+    , hunit "OrderFlags"
+      PackageTests.OrderFlags.Check.suite
     ] ++
     -- These tests are only required to pass on cabal version >= 1.7
     (if version >= Version [1, 7] []
diff --git a/Cabal/tests/PackageTests/BuildDeps/SameDepsAllRound/Check.hs b/Cabal/tests/PackageTests/OrderFlags/Check.hs
similarity index 53%
copy from Cabal/tests/PackageTests/BuildDeps/SameDepsAllRound/Check.hs
copy to Cabal/tests/PackageTests/OrderFlags/Check.hs
index 2241272..7a324dd 100644
--- a/Cabal/tests/PackageTests/BuildDeps/SameDepsAllRound/Check.hs
+++ b/Cabal/tests/PackageTests/OrderFlags/Check.hs
@@ -1,17 +1,18 @@
-module PackageTests.BuildDeps.SameDepsAllRound.Check where
+module PackageTests.OrderFlags.Check where
 
 import Test.HUnit
 import PackageTests.PackageTester
 import System.FilePath
-import qualified Control.Exception as E
+import Control.Exception
+import Prelude hiding (catch)
 
 
 suite :: Test
 suite = TestCase $ do
-    let spec = PackageSpec ("PackageTests" </> "BuildDeps" </> "SameDepsAllRound") []
+    let spec = PackageSpec ("PackageTests" </> "OrderFlags") []
     result <- cabal_build spec
     do
         assertEqual "cabal build should succeed - see test-log.txt" True (successful result)
-      `E.catch` \exc -> do
+      `catch` \exc -> do
         putStrLn $ "Cabal result was "++show result
-        E.throwIO (exc :: E.SomeException)
+        throwIO (exc :: SomeException)
diff --git a/Cabal/tests/PackageTests/OrderFlags/Foo.hs b/Cabal/tests/PackageTests/OrderFlags/Foo.hs
new file mode 100644
index 0000000..937afe7
--- /dev/null
+++ b/Cabal/tests/PackageTests/OrderFlags/Foo.hs
@@ -0,0 +1,8 @@
+module Foo where
+
+x :: IO Int
+x = return 5
+
+f :: IO Int
+f = do x
+       return 3
diff --git a/Cabal/tests/PackageTests/OrderFlags/my.cabal b/Cabal/tests/PackageTests/OrderFlags/my.cabal
new file mode 100644
index 0000000..e81a6d8
--- /dev/null
+++ b/Cabal/tests/PackageTests/OrderFlags/my.cabal
@@ -0,0 +1,20 @@
+name: OrderFlags
+version: 0.1
+license: BSD3
+author: Oleksandr Manzyuk
+stability: stable
+category: PackageTests
+build-type: Simple
+cabal-version: >=1.9.2
+
+description:
+    Check that Cabal correctly orders flags that are passed to GHC.
+
+library
+    exposed-modules: Foo
+    build-depends: base
+
+    ghc-options: -Wall -Werror
+
+    if impl(ghc >= 6.12.1)
+        ghc-options: -fno-warn-unused-do-bind





More information about the ghc-commits mailing list