-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Script] move test_daml_script_test_runner from sandbox to canton
- Loading branch information
1 parent
6c874e8
commit ad396ba
Showing
4 changed files
with
125 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
115 changes: 115 additions & 0 deletions
115
daml-script/test/src/com/digitalasset/daml/lf/engine/script/test/DamlScriptTestRunner.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// Copyright (c) 2023 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.daml.lf.engine.script | ||
|
||
import com.daml.bazeltools.BazelRunfiles | ||
import com.daml.ledger.api.testing.utils.SuiteResourceManagementAroundAll | ||
import com.daml.lf.integrationtest.CantonFixture | ||
import com.daml.platform.services.time.TimeProviderType | ||
import com.daml.scalautil.Statement.discard | ||
import org.scalatest.Suite | ||
import org.scalatest.matchers.should.Matchers | ||
import org.scalatest.wordspec.AnyWordSpec | ||
|
||
import java.nio.file.Files | ||
|
||
class DamlScriptTestRunner | ||
extends AnyWordSpec | ||
with CantonFixture | ||
with Matchers | ||
with SuiteResourceManagementAroundAll { | ||
self: Suite => | ||
|
||
override protected def authSecret = None | ||
override protected def darFiles = List.empty | ||
override protected def devMode = false | ||
override protected def nParticipants = 1 | ||
override protected def timeProviderType = TimeProviderType.Static | ||
override protected def tlsEnable = false | ||
|
||
private val exe = if (sys.props("os.name").toLowerCase.contains("windows")) ".exe" else "" | ||
val scriptPath = BazelRunfiles.rlocation("daml-script/runner/daml-script-binary" + exe) | ||
val darPath = BazelRunfiles.rlocation("daml-script/test/script-test.dar") | ||
|
||
"daml-script command line" should { | ||
"pick up all scripts and returns somewhat sensible outputs" in { | ||
val expected = | ||
"""MultiTest:listKnownPartiesTest SUCCESS | ||
|MultiTest:multiTest SUCCESS | ||
|MultiTest:partyIdHintTest SUCCESS | ||
|ScriptExample:allocateParties SUCCESS | ||
|ScriptExample:initializeFixed SUCCESS | ||
|ScriptExample:initializeUser SUCCESS | ||
|ScriptExample:test SUCCESS | ||
|ScriptTest:clearUsers SUCCESS | ||
|ScriptTest:failingTest FAILURE (com.daml.lf.engine.script.ScriptF$FailedCmd: Command submit failed: FAILED_PRECONDITION: DAML_INTERPRETATION_ERROR(9,XXXXXXXX): Interpretation error: Error: Unhandled Daml exception: DA.Exception.AssertionFailed:AssertionFailed@3f4deaf1{ message = "Assertion failed" }. Details: Last location: [DA.Internal.Exception:168], partial transaction: ... | ||
|ScriptTest:listKnownPartiesTest SUCCESS | ||
|ScriptTest:multiPartySubmission SUCCESS | ||
|ScriptTest:partyIdHintTest SUCCESS | ||
|ScriptTest:sleepTest SUCCESS | ||
|ScriptTest:stackTrace FAILURE (com.daml.lf.engine.script.ScriptF$FailedCmd: Command submit failed: FAILED_PRECONDITION: DAML_INTERPRETATION_ERROR(9,XXXXXXXX): Interpretation error: Error: Unhandled Daml exception: DA.Exception.AssertionFailed:AssertionFailed@3f4deaf1{ message = "Assertion failed" }. Details: Last location: [DA.Internal.Exception:168], partial transaction: ... | ||
|ScriptTest:test0 SUCCESS | ||
|ScriptTest:test1 SUCCESS | ||
|ScriptTest:test3 SUCCESS | ||
|ScriptTest:test4 SUCCESS | ||
|ScriptTest:testCreateAndExercise SUCCESS | ||
|ScriptTest:testGetTime SUCCESS | ||
|ScriptTest:testKey SUCCESS | ||
|ScriptTest:testMaxInboundMessageSize SUCCESS | ||
|ScriptTest:testMultiPartyQueries SUCCESS | ||
|ScriptTest:testQueryContractId SUCCESS | ||
|ScriptTest:testQueryContractKey SUCCESS | ||
|ScriptTest:testSetTime SUCCESS | ||
|ScriptTest:testStack SUCCESS | ||
|ScriptTest:testUserListPagination SUCCESS | ||
|ScriptTest:testUserManagement SUCCESS | ||
|ScriptTest:testUserRightManagement SUCCESS | ||
|ScriptTest:traceOrder SUCCESS | ||
|ScriptTest:tree SUCCESS | ||
|ScriptTest:tupleKey SUCCESS | ||
|""".stripMargin | ||
|
||
val port = suiteResource.value.head.value | ||
|
||
import scala.sys.process._ | ||
val builder = new StringBuilder | ||
def log(s: String) = discard(builder.append(s).append('\n')) | ||
|
||
val cmd = Seq( | ||
scriptPath, | ||
"--all", | ||
"--static-time", | ||
"--dar", | ||
darPath, | ||
"--max-inbound-message-size", | ||
"41943040", | ||
"--ledger-host", | ||
"localhost", | ||
"--ledger-port", | ||
port.toString, | ||
) | ||
|
||
cmd ! ProcessLogger(log, log) | ||
|
||
val actual = builder | ||
.toString() | ||
.linesIterator | ||
.filter(s => List("SUCCESS", "FAILURE").exists(s.contains)) | ||
.mkString("", f"%n", f"%n") | ||
// ignore partial transactions as parties, cids, and package Ids are pretty unpredictable | ||
.replaceAll("partial transaction: [^\n]+", "partial transaction: ...") | ||
.replaceAll( | ||
"""DAML_INTERPRETATION_ERROR\((\d+),\w{8}\)""", | ||
"DAML_INTERPRETATION_ERROR($1,XXXXXXXX)", | ||
) | ||
|
||
if (cantonFixtureDebugMode) { | ||
Files.writeString(tmpDir.resolve(getClass.getSimpleName + ".expected"), expected) | ||
Files.writeString(tmpDir.resolve(getClass.getSimpleName + ".actual"), actual) | ||
} | ||
|
||
actual shouldBe expected | ||
} | ||
} | ||
} |