Skip to content

Commit

Permalink
Deduce pkgname in damlc migrate from dalf not dar (digital-asset#3000)
Browse files Browse the repository at this point in the history
The filename of the dar is not something that you should rely on as
evidenced by the fact that we have a -o option to change it to
something completely different.
  • Loading branch information
cocreature authored and mergify[bot] committed Sep 24, 2019
1 parent 78e5109 commit 1d593f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler/damlc/lib/DA/Cli/Damlc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -786,10 +786,10 @@ execMigrate projectOpts opts0 inFile1_ inFile2_ mbDir =
[(pkgName1, pkgId1, lfPkg1), (pkgName2, pkgId2, lfPkg2)] <-
forM [inFile1, inFile2] $ \inFile -> do
bytes <- B.readFile inFile
let pkgName = takeBaseName inFile
let dar = ZipArchive.toArchive $ BSL.fromStrict bytes
-- get the main pkg
dalfManifest <- either fail pure $ readDalfManifest dar
let pkgName = takeBaseName $ mainDalfPath dalfManifest
mainDalfEntry <- getEntry (mainDalfPath dalfManifest) dar
(mainPkgId, mainLfPkg) <- decode $ BSL.toStrict $ ZipArchive.fromEntry mainDalfEntry
pure (pkgName, mainPkgId, mainLfPkg)
Expand Down
11 changes: 7 additions & 4 deletions daml-assistant/integration-tests/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ packagingTests tmpDir = testGroup "packaging"
let projectB = tmpDir </> "a-2.0"
let projectUpgrade = tmpDir </> "upgrade"
let projectRollback = tmpDir </> "rollback"
let aDar = projectA </> distDir </> "a-1.0.dar"
let bDar = projectB </> distDir </> "a-2.0.dar"
let aDar = projectA </> "projecta.dar"
let bDar = projectB </> "projectb.dar"
let upgradeDar = projectUpgrade </> distDir </> "upgrade-0.0.1.dar"
let rollbackDar= projectRollback </> distDir </> "rollback-0.0.1.dar"
let bWithUpgradesDar = "a-2.0-with-upgrades.dar"
Expand Down Expand Up @@ -356,7 +356,8 @@ packagingTests tmpDir = testGroup "packaging"
, " - daml-prim"
, " - daml-stdlib"
]
withCurrentDirectory projectA $ callCommandQuiet "daml build"
-- We use -o to test that we do not depend on the name of the dar
withCurrentDirectory projectA $ callCommandQuiet $ "daml build -o " <> aDar
assertBool "a-1.0.dar was not created." =<< doesFileExist aDar
step "Creating project a-2.0 ..."
createDirectoryIfMissing True (projectB </> "daml")
Expand All @@ -383,9 +384,11 @@ packagingTests tmpDir = testGroup "packaging"
, " - daml-prim"
, " - daml-stdlib"
]
withCurrentDirectory projectB $ callCommandQuiet "daml build"
-- We use -o to test that we do not depend on the name of the dar
withCurrentDirectory projectB $ callCommandQuiet $ "daml build -o " <> bDar
assertBool "a-2.0.dar was not created." =<< doesFileExist bDar
step "Creating upgrade/rollback project"
-- We use -o to verify that we do not depend on the
callCommandQuiet $ unwords ["daml", "migrate", projectUpgrade, aDar, bDar]
callCommandQuiet $ unwords ["daml", "migrate", projectRollback, bDar, aDar]
step "Build migration project"
Expand Down

0 comments on commit 1d593f2

Please sign in to comment.