Skip to content

Commit

Permalink
#80 Adding back the path parameter (#81)
Browse files Browse the repository at this point in the history
* #80 Adding back the path parameter

* #80 Adding back the path parameter

* fix build
  • Loading branch information
machaval authored May 18, 2023
1 parent 28520c5 commit d096a2c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 14 deletions.
4 changes: 1 addition & 3 deletions native-cli-integration-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ sourceSets {
dependencies {
api(project(":native-cli"))

testImplementation group: 'org.scalatest', name: 'scalatest_2.12', version: scalaTestVersion
testImplementation group: 'org.mule.weave', name: 'parser', version: weaveVersion
testImplementation group: 'org.mule.weave', name: 'test-helpers', version: weaveVersion

weaveSuite "org.mule.weave:runtime:${weaveTestSuiteVersion}:test@zip"
weaveSuite "org.mule.weave:yaml-module:${weaveTestSuiteVersion}:test@zip"

testRuntimeOnly 'com.vladsch.flexmark:flexmark-all:0.62.2'
testImplementation 'commons-io:commons-io:2.11.0'
testRuntimeOnly 'org.pegdown:pegdown:1.6.0'
testImplementation group: 'com.sun.mail', name: 'jakarta.mail', version: '1.6.4'
testImplementation group: 'xerces', name: 'xercesImpl', version: '2.12.1'
testImplementation group: 'xalan', name: 'xalan', version: '2.7.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ import org.mule.weave.v2.utils.DataWeaveVersion
import org.mule.weave.v2.utils.StringHelper.toStringTransformer
import org.mule.weave.v2.version.ComponentVersion
import org.scalatest.Assertion
import org.scalatest.FunSpec
import org.scalatest.Matchers
import sun.net.www.protocol.file.FileURLConnection
import org.scalatest.funspec.AnyFunSpec

import java.io.ByteArrayInputStream
import java.io.File
Expand All @@ -46,8 +44,9 @@ import javax.mail.util.ByteArrayDataSource
import scala.collection.JavaConverters._
import scala.io.BufferedSource
import scala.io.Source
import org.scalatest.matchers.should.Matchers

class NativeCliRuntimeIT extends FunSpec
class NativeCliRuntimeIT extends AnyFunSpec
with Matchers
with FolderBasedTest
with ResourceResolver
Expand Down Expand Up @@ -357,7 +356,7 @@ class NativeCliRuntimeIT extends FunSpec

override def ignoreTests(): Array[String] = {
// Encoding issues
val baseArray = Array("csv-invalid-utf8") ++
val baseArray = Array("csv-invalid-utf8", "splitBy-regex", "splitBy-string" ) ++
// Fail in java11 because broken backwards
Array("coerciones_toString", "date-coercion") ++
// Use resources (dwl files) that is present in the Tests but not in Cli (e.g: org::mule::weave::v2::libs::)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package org.mule.weave.native

import org.mule.weave.v2.utils.DataWeaveVersion
import org.scalatest.BeforeAndAfterAll
import org.scalatest.FreeSpec
import org.scalatest.Matchers
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers

import java.io.File
import java.net.URL

class NativeCliTest extends FreeSpec
class NativeCliTest extends AnyFreeSpec
with Matchers
with BeforeAndAfterAll
with ResourceResolver {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.concurrent.Callable;

public abstract class AbstractPicoExecCommand implements Callable<Integer> {
Expand All @@ -30,6 +31,13 @@ public abstract class AbstractPicoExecCommand implements Callable<Integer> {
protected boolean untrusted = false;
@CommandLine.Option(names = {"--language-level"}, description = {"The version of DW to be supported."})
protected String languageLevel = null;

@CommandLine.Option(
names = {"--path"},
description = {"The path where DW runtime will look for resolving modules."},
split = ":"
)
protected java.util.List<String> path = new ArrayList<>();
@CommandLine.Option(
names = {"--privileges"},
description = {"A list of all allowed runtime privileges for this execution to have."},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public PicoRepl(Console console) {
@Override
protected Integer doCall() {
ReplConfiguration replConfiguration = new ReplConfiguration(
new String[0],
path.toArray(new String[0]),
Option.empty(),
Optional.ofNullable(params).map((s) -> toScalaMap(s)).orElse(Map$.MODULE$.<String, String>empty()),
Optional.ofNullable(inputs).map((s) -> toScalaMap(s)).orElse(Map$.MODULE$.<String, File>empty()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected Integer doCall() {

Option<DataWeaveVersion> dataWeaveVersionOption = calculateRuntimeVersion(languageLevel, spec);
final WeaveRunnerConfig config = new WeaveRunnerConfig(
new String[0],
path.toArray(new String[0]),
eval,
((nr) -> {
if (script != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import scala.collection.immutable.Map$;

import java.io.File;
import java.util.ArrayList;
import java.util.Optional;

@CommandLine.Command(
Expand Down Expand Up @@ -129,8 +130,11 @@ protected Integer doCall() {

Option<DataWeaveVersion> dataWeaveVersionOption = calculateRuntimeVersion(languageLevel, spec);

ArrayList<String> newPath = new ArrayList<>(path);
newPath.add(srcFolder.getAbsolutePath());

final WeaveRunnerConfig config = WeaveRunnerConfig.apply(
new String[]{srcFolder.getAbsolutePath()},
newPath.toArray(new String[0]),
eval,
(st) -> {
return new WeaveModule(fileToString(mainFile), nameIdentifier.toString());
Expand Down

0 comments on commit d096a2c

Please sign in to comment.