From 777749539c492a05e625974aa2786c4a1e256c22 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Mon, 15 Feb 2021 20:20:24 +0100 Subject: [PATCH] Draw the rest of the Scala 2.13 owl (#8852) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- bazel_tools/client_server/tests/BUILD.bazel | 4 +-- ci/build.yml | 30 ++++--------------- .../damlc/tests/src/DA/Test/ScriptService.hs | 12 ++++---- .../damlc/tests/src/DA/Test/ShakeIdeClient.hs | 16 +++++----- .../client/src/DA/Daml/LF/PrettyScenario.hs | 6 ++-- daml-assistant/daml-sdk/BUILD.bazel | 14 +++++---- 6 files changed, 37 insertions(+), 45 deletions(-) diff --git a/bazel_tools/client_server/tests/BUILD.bazel b/bazel_tools/client_server/tests/BUILD.bazel index 4f2925e221..b8fd78a708 100644 --- a/bazel_tools/client_server/tests/BUILD.bazel +++ b/bazel_tools/client_server/tests/BUILD.bazel @@ -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", ], ) diff --git a/ci/build.yml b/ci/build.yml index b7f69c229b..8d0e30b7dc 100644 --- a/ci/build.yml +++ b/ci/build.yml @@ -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: diff --git a/compiler/damlc/tests/src/DA/Test/ScriptService.hs b/compiler/damlc/tests/src/DA/Test/ScriptService.hs index 6376a24e9a..22e8cd69d1 100644 --- a/compiler/damlc/tests/src/DA/Test/ScriptService.hs +++ b/compiler/damlc/tests/src/DA/Test/ScriptService.hs @@ -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 diff --git a/compiler/damlc/tests/src/DA/Test/ShakeIdeClient.hs b/compiler/damlc/tests/src/DA/Test/ShakeIdeClient.hs index 4c77cb079b..c40d79f316 100644 --- a/compiler/damlc/tests/src/DA/Test/ShakeIdeClient.hs +++ b/compiler/damlc/tests/src/DA/Test/ShakeIdeClient.hs @@ -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 ".*" [ "

TableView:Iou

" , "" , "S<", "tooltiptext", ">Signatory<", "" - , "O<", "tooltiptext", ">Observer<", "" - , "-<", "" - , "-<", "" - , "#1:1" , "S<", "tooltiptext", ">Signatory<", "" , "O<", "tooltiptext", ">Observer<", "" , "W<", "tooltiptext", ">Witness<", "" , "D<", "tooltiptext", ">Divulged<", "" , "" + , "#4:0" + , "S<", "tooltiptext", ">Signatory<", "" + , "O<", "tooltiptext", ">Observer<", "" + , "-<", "" + , "-<", "" + , "" , "

TableView:IouDivulger

" , "

TableView:IouIssuer

" diff --git a/compiler/scenario-service/client/src/DA/Daml/LF/PrettyScenario.hs b/compiler/scenario-service/client/src/DA/Daml/LF/PrettyScenario.hs index b0d810822c..e2bea9fdbc 100644 --- a/compiler/scenario-service/client/src/DA/Daml/LF/PrettyScenario.hs +++ b/compiler/scenario-service/client/src/DA/Daml/LF/PrettyScenario.hs @@ -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 diff --git a/daml-assistant/daml-sdk/BUILD.bazel b/daml-assistant/daml-sdk/BUILD.bazel index 1f3168c7b4..448d8e51c2 100644 --- a/daml-assistant/daml-sdk/BUILD.bazel +++ b/daml-assistant/daml-sdk/BUILD.bazel @@ -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", ], )