lukko 0.1 → 0.1.1
raw patch · 9 files changed
+106/−30 lines, 9 filesdep +singleton-booldep +taggeddep +tasty-expected-failuresetup-changedPVP ok
version bump matches the API change (PVP)
Dependencies added: singleton-bool, tagged, tasty-expected-failure
API changes (from Hackage documentation)
+ Lukko: type FileLockingSupported = True
+ Lukko.FLock: type FileLockingSupported = True
+ Lukko.NoOp: type FileLockingSupported = 'False
+ Lukko.OFD: type FileLockingSupported = True
Files
- CHANGELOG.md +4/−0
- Setup.hs +33/−0
- lukko.cabal +20/−14
- src-flock/Lukko/FLock.hsc +6/−1
- src-ofd/Lukko/OFD.hsc +5/−0
- src-windows/Lukko/Windows.hsc +5/−0
- src/Lukko.hs +1/−0
- src/Lukko/NoOp.hs +4/−0
- test/Tests.hs +28/−15
+ CHANGELOG.md view
@@ -0,0 +1,4 @@+# 0.1.1++- Add `Setup.hs` to sdist+- Add type-level `FileLockingSupported`
+ Setup.hs view
@@ -0,0 +1,33 @@+{-# LANGUAGE CPP #-}+{-# OPTIONS_GHC -Wall #-}+module Main (main) where++#ifndef MIN_VERSION_cabal_doctest+#define MIN_VERSION_cabal_doctest(x,y,z) 0+#endif++#if MIN_VERSION_cabal_doctest(1,0,0)++import Distribution.Extra.Doctest ( defaultMainWithDoctests )+main :: IO ()+main = defaultMainWithDoctests "doctests"++#else++#ifdef MIN_VERSION_Cabal+-- If the macro is defined, we have new cabal-install,+-- but for some reason we don't have cabal-doctest in package-db+--+-- Probably we are running cabal sdist, when otherwise using new-build+-- workflow+#warning You are configuring this package without cabal-doctest installed. \+ The doctests test-suite will not work as a result. \+ To fix this, install cabal-doctest before configuring.+#endif++import Distribution.Simple++main :: IO ()+main = defaultMain++#endif
lukko.cabal view
@@ -1,8 +1,8 @@-cabal-version: 2.2-name: lukko-version: 0.1-synopsis: File locking-category: System, Concurrency+cabal-version: 2.2+name: lukko+version: 0.1.1+synopsis: File locking+category: System, Concurrency description: This package provides access to platform dependent file locking APIs: .@@ -39,10 +39,11 @@ "Lukko.FLock" is available on not (Windows or Solaris or AIX). "Lukko.NoOp" is always available. -maintainer: Oleg Grenrus <oleg.grenrus@iki.fi>-license: GPL-2.0-or-later AND BSD-3-Clause-license-files: LICENSE LICENSE.GPLv2 LICENSE.GPLv3-build-type: Simple+maintainer: Oleg Grenrus <oleg.grenrus@iki.fi>+license: GPL-2.0-or-later AND BSD-3-Clause+license-files: LICENSE LICENSE.GPLv2 LICENSE.GPLv3+build-type: Simple+extra-source-files: CHANGELOG.md tested-with: GHC ==7.6.3 || ==7.8.4@@ -113,13 +114,18 @@ main-is: Tests.hs ghc-options: -threaded build-depends:- , async ^>=2.2.2+ , async ^>=2.2.2 , base- , filepath ^>=1.3.0.0 || ^>=1.4.0.0+ , filepath ^>=1.3.0.0 || ^>=1.4.0.0 , lukko- , tasty ^>=1.2.3- , tasty-hunit ^>=0.10.0.2- , temporary ^>=1.3+ , singleton-bool ^>=0.1.5+ , tasty ^>=1.2.3+ , tasty-expected-failure ^>=0.11.1.2+ , tasty-hunit ^>=0.10.0.2+ , temporary ^>=1.3++ if !impl(ghc >=7.8)+ build-depends: tagged ^>=0.8.5 if os(windows) cpp-options: -DHAS_WINDOWS_LOCK
src-flock/Lukko/FLock.hsc view
@@ -1,11 +1,13 @@-{-# LANGUAGE InterruptibleFFI #-} {-# LANGUAGE CPP #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE InterruptibleFFI #-} {-# LANGUAGE Trustworthy #-} -- | File locking via POSIX @flock@. module Lukko.FLock ( -- * Types FileLockingNotSupported(..), fileLockingSupported,+ FileLockingSupported, FileLockingMethod (..), fileLockingMethod, LockMode(..),@@ -44,6 +46,9 @@ -- | A constants specifying whether file locking is supported. fileLockingSupported :: Bool fileLockingSupported = True++-- | A type level 'fileLockingSupported'.+type FileLockingSupported = True -- | A constant specifying this method fileLockingMethod :: FileLockingMethod
src-ofd/Lukko/OFD.hsc view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE DataKinds #-} {-# LANGUAGE InterruptibleFFI #-} {-# LANGUAGE Trustworthy #-} -- | Linux open file descriptor locking.@@ -14,6 +15,7 @@ -- * Types FileLockingNotSupported(..), fileLockingSupported,+ FileLockingSupported, FileLockingMethod (..), fileLockingMethod, LockMode(..),@@ -57,6 +59,9 @@ -- | A constants specifying whether file locking is supported. fileLockingSupported :: Bool fileLockingSupported = True++-- | A type level 'fileLockingSupported'.+type FileLockingSupported = True -- | A constant specifying this method fileLockingMethod :: FileLockingMethod
src-windows/Lukko/Windows.hsc view
@@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE DataKinds #-} {-# LANGUAGE InterruptibleFFI #-} {-# LANGUAGE Trustworthy #-} -- | File locking for Windows.@@ -6,6 +7,7 @@ -- * Types FileLockingNotSupported(..), fileLockingSupported,+ FileLockingSupported, FileLockingMethod (..), fileLockingMethod, LockMode(..),@@ -55,6 +57,9 @@ -- | A constants specifying whether file locking is supported. fileLockingSupported :: Bool fileLockingSupported = True++-- | A type level 'fileLockingSupported'.+type FileLockingSupported = True -- | A constant specifying this method fileLockingMethod :: FileLockingMethod
src/Lukko.hs view
@@ -4,6 +4,7 @@ module Lukko ( FileLockingNotSupported(..), Impl.fileLockingSupported,+ Impl.FileLockingSupported, FileLockingMethod (..), Impl.fileLockingMethod, LockMode(..),
src/Lukko/NoOp.hs view
@@ -7,6 +7,7 @@ -- * Types FileLockingNotSupported(..), fileLockingSupported,+ FileLockingSupported, FileLockingMethod (..), fileLockingMethod, LockMode(..),@@ -32,6 +33,9 @@ -- | A constants specifying whether file locking is supported. fileLockingSupported :: Bool fileLockingSupported = False++-- | A type level 'fileLockingSupported'.+type FileLockingSupported = 'False -- | A constant specifying this method fileLockingMethod :: FileLockingMethod
test/Tests.hs view
@@ -1,19 +1,25 @@-{-# LANGUAGE CPP #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE ScopedTypeVariables #-} module Main (main) where -import Control.Concurrent (threadDelay)-import Control.Concurrent.Async (forConcurrently_)-import Control.Exception (bracket)+import Control.Concurrent (threadDelay)+import Control.Concurrent.Async (forConcurrently_)+import Control.Exception (bracket) import Data.IORef-import System.FilePath ((</>))+import Data.Proxy (Proxy (..))+import Data.Singletons.Bool (reflectBool, SBoolI)+import System.FilePath ((</>)) import System.IO (Handle, IOMode (ReadWriteMode), hClose, openFile)-import System.IO.Temp (withSystemTempDirectory)-import Test.Tasty (TestTree, defaultMain, testGroup)-import Test.Tasty.HUnit (testCase, (@=?))+import System.IO.Temp (withSystemTempDirectory)+import Test.Tasty (TestTree, defaultMain, testGroup)+import Test.Tasty.ExpectedFailure (ignoreTest)+import Test.Tasty.HUnit (testCase, (@=?)) import Lukko +import qualified Lukko.NoOp as NoOp+ #ifdef HAS_OFD_LOCKING import qualified Lukko.OFD as OFD #endif@@ -24,22 +30,25 @@ main :: IO () main = defaultMain $ testGroup "lukko" $- [ testGroup "Lukko default" $ testSuite fdLock fdUnlock- | fileLockingSupported+ [ testGroup "Lukko default" $ testSuite (Proxy :: Proxy FileLockingSupported) fileLockingSupported fdLock fdUnlock+ , testGroup "Lukko.NoOp" $ testSuite (Proxy :: Proxy NoOp.FileLockingSupported) NoOp.fileLockingSupported NoOp.fdLock NoOp.fdUnlock ] #ifdef HAS_OFD_LOCKING- ++ [ testGroup "Lukko.OFD" $ testSuite OFD.fdLock OFD.fdUnlock ]+ ++ [ testGroup "Lukko.OFD" $ testSuite (Proxy :: Proxy OFD.FileLockingSupported) OFD.fileLockingSupported OFD.fdLock OFD.fdUnlock ] #endif #ifdef HAS_FLOCK- ++ [ testGroup "Lukko.FLock" $ testSuite FLock.fdLock FLock.fdUnlock ]+ ++ [ testGroup "Lukko.FLock" $ testSuite (Proxy :: Proxy FLock.FileLockingSupported) FLock.fileLockingSupported FLock.fdLock FLock.fdUnlock ] #endif testSuite- :: (FD -> LockMode -> IO ())+ :: forall supported. SBoolI supported+ => Proxy supported+ -> Bool+ -> (FD -> LockMode -> IO ()) -> (FD -> IO ()) -> [TestTree]-testSuite implLock implUnlock =- [ testCase "concurrent threads" $ do+testSuite suppP supp implLock implUnlock =+ [ modify $ testCase "concurrent threads" $ do let n = 10 :: Int ref <- newIORef 0 @@ -53,8 +62,12 @@ val <- readIORef ref val @=? n+ , testCase "FileLockingSupported and fileLockingSupported agree" $+ reflectBool suppP @=? supp ] where+ modify | supp = id+ | otherwise = ignoreTest withLock = genWithLock implLock implUnlock genWithLock