Hello community,

here is the log from the commit of package ghc-filelock for openSUSE:Factory 
checked in at 2018-05-30 12:07:35
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ghc-filelock (Old)
 and      /work/SRC/openSUSE:Factory/.ghc-filelock.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ghc-filelock"

Wed May 30 12:07:35 2018 rev:3 rq:607798 version:0.1.1.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/ghc-filelock/ghc-filelock.changes        
2016-07-21 08:09:15.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.ghc-filelock.new/ghc-filelock.changes   
2018-05-30 12:25:41.629562416 +0200
@@ -1,0 +2,6 @@
+Mon May 14 17:02:11 UTC 2018 - [email protected]
+
+- Update filelock to version 0.1.1.2.
+  Upstream does not provide a changelog.
+
+-------------------------------------------------------------------

Old:
----
  filelock-0.1.0.1.tar.gz

New:
----
  filelock-0.1.1.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ghc-filelock.spec ++++++
--- /var/tmp/diff_new_pack.6oLgSx/_old  2018-05-30 12:25:42.321539484 +0200
+++ /var/tmp/diff_new_pack.6oLgSx/_new  2018-05-30 12:25:42.321539484 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package ghc-filelock
 #
-# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,20 +17,22 @@
 
 
 %global pkg_name filelock
+%bcond_with tests
 Name:           ghc-%{pkg_name}
-Version:        0.1.0.1
+Version:        0.1.1.2
 Release:        0
 Summary:        Portable interface to file locking (flock / LockFileEx)
 License:        CC0-1.0
-Group:          System/Libraries
-Url:            https://hackage.haskell.org/package/%{pkg_name}
+Group:          Development/Libraries/Haskell
+URL:            https://hackage.haskell.org/package/%{pkg_name}
 Source0:        
https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz
 BuildRequires:  ghc-Cabal-devel
 BuildRequires:  ghc-rpm-macros
-# Begin cabal-rpm deps:
 BuildRequires:  ghc-unix-devel
-BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-# End cabal-rpm deps
+%if %{with tests}
+BuildRequires:  ghc-async-devel
+BuildRequires:  ghc-process-devel
+%endif
 
 %description
 This package provides an interface to Windows and Unix file locking
@@ -38,7 +40,7 @@
 
 %package devel
 Summary:        Haskell %{pkg_name} library development files
-Group:          Development/Libraries/Other
+Group:          Development/Libraries/Haskell
 Requires:       %{name} = %{version}-%{release}
 Requires:       ghc-compiler = %{ghc_version}
 Requires(post): ghc-compiler = %{ghc_version}
@@ -50,14 +52,14 @@
 %prep
 %setup -q -n %{pkg_name}-%{version}
 
-
 %build
 %ghc_lib_build
 
-
 %install
 %ghc_lib_install
 
+%check
+%cabal_test
 
 %post devel
 %ghc_pkg_recache
@@ -66,10 +68,8 @@
 %ghc_pkg_recache
 
 %files -f %{name}.files
-%defattr(-,root,root,-)
-%doc LICENSE
+%license LICENSE
 
 %files devel -f %{name}-devel.files
-%defattr(-,root,root,-)
 
 %changelog

++++++ filelock-0.1.0.1.tar.gz -> filelock-0.1.1.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/filelock-0.1.0.1/System/FileLock/Internal/Flock.hsc 
new/filelock-0.1.1.2/System/FileLock/Internal/Flock.hsc
--- old/filelock-0.1.0.1/System/FileLock/Internal/Flock.hsc     2014-06-17 
11:01:53.000000000 +0200
+++ new/filelock-0.1.1.2/System/FileLock/Internal/Flock.hsc     2017-08-04 
13:03:57.000000000 +0200
@@ -14,6 +14,7 @@
 import System.Posix.Files
 import System.Posix.IO (openFd, closeFd, defaultFileFlags, OpenMode(..))
 import System.Posix.Types
+import Prelude
 
 type Lock = Fd
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/filelock-0.1.0.1/System/FileLock.hs 
new/filelock-0.1.1.2/System/FileLock.hs
--- old/filelock-0.1.0.1/System/FileLock.hs     2014-06-17 11:01:53.000000000 
+0200
+++ new/filelock-0.1.1.2/System/FileLock.hs     2017-08-04 13:07:04.000000000 
+0200
@@ -27,6 +27,7 @@
   , tryLockFile
   , unlockFile
   , withFileLock
+  , withTryFileLock
   ) where
 
 import Control.Applicative
@@ -35,6 +36,7 @@
 import Data.IORef
 import Data.Traversable (traverse)
 import Data.Typeable
+import Prelude
 
 #ifdef USE_FLOCK
 import qualified System.FileLock.Internal.Flock as I
@@ -77,6 +79,10 @@
   wasAlive <- atomicModifyIORef ref $ \old -> (False, old)
   when wasAlive $ I.unlock l
 
--- | Perform some action with a lock held.
+-- | Perform some action with a lock held. Blocks until the lock is available.
 withFileLock :: FilePath -> SharedExclusive -> (FileLock -> IO a) -> IO a
 withFileLock path mode = E.bracket (lockFile path mode) unlockFile
