shake-dhall 0.1.1.1 → 0.1.1.2
raw patch · 4 files changed
+62/−6 lines, 4 filesdep +directorydep +shake-dhalldep +tastydep ~basePVP ok
version bump matches the API change (PVP)
Dependencies added: directory, shake-dhall, tasty, tasty-hunit
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- CHANGELOG.md +6/−0
- shake-dhall.cabal +29/−2
- src/Dhall/Dep.hs +12/−4
- test/Spec.hs +15/−0
CHANGELOG.md view
@@ -1,5 +1,11 @@ # shake-dhall +## 0.1.1.2++ * Add test suite+ * Fix bug uncovered by test suite+ * Canonicalize paths+ ## 0.1.1.1 * Documentation typos
shake-dhall.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: shake-dhall-version: 0.1.1.1+version: 0.1.1.2 license: BSD3 license-file: LICENSE copyright: Copyright: (c) 2020 Vanessa McHale@@ -32,7 +32,34 @@ text -any, containers >=0.6, shake -any,- filepath -any+ filepath -any,+ directory -any++ if impl(ghc >=8.0)+ ghc-options:+ -Wincomplete-uni-patterns -Wincomplete-record-updates+ -Wredundant-constraints -Widentities++ if impl(ghc >=8.4)+ ghc-options: -Wmissing-export-lists++ if impl(ghc >=8.2)+ ghc-options: -Wcpp-undef++ if impl(ghc >=8.10)+ ghc-options: -Wunused-packages++test-suite shake-dhall-test+ type: exitcode-stdio-1.0+ main-is: Spec.hs+ hs-source-dirs: test+ default-language: Haskell2010+ ghc-options: -threaded -rtsopts "-with-rtsopts=-N -K1K" -Wall+ build-depends:+ base -any,+ shake-dhall -any,+ tasty -any,+ tasty-hunit -any if impl(ghc >=8.0) ghc-options:
src/Dhall/Dep.hs view
@@ -3,6 +3,7 @@ ) where import Control.Exception (throw)+import Control.Monad ((<=<)) import Data.Containers.ListUtils (nubOrd) import Data.Foldable (toList) import Data.Maybe (catMaybes)@@ -11,6 +12,8 @@ importHashed, importType) import Dhall.Import (localToPath) import Dhall.Parser (exprFromText)+import System.Directory (canonicalizePath,+ makeRelativeToCurrentDirectory) import System.FilePath (isAbsolute, takeDirectory, (</>)) -- | Given a path, the file paths it depends on@@ -21,15 +24,20 @@ fileMod fp' = if isAbsolute fp' then fp' else fileDir </> fp' tree = either throw id (exprFromText fp contents) imports = toList tree- catMaybes <$> traverse (fmap (fileMod <$>) . fromImport) imports+ traverse canonicalizeRelative =<<+ catMaybes <$> traverse (fmap (fileMod <$>) . fromImport) imports +canonicalizeRelative :: FilePath -> IO FilePath+canonicalizeRelative = makeRelativeToCurrentDirectory <=< canonicalizePath+ -- | Get all transitive dependencies getAllFileDeps :: FilePath -> IO [FilePath] getAllFileDeps fp = do deps <- getFileDeps fp- level <- traverse getFileDeps deps- let next = nubOrd (mconcat (deps : level))- pure $ if null level then deps else next+ level <- traverse getAllFileDeps deps+ pure $ if null level+ then deps+ else nubOrd (concat (deps : level)) fromImport :: Import -> IO (Maybe FilePath) fromImport = fromImportType . importType . importHashed
+ test/Spec.hs view
@@ -0,0 +1,15 @@+module Main ( main ) where++import Dhall.Dep+import Test.Tasty+import Test.Tasty.HUnit++main :: IO ()+main = defaultMain $+ testGroup "Dhall.Deps"+ [ unitTest ]++unitTest :: TestTree+unitTest = testCase "test/data/expr2.dhall" $ do+ res <- getAllFileDeps "test/data/expr2.dhall"+ res @?= ["test/data/expr1.dhall", "test/data/expr0.dhall", "test/data/subdir/lib.dhall"]