Add regression test for unstable serializable types (#3976)

* Add regression test for unstable serializable types

This test verifies that we only have the serializable types in
daml-prim and daml-stdlib that we expect and don’t introduce new ones
by accident.

CHANGELOG_BEGIN
CHANGELOG_END

* Fix windows

* Ignore whitespace because windows

* optional is dead
This commit is contained in:
Moritz Kiefer 2020-01-08 12:06:07 +01:00 committed by GitHub
parent 9c30a7096b
commit 0ec595b680
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 80 additions and 0 deletions

View File

@ -345,6 +345,30 @@ sh_test(
],
)
sh_test(
name = "unstable-types",
srcs = ["src/unstable-types.sh"],
args = [
"$(location @jq_dev_env//:jq)",
"$(location :src/query-lf-interned.jq)",
"$(location //compiler/damlc/pkg-db)",
"$(location //compiler/damlc)",
"$(POSIX_DIFF)",
],
data = [
":src/query-lf-interned.jq",
"//compiler/damlc",
"//compiler/damlc/pkg-db",
"@jq_dev_env//:jq",
],
toolchains = [
"@rules_sh//sh/posix:make_variables",
],
deps = [
"@bazel_tools//tools/bash/runfiles",
],
)
# Generate a simple DALF for plain DALF import testing
genrule(

View File

@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Copyright (c) 2020 The DAML Authors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v2 ---
set -euo pipefail
JQ="$(rlocation "$TEST_WORKSPACE/$1")"
JQ_LF_LIB="$(rlocation "$TEST_WORKSPACE/$2")"
PKG_DB="$(rlocation "$TEST_WORKSPACE/$3")"
DAMLC="$(rlocation "$TEST_WORKSPACE/$4")"
DIFF=$5
get_serializable_types() {
$DAMLC inspect $1 --json | $JQ -L $(dirname $JQ_LF_LIB) 'import "query-lf-interned" as lf; .Sum.daml_lf_1 as $pkg | $pkg.modules | .[] | (.name | lf::get_dotted_name($pkg) | join(".")) as $modname | .data_types | .[] | select(.serializable) | .name | lf::get_dotted_name($pkg) | $modname + ":" + join(".")'
}
for LF_VERSION in $PKG_DB/*; do
# Skip 1.6 since we dont really care about it and it removes the need to handle LF versions without
# interning.
if [ $(basename $LF_VERSION) != "1.6" ]; then
stdlib=$LF_VERSION/daml-stdlib-*.dalf
prim=$LF_VERSION/daml-prim.dalf
$DIFF -b -u <(get_serializable_types $stdlib) <(cat <<EOF
"DA.Upgrade:MetaEquiv"
"DA.Random:Minstd"
"DA.Next.Set:Set"
"DA.Next.Map:Map"
"DA.Generics:MetaSel0"
"DA.Generics:MetaData0"
"DA.Generics:DecidedStrictness"
"DA.Generics:SourceStrictness"
"DA.Generics:SourceUnpackedness"
"DA.Generics:Associativity"
"DA.Generics:Infix0"
"DA.Generics:Fixity"
"DA.Generics:K1"
"DA.Generics:Par1"
"DA.Generics:U1"
EOF
)
$DIFF -b -u <(get_serializable_types $prim) <(cat <<EOF
EOF
)
fi
done