Skip to content

Commit

Permalink
able to replicate and resolve #2204
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrthomas committed Dec 6, 2022
1 parent ea146fc commit ff5f22d
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.intuit.karate.ScenarioActions;
import com.intuit.karate.StringUtils;
import com.intuit.karate.graal.JsEngine;
import com.intuit.karate.graal.JsValue;
import com.intuit.karate.http.ResourceType;
import com.intuit.karate.shell.StringLogAppender;

Expand Down Expand Up @@ -95,7 +96,7 @@ public ScenarioRuntime(FeatureRuntime featureRuntime, Scenario scenario) {
List<FeatureResult> list = new ArrayList(1);
FeatureResult fr = new FeatureResult(featureRuntime.featureCall.feature);
fr.setCallDepth(1);
fr.addResult(featureRuntime.setupResult);
fr.addResult(featureRuntime.setupResult);
list.add(fr);
sr.addCallResults(list);
featureRuntime.setupResult = null;
Expand Down Expand Up @@ -291,13 +292,15 @@ private void evalConfigJs(String js, String displayName) {
return;
}
try {
Variable fun = engine.evalJs("(" + js + ")");
if (!fun.isJsFunction()) {
logger.warn("not a valid js function: {}", displayName);
return;
synchronized (JsValue.LOCK) {
Variable fun = engine.evalJs("(" + js + ")");
if (!fun.isJsFunction()) {
logger.warn("not a valid js function: {}", displayName);
return;
}
Map<String, Object> map = engine.getOrEvalAsMap(fun);
engine.setVariables(map);
}
Map<String, Object> map = engine.getOrEvalAsMap(fun);
engine.setVariables(map);
} catch (Exception e) {
String message = ">> " + scenario.getDebugInfo() + "\n>> " + displayName + " failed\n>> " + e.getMessage();
error = JsEngine.fromJsEvalException(js, e, message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ public class ParallelJavaTest {

@Test
public void testParallel() {
Results results = Runner.path("classpath:com/intuit/karate/core/parajava/parallel-java.feature")
Results results = Runner.path("classpath:com/intuit/karate/core/parajava")
.configDir("classpath:com/intuit/karate/core/parajava")
.karateEnv("foo")
.parallel(5);
assertEquals(0, results.getFailCount(), results.getErrorMessages());
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Feature:

Scenario: test 1
* match Hello.sayHello("foo") == "hello foo"
* match addVals(1, 2) == 3

Scenario: test 2
* match Hello.sayHello("foo") == "hello foo"
* match addVals(1, 2) == 3

Scenario: test 3
* match Hello.sayHello("foo") == "hello foo"
* match addVals(1, 2) == 3

Scenario: test 4
* match Hello.sayHello("foo") == "hello foo"
* match addVals(1, 2) == 3

Scenario: test 5
* match Hello.sayHello("foo") == "hello foo"
* match addVals(1, 2) == 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Feature:

Scenario: test 1
* match Hello.sayHello("foo") == "hello foo"
* match addVals(1, 2) == 3

Scenario: test 2
* match Hello.sayHello("foo") == "hello foo"
* match addVals(1, 2) == 3

Scenario: test 3
* match Hello.sayHello("foo") == "hello foo"
* match addVals(1, 2) == 3

Scenario: test 4
* match Hello.sayHello("foo") == "hello foo"
* match addVals(1, 2) == 3

Scenario: test 5
* match Hello.sayHello("foo") == "hello foo"
* match addVals(1, 2) == 3
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
Feature:

Scenario:
* def addVals = function(val1, val2){ return val1 + val2 }
* def Hello = Java.type('com.intuit.karate.core.parallel.Hello')
* def BigDecimal = Java.type('java.math.BigDecimal')

0 comments on commit ff5f22d

Please sign in to comment.