daml/triggers/tests/BUILD.bazel
Stefano Baghino aec3390904
Replace silencer plugin with built-in warning configuration (#12543)
Since Scala 2.13.2, Scala introduced built-in support to
manage warnings in a more granular fashion, thus making
the silencer plugin we are currently using no longer
strictly useful. Removing compiler plugins also removes
friction from migrating to Scala 3 in the future. As a
cherry on top, the built-in warning configuration also
allows to check whether a `@nowarn` actually does
anything, allowing us to proactively remove unused
warnings should the need arise.

[Here][1] is s a blog post by the Scala team about it.

Warnings have been either solved or preserved if useful,
trying to minimize the scope (keeping it at the single
expression scope if possible). In particular, all
remaining usages of the Scala Collection API compatibility
module have been removed.

Using the silencer plugin also apparently hid a few
remaining usages of compatibility libraries that were used
as part of the transition from Scala 2.12 to Scala 2.13
that are no longer needed. Removing those warnings
highlighted those.

changelog_begin
changelog_end

[1]: https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html
2022-01-24 15:01:35 +00:00

179 lines
6.4 KiB
Python

# Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load(
"//bazel_tools:scala.bzl",
"da_scala_binary",
"da_scala_library",
"da_scala_test_suite",
)
load("@build_environment//:configuration.bzl", "sdk_version")
DAML_LF_VERSIONS = [
"1.dev",
"", # SDK default
]
[
genrule(
name = "acs" + suffix,
srcs =
glob(["**/*.daml"]) + [
"//triggers/daml:daml-trigger%s.dar" % suffix,
"//daml-script/daml:daml-script%s.dar" % suffix,
] + [
"//templates:copy-trigger/src/CopyTrigger.daml",
],
outs = ["acs%s.dar" % suffix],
cmd = """
set -eou pipefail
TMP_DIR=$$(mktemp -d)
mkdir -p $$TMP_DIR/daml
cp -L $(location :daml/ACS.daml) $$TMP_DIR/daml
cp -L $(location :daml/Retry.daml) $$TMP_DIR/daml
cp -L $(location :daml/ExerciseByKey.daml) $$TMP_DIR/daml
cp -L $(location :daml/CreateAndExercise.daml) $$TMP_DIR/daml
cp -L $(location :daml/MaxInboundMessageTest.daml) $$TMP_DIR/daml
cp -L $(location :daml/Numeric.daml) $$TMP_DIR/daml
cp -L $(location :daml/CommandId.daml) $$TMP_DIR/daml
cp -L $(location :daml/PendingSet.daml) $$TMP_DIR/daml
cp -L $(location :daml/TemplateIdFilter.daml) $$TMP_DIR/daml
cp -L $(location :daml/Time.daml) $$TMP_DIR/daml
cp -L $(location :daml/Heartbeat.daml) $$TMP_DIR/daml
cp -L $(location :daml/ReadAs.daml) $$TMP_DIR/daml
cp -L $(location :daml/ActAs.daml) $$TMP_DIR/daml
cp -L $(location //templates:copy-trigger/src/CopyTrigger.daml) $$TMP_DIR/daml
cp -L $(location //triggers/daml:daml-trigger{suffix}.dar) $$TMP_DIR/daml-trigger.dar
cp -L $(location //daml-script/daml:daml-script{suffix}.dar) $$TMP_DIR/daml-script.dar
if [ "{lf_version}" = "1.dev" ]
then
cp -L $(location :daml/Interface.daml) $$TMP_DIR/daml
fi
cat << EOF > $$TMP_DIR/daml.yaml
sdk-version: {sdk}
name: acs
source: daml
version: 0.0.1
dependencies:
- daml-stdlib
- daml-prim
- daml-trigger.dar
- daml-script.dar
EOF
test -z "{lf_version}" || echo "build-options: [--target={lf_version}]" >> $$TMP_DIR/daml.yaml
$(location //compiler/damlc) build --project-root=$$TMP_DIR --ghc-option=-Werror -o $$PWD/$(location acs{suffix}.dar)
rm -rf $$TMP_DIR
""".format(
sdk = sdk_version,
lf_version = lf_version,
suffix = suffix,
),
tools = ["//compiler/damlc"],
visibility = ["//visibility:public"],
)
for lf_version in DAML_LF_VERSIONS
for suffix in [("-" + lf_version) if lf_version else ""]
]
da_scala_library(
name = "test-utils",
srcs = [
"src/test/scala/com/digitalasset/daml/lf/engine/trigger/test/AbstractFuncTests.scala",
"src/test/scala/com/digitalasset/daml/lf/engine/trigger/test/AbstractTriggerTest.scala",
],
scala_deps = [
"@maven//:com_typesafe_akka_akka_stream",
"@maven//:org_scalactic_scalactic",
"@maven//:org_scalatest_scalatest_core",
"@maven//:org_scalatest_scalatest_matchers_core",
"@maven//:org_scalatest_scalatest_shouldmatchers",
"@maven//:org_scalatest_scalatest_wordspec",
"@maven//:org_scalaz_scalaz_core",
],
deps = [
"//bazel_tools/runfiles:scala_runfiles",
"//daml-lf/archive:daml_lf_archive_reader",
"//daml-lf/data",
"//daml-lf/interpreter",
"//daml-lf/language",
"//daml-lf/transaction",
"//language-support/scala/bindings",
"//language-support/scala/bindings-akka",
"//ledger-api/rs-grpc-bridge",
"//ledger-api/testing-utils",
"//ledger/ledger-api-auth",
"//ledger/ledger-api-common",
"//ledger/ledger-api-domain",
"//ledger/ledger-resources",
"//ledger/participant-integration-api",
"//ledger/sandbox",
"//ledger/sandbox:sandbox-scala-tests-lib",
"//ledger/sandbox-common",
"//ledger/sandbox-common:sandbox-common-scala-tests-lib",
"//ledger/test-common",
"//libs-scala/contextualized-logging",
"//libs-scala/ports",
"//libs-scala/resources",
"//triggers/runner:trigger-runner-lib",
"@maven//:org_scalatest_scalatest_compatible",
],
)
[
da_scala_test_suite(
name = "trigger-integration-tests" + suffix,
srcs = [
"src/test/scala/com/digitalasset/daml/lf/engine/trigger/test/%s.scala" % f
for f in [
"FuncTestsStaticTime",
"FuncTestsWallClock",
"Jwt",
"Tls",
"RunnerSpec",
"UnfoldStateSpec",
"ConfigSpec",
] + (["DevOnly"] if lf_version else [])
],
data = [
":acs%s.dar" % suffix,
"//ledger/test-common/test-certificates",
],
resources = ["//triggers/runner:src/main/resources/logback.xml"],
scala_deps = [
"@maven//:com_typesafe_akka_akka_stream",
"@maven//:org_scalacheck_scalacheck",
"@maven//:org_scalatestplus_scalacheck_1_15",
"@maven//:org_scalaz_scalaz_core",
],
deps = [
":test-utils",
"//bazel_tools/runfiles:scala_runfiles",
"//daml-lf/archive:daml_lf_archive_reader",
"//daml-lf/data",
"//daml-lf/interpreter",
"//daml-lf/language",
"//language-support/scala/bindings",
"//language-support/scala/bindings-akka",
"//ledger-api/rs-grpc-bridge",
"//ledger-api/testing-utils",
"//ledger/caching",
"//ledger/ledger-api-auth",
"//ledger/ledger-api-common",
"//ledger/ledger-api-domain",
"//ledger/ledger-configuration",
"//ledger/ledger-resources",
"//ledger/participant-integration-api",
"//ledger/sandbox:sandbox-scala-tests-lib",
"//ledger/sandbox-common",
"//ledger/sandbox-common:sandbox-common-scala-tests-lib",
"//ledger/test-common",
"//libs-scala/ports",
"//libs-scala/resources",
"//libs-scala/scalatest-utils",
"//triggers/runner:trigger-runner-lib",
],
)
for lf_version in DAML_LF_VERSIONS
for suffix in [("-" + lf_version) if lf_version else ""]
]