com.ossuminc.riddl.testkit.RunPassTestBase.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of riddl-testkit_3 Show documentation
Show all versions of riddl-testkit_3 Show documentation
A Testkit for testing RIDDL code, and a suite of those tests
package com.ossuminc.riddl.testkit
import com.ossuminc.riddl.language.AST.Root
import com.ossuminc.riddl.language.CommonOptions
import com.ossuminc.riddl.language.parsing.{RiddlParserInput, TopLevelParser}
import com.ossuminc.riddl.passes.{Pass, PassCreator, PassInfo, PassInput, PassesResult}
import com.ossuminc.riddl.utils.SysLogger
abstract class RunPassTestBase extends ValidatingTest {
def runPassesWith(
input: RiddlParserInput,
passToRun:PassCreator,
commonOptions: CommonOptions = CommonOptions.empty
)
: PassesResult = {
TopLevelParser.parseInput(input, commonOptions, true) match {
case Left(messages) => fail(messages.format)
case Right(root:Root) =>
val passesToRun = Pass.standardPasses :+ passToRun
val passInput = PassInput(root, commonOptions)
val result = Pass.runThesePasses(passInput, passesToRun, SysLogger())
if result.messages.hasErrors then fail(result.messages.justErrors.format)
result
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy