Add an integration test for daml packages (#1050)

This commit is contained in:
Moritz Kiefer 2019-05-09 16:45:40 +02:00 committed by GitHub
parent cb63adf63c
commit eb3b9a7ec4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 55 additions and 0 deletions

View File

@ -90,6 +90,7 @@ da_haskell_test(
"text",
],
deps = [
"//:sdk-version-hs-lib",
"//daml-assistant/daml-helper:daml-helper-lib",
"//libs-haskell/bazel-runfiles",
],

View File

@ -23,6 +23,7 @@ import Test.Tasty.HUnit
import DA.Bazel.Runfiles
import DamlHelper
import SdkVersion
main :: IO ()
main =
@ -49,12 +50,65 @@ tests tmpDir = testGroup "Integration tests"
, testCase "daml version" $ callProcessQuiet "daml" ["version"]
, testCase "daml --help" $ callProcessQuiet "daml" ["--help"]
, testCase "daml new --list" $ callProcessQuiet "daml" ["new", "--list"]
, packagingTests tmpDir
, quickstartTests quickstartDir mvnDir
]
where quickstartDir = tmpDir </> "quickstart"
mvnDir = tmpDir </> "m2"
tarballDir = tmpDir </> "tarball"
packagingTests :: FilePath -> TestTree
packagingTests tmpDir = testGroup "packaging"
[ testCaseSteps "Build package with dependency" $ \step -> do
let projectA = tmpDir </> "a"
let projectB = tmpDir </> "b"
let aDar = projectA </> "dist" </> "a.dar"
let bDar = projectB </> "dist" </> "b.dar"
step "Creating project a..."
createDirectoryIfMissing True (projectA </> "daml")
writeFileUTF8 (projectA </> "daml" </> "A.daml") $ unlines
[ "daml 1.2"
, "module A (a) where"
, "a : ()"
, "a = ()"
]
writeFileUTF8 (projectA </> "daml.yaml") $ unlines
[ "sdk-version: " <> sdkVersion
, "name: a"
, "version: \"1.0\""
, "source: daml/A.daml"
, "exposed-modules: [A]"
, "dependencies:"
, " - daml-prim"
, " - daml-stdlib"
]
withCurrentDirectory projectA $ callProcessQuiet "daml" ["build"]
assertBool "a.dar was not created." =<< doesFileExist aDar
step "Creating project b..."
createDirectoryIfMissing True (projectB </> "daml")
writeFileUTF8 (projectB </> "daml" </> "B.daml") $ unlines
[ "daml 1.2"
, "module B where"
, "import A"
, "b : ()"
, "b = a"
]
writeFileUTF8 (projectB </> "daml.yaml") $ unlines
[ "sdk-version: " <> sdkVersion
, "version: \"1.0\""
, "name: b"
, "source: daml/B.daml"
, "exposed-modules: [B]"
, "dependencies:"
, " - daml-prim"
, " - daml-stdlib"
, " - " <> aDar
]
withCurrentDirectory projectB $ callProcessQuiet "daml" ["build"]
assertBool "b.dar was not created." =<< doesFileExist bDar
]
quickstartTests :: FilePath -> FilePath -> TestTree
quickstartTests quickstartDir mvnDir = testGroup "quickstart"
[ testCase "daml new" $