Draw the rest of the Scala 2.13 owl (#8852)

* Draw the rest of the Scala 2.13 owl

Not quite but pretty close and this switches us over from inclusions
to exclusions which makes it much easier to track.

Ledger API test tool should be fixed by #8821. Non-repudiation needs a
tiny bit of work since unwrapArray doesn’t work the same on 2.13 but
shouldn’t be hard to fix.

changelog_begin
changelog_end

* Fix ScriptService tests

Those tests were all dumb. They asserted on a fixed order while the
function to sort the things was broken so we ended up with the random
Map order which is unsurprisingly not the same.

This is easily fixed by fixing the sort function.

There is also a second issue with query not sorting.

changelog_begin
changelog_end

* Turns out if you fix one test the next one breaks

And clearly nobody ever tested this or give this a second thought.

changelog_begin
changelog_end
This commit is contained in:
Moritz Kiefer 2021-02-15 20:20:24 +01:00 committed by GitHub
parent 0c72d07f27
commit 777749539c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 45 deletions

View File

@ -26,8 +26,8 @@ da_scala_binary(
name = "server",
srcs = ["server.scala"],
main_class = "com.daml.bazeltools.clientservertest.tests.Main",
deps = [
"@maven//:com_github_scopt_scopt_2_12",
scala_deps = [
"@maven//:com_github_scopt_scopt",
],
)

View File

@ -176,33 +176,15 @@ jobs:
set -euo pipefail
eval "$(./dev-env/bin/dade-assist)"
bazel build --config scala_2_13 -- \
//libs-scala/... \
//daml-lf/... \
//language-support/... \
//ledger-api/... \
//ledger/... \
//ledger-service/... \
//triggers/... \
//daml-script/... \
//navigator/... \
//extractor/... \
//... \
-//ledger/ledger-api-test-tool/... \
-//ledger/ledger-api-test-tool-on-canton/...
# gatling-utils tests fail with a ClassNotFoundException for scala.collection.SeqLike
-//runtime-components/...
# gatling-utils tests fail with a ClassNotFoundException for scala.collection.SeqLike
bazel test --config scala_2_13 -- \
//libs-scala/... \
//daml-lf/... \
//language-support/... \
//ledger-api/... \
//ledger/... \
//ledger-service/... \
//daml-script/... \
//triggers/... \
//navigator/... \
//extractor/... \
-//libs-scala/gatling-utils/... \
//... \
-//ledger/ledger-api-test-tool/... \
-//ledger/ledger-api-test-tool-on-canton/...
-//runtime-components/... \
-//libs-scala/gatling-utils/...
displayName: 'Build'
- template: tell-slack-failed.yml
parameters:

View File

@ -264,6 +264,7 @@ main =
[ "module Test where",
"import Daml.Script",
"import DA.Assert",
"import DA.List",
"template T1",
" with",
" p : Party, v: Int",
@ -281,6 +282,7 @@ main =
" where",
" signatory p1",
" observer p2",
"deriving instance Ord TShared",
"template Divulger",
" with",
" divulgee : Party",
@ -325,14 +327,14 @@ main =
" t1p2 <- query @T1 p2",
" t1p2 === [(cidT1p2, T1 p2 23)]",
" sharedp1 <- query @TShared p1",
" sharedp1 === [(cidSharedp1, TShared p1 p2), (cidSharedp2, TShared p2 p1)]",
" sortOn snd sharedp1 === [(cidSharedp1, TShared p1 p2), (cidSharedp2, TShared p2 p1)]",
" sharedp2 <- query @TShared p2",
" sharedp2 === [(cidSharedp1, TShared p1 p2), (cidSharedp2, TShared p2 p1)]"
" sortOn snd sharedp2 === [(cidSharedp1, TShared p1 p2), (cidSharedp2, TShared p2 p1)]"
]
expectScriptSuccess rs (vr "testQueryInactive") $ \r ->
matchRegex r "Active contracts: #2:0, #0:0\n\n"
matchRegex r "Active contracts: #0:0, #2:0\n\n"
expectScriptSuccess rs (vr "testQueryVisibility") $ \r ->
matchRegex r "Active contracts: #4:0, #3:0, #2:0, #0:0, #1:0\n\n"
matchRegex r "Active contracts: #0:0, #1:0, #2:0, #3:0, #4:0\n\n"
pure (),
testCase "submitMustFail" $ do
rs <-
@ -555,7 +557,7 @@ main =
, " pure ()"
]
expectScriptSuccess rs (vr "testQueryContract") $ \r ->
matchRegex r "Active contracts: #2:0, #0:0, #1:0",
matchRegex r "Active contracts: #0:0, #1:0, #2:0",
testCase "trace" $ do
rs <-
runScripts

View File

@ -1174,23 +1174,25 @@ scenarioTests mbScenarioService = Tasty.testGroup "Scenario tests"
let vr = VRScenario f "test"
setOpenVirtualResources [vr]
-- TODO(MH): Matching on HTML via regular expressions has a high
-- chance of becoming a maintenance nightmare. Fina a better way.
-- chance of becoming a maintenance nightmare. Find a better way.
expectVirtualResourceRegex vr $ T.intercalate ".*"
[ "<h1>TableView:Iou</h1>"
, "<table"
, "<tr", "Issuer", "Owner", "Regulator", "Spy", "</tr>"
, "<tr"
, "<td", "tooltip", ">S<", "tooltiptext", ">Signatory<", "</td>"
, "<td", "tooltip", ">O<", "tooltiptext", ">Observer<", "</td>"
, "<td", "tooltip", ">-<", "</td>"
, "<td", "tooltip", ">-<", "</td>"
, "</tr"
, "<tr"
, "<td>#1:1"
, "<td", "tooltip", ">S<", "tooltiptext", ">Signatory<", "</td>"
, "<td", "tooltip", ">O<", "tooltiptext", ">Observer<", "</td>"
, "<td", "tooltip", ">W<", "tooltiptext", ">Witness<", "</td>"
, "<td", "tooltip", ">D<", "tooltiptext", ">Divulged<", "</td>"
, "</tr>"
, "<tr"
, "<td>#4:0"
, "<td", "tooltip", ">S<", "tooltiptext", ">Signatory<", "</td>"
, "<td", "tooltip", ">O<", "tooltiptext", ">Observer<", "</td>"
, "<td", "tooltip", ">-<", "</td>"
, "<td", "tooltip", ">-<", "</td>"
, "</tr"
, "</table>"
, "<h1>TableView:IouDivulger</h1>"
, "<h1>TableView:IouIssuer</h1>"

View File

@ -114,9 +114,11 @@ lookupModule world mbPkgId modName = do
parseNodeId :: NodeId -> [Integer]
parseNodeId =
fmap (fromMaybe 0 . readMaybe . TL.unpack)
fmap (fromMaybe 0 . readMaybe . dropHash . TL.unpack)
. TL.splitOn ":"
. nodeIdId
where
dropHash s = fromMaybe s $ stripPrefix "#" s
prettyScenarioResult
:: LF.World -> ScenarioResult -> Doc SyntaxClass
@ -125,7 +127,7 @@ prettyScenarioResult world (ScenarioResult steps nodes retValue _finaltime trace
isActive Node{..} = case nodeNode of
Just NodeNodeCreate{} -> isNothing nodeConsumedBy
_ -> False
sortNodeIds = sortBy (\a b -> compare (parseNodeId a) (parseNodeId b))
sortNodeIds = sortOn parseNodeId
ppActive =
fcommasep
$ map prettyNodeIdLink

View File

@ -11,13 +11,20 @@ da_scala_library(
name = "sdk-lib",
srcs = glob(["src/main/scala/**/*.scala"]),
resources = glob(["src/main/resources/**/*"]),
scala_deps = [
"@maven//:com_typesafe_akka_akka_http_spray_json",
"@maven//:com_typesafe_scala_logging_scala_logging",
"@maven//:io_spray_spray_json",
],
scala_runtime_deps = [
"@maven//:com_typesafe_akka_akka_slf4j",
"@maven//:org_tpolecat_doobie_postgres",
],
visibility = ["//visibility:public"],
runtime_deps = [
"@maven//:ch_qos_logback_logback_classic",
"@maven//:ch_qos_logback_logback_core",
"@maven//:com_typesafe_akka_akka_slf4j_2_12",
"@maven//:io_grpc_grpc_netty",
"@maven//:org_tpolecat_doobie_postgres_2_12",
"@maven//:org_xerial_sqlite_jdbc",
],
deps = [
@ -31,9 +38,6 @@ da_scala_library(
"//triggers/runner:trigger-runner-lib",
"//triggers/service:trigger-service",
"//triggers/service/auth:oauth2-middleware",
"@maven//:com_typesafe_akka_akka_http_spray_json_2_12",
"@maven//:com_typesafe_scala_logging_scala_logging_2_12",
"@maven//:io_spray_spray_json_2_12",
],
)