Skip to content

Commit

Permalink
Fixing #74. Fixing build (#75)
Browse files Browse the repository at this point in the history
* Fixing #74. Fixing build

* Trying to fix tests

* Trying to fix tests

* Trying to fix tests

* Trying to fix tests

* Trying to fix tests

* Trying to fix tests

* Adding compatibility version
  • Loading branch information
machaval authored Feb 14, 2023
1 parent dbca385 commit 0369edc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
weaveVersion=2.6.0-SNAPSHOT
weaveTestSuiteVersion=2.5.0-SNAPSHOT
weaveTestSuiteVersion=2.6.0-SNAPSHOT
nativeVersion=100.100.100
scalaVersion=2.12.11
ioVersion=1.0.0-SNAPSHOT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,16 @@ class NativeCliRuntimeIT extends FunSpec
private val INPUT_FILE_PATTERN = Pattern.compile("in[0-9]+\\.[a-zA-Z]+")
private val OUTPUT_FILE_PATTERN = Pattern.compile("out\\.[a-zA-Z]+")

private val versionString: String = DataWeaveVersion(ComponentVersion.weaveSuiteVersion).toString()

val testSuites = Seq(
TestSuite("master", loadTestZipFile(s"weave-suites/runtime-${ComponentVersion.weaveSuiteVersion}-test.zip")),
TestSuite("yaml", loadTestZipFile(s"weave-suites/yaml-module-${ComponentVersion.weaveSuiteVersion}-test.zip"))
)
TestSuite("master", loadTestZipFile(s"weave-suites/runtime-${ComponentVersion.weaveSuiteVersion}-test.zip")),
TestSuite("yaml", loadTestZipFile(s"weave-suites/yaml-module-${ComponentVersion.weaveSuiteVersion}-test.zip"))
)

private def loadTestZipFile(testSuiteExample: String): File = {
val url = getResource(testSuiteExample)
val connection = url.openConnection.asInstanceOf[FileURLConnection]
val connection = url.openConnection
val zipFile = new File(connection.getURL.toURI)
zipFile
}
Expand Down Expand Up @@ -131,6 +133,7 @@ class NativeCliRuntimeIT extends FunSpec
}
}


def runTestCase(testFolders: Array[File]): Unit = {
val unsortedScenarios = for {
testFolder <- testFolders
Expand All @@ -148,7 +151,7 @@ class NativeCliRuntimeIT extends FunSpec
scenario.inputs.foreach(f => {
val name = FilenameUtils.getBaseName(f.getName)
args = args :+ "-i"
args = args :+ (name + s"=${f.getAbsolutePath}" )
args = args :+ (name + s"=${f.getAbsolutePath}")

})

Expand Down Expand Up @@ -209,7 +212,7 @@ class NativeCliRuntimeIT extends FunSpec


args = args :+ s"--file=${cliTransform.getAbsolutePath}"
val languageLevel = DataWeaveVersion(ComponentVersion.weaveSuiteVersion).toString()
val languageLevel = versionString
args = args :+ "--language-level=" + languageLevel

val (exitCode, _, _) = NativeCliITTestRunner(args).execute(TIMEOUT._1, TIMEOUT._2)
Expand Down Expand Up @@ -398,7 +401,7 @@ class NativeCliRuntimeIT extends FunSpec
Array("sql_date_mapping") ++
Array("runtime_run")

if (DataWeaveVersion(ComponentVersion.weaveSuiteVersion).toString() == "2.4") {
val testToIgnore = if (versionString == "2.4") {
baseArray ++
// A change to json streaming in 2.5.0 breaks this test
Array("default_with_extended_null_type") ++
Expand All @@ -423,10 +426,16 @@ class NativeCliRuntimeIT extends FunSpec
) ++
Array("as-operator",
"type-equality"
)
} else {
) ++
Array("xml_doctype", "stringutils_unwrap")
} else if (versionString == "2.5") {
baseArray ++
Array("xml_doctype", "stringutils_unwrap")
}
else {
baseArray
}
testToIgnore
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.mule.weave.v2.parser.phase.CompositeModuleParsingPhasesManager
import org.mule.weave.v2.parser.phase.ModuleLoader
import org.mule.weave.v2.parser.phase.ModuleLoaderManager
import org.mule.weave.v2.parser.phase.ModuleParsingPhasesManager
import org.mule.weave.v2.runtime.CompilationConfig
import org.mule.weave.v2.runtime.DataWeaveResult
import org.mule.weave.v2.runtime.DataWeaveScript
import org.mule.weave.v2.runtime.DataWeaveScriptingEngine
Expand Down Expand Up @@ -55,16 +56,9 @@ class NativeRuntime(libDir: File, path: Array[File], console: Console, maybeLang

private val pathBasedResourceResolver: PathBasedResourceResolver = PathBasedResourceResolver(path ++ Option(libDir.listFiles()).getOrElse(new Array[File](0)))

private val languageLevelService: LanguageLevelService = {
maybeLanguageLevel match {
case Some(version) => WeaveLanguageLevelService(version)
case None => DefaultLanguageLevelService
}
}

private val weaveScriptingEngine: DataWeaveScriptingEngine = {
setupEnv()
new DataWeaveScriptingEngine(new NativeModuleComponentFactory(() => pathBasedResourceResolver, systemFirst = true), ParserConfiguration(), new Properties(), languageLevelService = languageLevelService)
new DataWeaveScriptingEngine(new NativeModuleComponentFactory(() => pathBasedResourceResolver, systemFirst = true), ParserConfiguration(), new Properties())
}

if (console.isDebugEnabled()) {
Expand Down Expand Up @@ -108,7 +102,16 @@ class NativeRuntime(libDir: File, path: Array[File], console: Console, maybeLang
}

private def compileScript(script: String, inputs: ScriptingBindings, nameIdentifier: NameIdentifier, defaultOutputMimeType: String) = {
weaveScriptingEngine.compile(script, nameIdentifier, inputs.entries().map(wi => new InputType(wi, None)).toArray, defaultOutputMimeType)
var config = weaveScriptingEngine.newConfig()
.withScript(script)
.withInputs(inputs.entries().map(wi => new InputType(wi, None)).toArray)
.withNameIdentifier(nameIdentifier)
.withDefaultOutputType(defaultOutputMimeType)

if (maybeLanguageLevel.isDefined) {
config = config.withLanguageVersion(maybeLanguageLevel.get)
}
weaveScriptingEngine.compileWith(config)
}

private def createServiceManager(maybePrivileges: Option[Seq[String]] = None): ServiceManager = {
Expand Down

0 comments on commit 0369edc

Please sign in to comment.