+
+-- | Perform sme action with a lock held. Non-blocking.
+withTryFileLock :: FilePath -> SharedExclusive -> (FileLock -> IO a) -> IO 
(Maybe a)
+withTryFileLock path mode f = E.bracket (tryLockFile path mode) (traverse 
unlockFile) (traverse f)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/filelock-0.1.0.1/filelock.cabal 
new/filelock-0.1.1.2/filelock.cabal
--- old/filelock-0.1.0.1/filelock.cabal 2014-06-17 11:01:53.000000000 +0200
+++ new/filelock-0.1.1.2/filelock.cabal 2017-08-04 18:15:50.000000000 +0200
@@ -2,7 +2,7 @@
 -- documentation, see http://haskell.org/cabal/users-guide/
 
 name:                filelock
-version:             0.1.0.1
+version:             0.1.1.2
 synopsis:            Portable interface to file locking (flock / LockFileEx)
 description:         This package provides an interface to Windows and Unix
                      file locking functionalities.
@@ -10,12 +10,13 @@
 license:             PublicDomain
 license-file:        LICENSE
 author:              Takano Akio
-maintainer:          [email protected]
+maintainer:          [email protected]
 -- copyright:           
 category:            System
 build-type:          Simple
 -- extra-source-files:  
 cabal-version:       >=1.10
+extra-source-files:  tests/lock.log.expected
 
 library
   exposed-modules:     System.FileLock
@@ -33,3 +34,11 @@
   else
     cpp-options:      -DUSE_FLOCK
     build-depends:    unix
+
+test-suite test
+  type:               exitcode-stdio-1.0
+  hs-source-dirs:     tests
+  main-is:            test.hs
+  build-depends:      filelock, process, async, base
+  ghc-options:        -threaded
+  default-language:   Haskell2010
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/filelock-0.1.0.1/tests/lock.log.expected 
new/filelock-0.1.1.2/tests/lock.log.expected
--- old/filelock-0.1.0.1/tests/lock.log.expected        1970-01-01 
01:00:00.000000000 +0100
+++ new/filelock-0.1.1.2/tests/lock.log.expected        2017-08-04 
13:03:57.000000000 +0200
@@ -0,0 +1,12 @@
+took shared lock
+took shared lock
+lock not available
+took shared lock
+released shared lock
+released shared lock
+released shared lock
+took exclusive lock
+released exclusive lock
+took shared lock
+released shared lock
+lock was available
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/filelock-0.1.0.1/tests/test.hs 
new/filelock-0.1.1.2/tests/test.hs
--- old/filelock-0.1.0.1/tests/test.hs  1970-01-01 01:00:00.000000000 +0100
+++ new/filelock-0.1.1.2/tests/test.hs  2017-08-04 13:03:57.000000000 +0200
@@ -0,0 +1,87 @@
+{-# LANGUAGE ViewPatterns #-}
+
+import Control.Monad
+import Control.Concurrent
+import Control.Concurrent.Async
+import System.Environment
+import System.Exit
+import System.Process
+import System.IO
+
+import System.FileLock
+
+main :: IO ()
+main = do
+  hSetBuffering stdout LineBuffering
+  args <- getArgs
+  case args of
+    ["shared", read -> duration]
+      -> holdLock "shared" Shared duration
+    ["exclusive", read -> duration]
+      -> holdLock "exclusive" Exclusive duration
+    ["try"]
+      -> tryTakingLock
+    ["tryshared", read -> duration]
+      -> tryHoldLock "shared" Shared duration
+    ["tryexclusive", read -> duration]
+      -> tryHoldLock "exclusive" Exclusive duration
+    _ -> do
+      withFile "lock.log" WriteMode $ \h ->
+        void $ mapConcurrently id
+          [ callSelf h ["shared", "300"]
+          , callSelf h ["shared", "200"]
+          , msleep 10 >> callSelf h ["exclusive", "500"]
+          , msleep 20 >> callSelf h ["try"]
+          , msleep 50 >> callSelf h ["shared", "500"]
+          , msleep 700 >> callSelf h ["shared", "10"]
+          , msleep 1500 >> callSelf h ["try"]
+          ]
+      msleep 2000
+      log <- readFile "lock.log"
+      expected <- readFile "tests/lock.log.expected"
+      when (log /= expected) $ do
+        putStrLn "log mismatch!"
+        exitFailure
+
+callSelf :: Handle -> [String] -> IO ()
+callSelf out args = do
+  self <- getExecutablePath
+  (_hin, _hout, _herr, ph) <- createProcess_ "callSelf"
+    (proc self args) { std_out = UseHandle out }
+  ExitSuccess <- waitForProcess ph
+  return ()
+
+msleep :: Int -> IO ()
+msleep = threadDelay . (*1000)
+
+holdLock :: String -> SharedExclusive -> Int -> IO ()
+holdLock ty sex duration = do
+  withFileLock lockfile sex $ \_ -> do
+    putStrLn $ "took " ++ desc
+    msleep duration
+  putStrLn $ "released " ++ desc
+  where
+    desc = ty ++ " lock"
+
+tryTakingLock :: IO ()
+tryTakingLock = do
+  ml <- tryLockFile lockfile Exclusive
+  case ml of
+    Nothing -> putStrLn "lock not available"
+    Just l -> do
+      putStrLn "lock was available"
+      unlockFile l
+
+tryHoldLock :: String -> SharedExclusive -> Int -> IO ()
+tryHoldLock ty sex duration = do
+  res <- withTryFileLock lockfile sex $ \_ -> do
+    putStrLn $ "took " ++ desc
+    msleep duration
+  case res of
+    Nothing -> putStrLn "lock not available"
+    Just _  -> putStrLn $ "released " ++ desc
+  where
+    desc = ty ++ " lock"
+
+lockfile :: String
+lockfile = "lock"


Reply via email to