All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ossuminc.riddl.testkit.RunPassTestBase.scala Maven / Gradle / Ivy

There is a newer version: 1.0.0-RC2
Show newest version
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