daml/test-common/test-common.bzl
Moisés Ackerman e6bf01717f
Remove more internal uses of Scenario (#17375)
* daml-lf-test.sh no longer takes damlc argument

* Split //daml-lf/tests:BasicTests into engine and integration tests

* Remove unused //daml-lf/engine:Optional

* Convert //daml-lf/tests:AuthorizedDivulgence into integration test

* Convert //daml-lf/tests:DontDiscloseNonConsumingExercisesToObservers into integration test

* Convert //daml-lf/tests:ConjunctionChoices into integration test

* Convert //daml-lf/tests:ContractKeys into integration test LFContractKeys

* Move //daml-lf/tests:AuthTests to //daml-lf/engine:AuthTests

* Split //daml-lf/tests:LargeTransaction into ledger and non-ledger tests

* Remove scenarios in //language-support/java/codegen:ledger-tests-model

* Remove unused scenarios in //test-common:src/main/daml/model/Test.daml

* Remove 'enable_scenarios' param in da_scala_dar_resources_library

* Remove 'enable_scenarios' param in damlc_compile_test

* Remove '--enable-scenarios=yes in //compiler/damlc/tests:deterministic

* Convert /daml-lf/tests/scenario/dev/experimental to integration test

* Convert /daml-lf/tests/scenario/dev/interfaces to integration test

* Convert /daml-lf/tests/scenario/stable/big-numeric to integration test

* Convert /daml-lf/tests/scenario/stable/contract-key-through-exercises to integration test

* Convert /daml-lf/tests/scenario/stable/contract-keys to integration test

* Convert /daml-lf/tests/scenario/stable/divulge-iou to integration test

* Convert /daml-lf/tests/scenario/stable/embed-abort to integration test

* Convert /daml-lf/tests/scenario/stable/eval-agreement to integration test

* Convert /daml-lf/tests/scenario/stable/exception-auth to integration test

* Convert /daml-lf/tests/scenario/stable/gen-map to integration test

* Convert /daml-lf/tests/scenario/stable/many-fields to integration test

* Convert /daml-lf/tests/scenario/stable/mustfailcommit to integration test

* Convert /daml-lf/tests/scenario/stable/mustfailinterpretation to integration test

* Convert /daml-lf/tests/scenario/stable/mustfails to integration test

* Convert /daml-lf/tests/scenario/stable/no-contract-ids-in-keys to integration test

* Convert /daml-lf/tests/scenario/stable/pass-time to integration test

* Convert /daml-lf/tests/scenario/stable/pattern-matching to integration test

* Convert /daml-lf/tests/scenario/stable/timeout to integration test

* Remove scaffolding for daml-lf/tests/scenario

* Remove unused 'enable-scenarios' flags

* Remove unused daml-lf/tests/daml-lf-test.sh

* Remove unused daml-lf/tests/scala-test-limited-stack.sh

* Remove comments about deprecated flag 'DontDivulgeContractIdsInCreateArguments' in AuthorizedDivulgence integration test

* Add 'create' in LfStableTimeout:testScriptLoop

* add TODO for nesting limits test in LfStableMustFails

* Move LfStableMustFails expected ledger files into subdir
2023-09-28 16:29:46 +01:00

87 lines
3.6 KiB
Python

# Copyright (c) 2023 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load("//bazel_tools:scala.bzl", "da_scala_library")
load("//rules_daml:daml.bzl", "daml_compile")
load("//daml-lf/language:daml-lf.bzl", "mangle_for_java")
def to_camel_case(name):
return "".join([part.capitalize() for part in name.split("_")])
def da_scala_dar_resources_library(
daml_root_dir,
daml_dir_names,
lf_versions,
add_maven_tag = False,
maven_name_prefix = "",
exclusions = {},
data_dependencies = {},
**kwargs):
"""
Define a Scala library with dar files as resources.
"""
for lf_version in lf_versions:
for daml_dir_name in daml_dir_names.get(lf_version, []):
# 1. Compile daml files
daml_compile_name = "%s-tests-%s" % (daml_dir_name, lf_version)
daml_compile_kwargs = {
"project_name": "%s-tests" % daml_dir_name.replace("_", "-"),
"srcs": native.glob(["%s/%s/*.daml" % (daml_root_dir, daml_dir_name)], exclude = exclusions.get(lf_version, [])),
"target": lf_version,
}
daml_compile_kwargs.update(kwargs)
daml_compile(
name = daml_compile_name,
data_dependencies = [dep % (lf_version) for dep in data_dependencies.get(daml_dir_name, [])],
**daml_compile_kwargs
)
# 2. Generate lookup objects
genrule_name = "test-dar-lookup-%s" % lf_version
genrule_command = """
cat > $@ <<EOF
package com.daml.ledger.test
import com.daml.lf.language.LanguageVersion
sealed trait TestDar {{ val path: String }}
object TestDar {{
val lfVersion: LanguageVersion = LanguageVersion.v{lf_version}
val paths: List[String] = List(
EOF
""".format(lf_version = mangle_for_java(lf_version)) + "\n".join(["""
echo " \\"%s/%s-tests-%s.dar\\"," >> $@
""" % (native.package_name(), test_name, lf_version) for test_name in daml_dir_names.get(lf_version, [])]) + """
echo " )\n}\n" >> $@
""" + "\n".join(["""
echo "case object %sTestDar extends TestDar { val path = \\"%s/%s-tests-%s.dar\\" }" >> $@
""" % (to_camel_case(test_name), native.package_name(), test_name, lf_version) for test_name in daml_dir_names.get(lf_version, [])])
genrule_kwargs = {
"outs": ["TestDar-%s.scala" % mangle_for_java(lf_version)],
"cmd": genrule_command,
}
genrule_kwargs.update(kwargs)
native.genrule(name = genrule_name, **genrule_kwargs)
# 3. Build a Scala library with the above
filegroup_name = "dar-files-%s" % lf_version
filegroup_kwargs = {
"srcs": ["%s-tests-%s.dar" % (dar_name, lf_version) for dar_name in daml_dir_names.get(lf_version, [])],
}
filegroup_kwargs.update(kwargs)
native.filegroup(name = filegroup_name, **filegroup_kwargs)
da_scala_library_name = "dar-files-%s-lib" % lf_version
da_scala_library_kwargs = {
"srcs": [":test-dar-lookup-%s" % lf_version],
"generated_srcs": [":test-dar-files-%s.scala" % lf_version], # required for scaladoc
"resources": ["dar-files-%s" % lf_version],
"deps": ["//daml-lf/language"],
}
if add_maven_tag:
da_scala_library_kwargs.update({"tags": ["maven_coordinates=com.daml:%s-dar-files-%s-lib:__VERSION__" % (maven_name_prefix, lf_version)]})
da_scala_library_kwargs.update(kwargs)
da_scala_library(name = da_scala_library_name, **da_scala_library_kwargs)