mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
parent
3b1d8dfe33
commit
f18c393866
@ -345,4 +345,6 @@ breakAt72Bytes s =
|
||||
makeRelative' :: NormalizedFilePath -> NormalizedFilePath -> NormalizedFilePath
|
||||
makeRelative' a b =
|
||||
toNormalizedFilePath $
|
||||
makeRelative (fromNormalizedFilePath a) (fromNormalizedFilePath b)
|
||||
-- Note that NormalizedFilePath only takes care of normalizing slashes.
|
||||
-- Here we also want to normalise things like ./a to a
|
||||
makeRelative (normalise $ fromNormalizedFilePath a) (normalise $ fromNormalizedFilePath b)
|
||||
|
@ -87,6 +87,16 @@ tests damlDir tmpDir = testGroup "Integration tests"
|
||||
throwError :: MonadFail m => T.Text -> T.Text -> m ()
|
||||
throwError msg e = fail (T.unpack $ msg <> " " <> e)
|
||||
|
||||
-- | Check that the given file exists in the dar in the given directory.
|
||||
--
|
||||
-- This function automatically strips away the root directory e.g.
|
||||
-- foobar-0.0.1-b2d63d90f3cb73434ae005ee1c9762166bb84563ac9d108a606c8384803f09f2
|
||||
-- so to check that foobar-0.0.1-b2d63d90f3cb73434ae005ee1c9762166bb84563ac9d108a606c8384803f09f2/A/B.daml
|
||||
-- exists use checkDarFile darFiles "A" "B.daml"
|
||||
checkDarFile :: [FilePath] -> FilePath -> FilePath -> IO ()
|
||||
checkDarFile darFiles dir file = assertBool (dir </> file <> " not in " <> show darFiles) $
|
||||
any (\f -> normalise (dropDirectory1 f) == normalise (dir </> file)) darFiles
|
||||
|
||||
-- | These tests check that it is possible to invoke (a subset) of damlc
|
||||
-- commands outside of the assistant.
|
||||
noassistantTests :: FilePath -> TestTree
|
||||
@ -187,6 +197,47 @@ packagingTests tmpDir = testGroup "packaging"
|
||||
]
|
||||
withCurrentDirectory projectB $ callCommandQuiet "daml build"
|
||||
assertBool "b.dar was not created." =<< doesFileExist bDar
|
||||
, testCaseSteps "Dependency on a package with source: A.daml" $ \step -> do
|
||||
let projectA = tmpDir </> "a"
|
||||
let projectB = tmpDir </> "b"
|
||||
let aDar = projectA </> ".daml" </> "dist" </> "a-1.0.dar"
|
||||
let bDar = projectB </> ".daml" </> "dist" </> "b-1.0.dar"
|
||||
step "Creating project a..."
|
||||
createDirectoryIfMissing True projectA
|
||||
writeFileUTF8 (projectA </> "A.daml") $ unlines
|
||||
[ "daml 1.2"
|
||||
, "module A () where"
|
||||
]
|
||||
writeFileUTF8 (projectA </> "daml.yaml") $ unlines
|
||||
[ "sdk-version: " <> sdkVersion
|
||||
, "name: a"
|
||||
, "version: \"1.0\""
|
||||
, "source: A.daml"
|
||||
, "dependencies:"
|
||||
, " - daml-prim"
|
||||
, " - daml-stdlib"
|
||||
]
|
||||
withCurrentDirectory projectA $ callCommandQuiet "daml build"
|
||||
assertBool "a-1.0.dar was not created." =<< doesFileExist aDar
|
||||
step "Creating project b..."
|
||||
createDirectoryIfMissing True projectB
|
||||
writeFileUTF8 (projectB </> "B.daml") $ unlines
|
||||
[ "daml 1.2"
|
||||
, "module B where"
|
||||
, "import A ()"
|
||||
]
|
||||
writeFileUTF8 (projectB </> "daml.yaml") $ unlines
|
||||
[ "sdk-version: " <> sdkVersion
|
||||
, "version: \"1.0\""
|
||||
, "name: b"
|
||||
, "source: B.daml"
|
||||
, "dependencies:"
|
||||
, " - daml-prim"
|
||||
, " - daml-stdlib"
|
||||
, " - " <> aDar
|
||||
]
|
||||
withCurrentDirectory projectB $ callCommandQuiet "daml build"
|
||||
assertBool "b.dar was not created." =<< doesFileExist bDar
|
||||
, testCase "Build package with SDK dependency" $ do
|
||||
let project = tmpDir </> "project"
|
||||
let dar = project </> ".daml" </> "dist" </> "project-1.0.dar"
|
||||
@ -242,7 +293,7 @@ packagingTests tmpDir = testGroup "packaging"
|
||||
writeFileUTF8 (projDir </> "A.daml") $ unlines
|
||||
[ "daml 1.2"
|
||||
, "module A where"
|
||||
, "import B"
|
||||
, "import B ()"
|
||||
]
|
||||
writeFileUTF8 (projDir </> "B.daml") $ unlines
|
||||
[ "daml 1.2"
|
||||
@ -259,12 +310,7 @@ packagingTests tmpDir = testGroup "packaging"
|
||||
let dar = projDir </> ".daml/dist/proj-0.1.0.dar"
|
||||
assertBool "proj-0.1.0.dar was not created." =<< doesFileExist dar
|
||||
darFiles <- Zip.filesInArchive . Zip.toArchive <$> BSL.readFile dar
|
||||
assertBool "A.daml missing" (any (\f -> takeFileName f == "A.daml") darFiles)
|
||||
assertBool "A.hi missing" (any (\f -> takeFileName f == "A.hi") darFiles)
|
||||
assertBool "A.hie missing" (any (\f -> takeFileName f == "A.hie") darFiles)
|
||||
assertBool "B.daml missing" (any (\f -> takeFileName f == "B.daml") darFiles)
|
||||
assertBool "B.hi missing" (any (\f -> takeFileName f == "B.hi") darFiles)
|
||||
assertBool "B.hie missing" (any (\f -> takeFileName f == "B.hie") darFiles)
|
||||
forM_ ["A.daml", "A.hi", "A.hie", "B.daml", "B.hi", "B.hie"] $ checkDarFile darFiles "."
|
||||
|
||||
, testCase "Root source file in subdir" $ withTempDir $ \projDir -> do
|
||||
-- Test that the daml source files get included properly if "source" points to a file
|
||||
@ -291,15 +337,12 @@ packagingTests tmpDir = testGroup "packaging"
|
||||
let dar = projDir </> ".daml/dist/proj-0.1.0.dar"
|
||||
assertBool "proj-0.1.0.dar was not created." =<< doesFileExist dar
|
||||
darFiles <- Zip.filesInArchive . Zip.toArchive <$> BSL.readFile dar
|
||||
let checkSource dir file =
|
||||
assertBool (dir </> file <> " missing") $
|
||||
any (\f -> normalise (dropDirectory1 f) == dir </> file) darFiles
|
||||
checkSource "A" "B.daml"
|
||||
checkSource "A" "B.hi"
|
||||
checkSource "A" "B.hie"
|
||||
checkSource "B" "C.daml"
|
||||
checkSource "B" "C.hi"
|
||||
checkSource "B" "C.hie"
|
||||
checkDarFile darFiles "A" "B.daml"
|
||||
checkDarFile darFiles "A" "B.hi"
|
||||
checkDarFile darFiles "A" "B.hie"
|
||||
checkDarFile darFiles "B" "C.daml"
|
||||
checkDarFile darFiles "B" "C.hi"
|
||||
checkDarFile darFiles "B" "C.hie"
|
||||
|
||||
, testCase "Imports from differen directories" $ withTempDir $ \projDir -> do
|
||||
-- Regression test for #2929
|
||||
@ -416,11 +459,11 @@ packagingTests tmpDir = testGroup "packaging"
|
||||
callCommandQuiet $ unwords ["daml", "migrate", projectRollback, bDar, aDar]
|
||||
step "Build migration project"
|
||||
withCurrentDirectory projectUpgrade $
|
||||
callCommand "daml build"
|
||||
callCommandQuiet "daml build"
|
||||
assertBool "upgrade-0.0.1.dar was not created" =<< doesFileExist upgradeDar
|
||||
step "Build rollback project"
|
||||
withCurrentDirectory projectRollback $
|
||||
callCommand "daml build"
|
||||
callCommandQuiet "daml build"
|
||||
assertBool "rollback-0.0.1.dar was not created" =<< doesFileExist rollbackDar
|
||||
step "Merging upgrade dar"
|
||||
callCommandQuiet $
|
||||
|
@ -13,3 +13,8 @@ HEAD — ongoing
|
||||
[Ledger] The ledger api index server starts only after the indexer has finished initializing the database.
|
||||
+ [DAML Standard Library] Add ``DA.Action.State`` module containing a ``State`` action that
|
||||
can be used for computations that modify a state variable.
|
||||
+ [DAML Compiler] Fixed the location of interface files when the
|
||||
``source`` field in ``daml.yaml`` points to a file. This is mainly
|
||||
important for when you want to use the created ``.dar`` in the
|
||||
``dependencies`` field of another package.
|
||||
See `issue #3135 <https://github.com/digital-asset/daml/issues/3135>`_.
|
||||
|
Loading…
Reference in New Issue
Block a user