daml
daml copied to clipboard
Inline package upgrades test
Updates the upgrades tests to allow for "test dars" to be generated inline for test files using a comment yaml syntax, and cpp pragmas to modify per version. This allows our upgrades tests to be self contained and still simply daml files. The syntax is as follows
{- PACKAGE
name: <the-package-name>
versions: <number of versions to create as an int, will generate 1.0.0, 2.0.0, ..., n.0.0>
-}
{- MODULE
package: <a-package-name>
contents: |
module <Name.Of.The.Module> where
<write daml code here>
template Example with p: Party where signatory p
-}
Module names can be arbitrarily long, the correct project structure will be generated.
All daml code after the contents: | should be indented once more than the contents above it.
Packages (or more specifically, dars) will be generated with the naming scheme <package-name>-<package-version>. e.g. my-package-2.0.0.
The contents supports the special comments -- @V <space separated versions> to filter code based on version.
i.e. if you wanted a field only in v2, you'd write within contents
template Upgraded with
p: Party
anotherField: Optional Int -- @V 2
where
signatory p
The lines with @V comments are kept when building the dar with a version present in the comment (i.e. -- @V 2 3 will be kept when building versions 2.0.0 and 3.0.0), otherwise they are dropped. The lines without such comments are always preserved.
~~Maybe also a little readme describing the format?~~ I have now done this
Module names can be arbitrarily long, the correct project structure will be generated.
Not sure what you mean here, but LF restricts module names to 1000 chars including dot.