Skip to content
Snippets Groups Projects
Commit 9502e850 authored by Guy Zana's avatar Guy Zana
Browse files

cli: fix broken 'test' command

Broken by 92b6753b.

The test command of the CLI didn't work because Javascript cannot work
with a Java String[] array as if it is a JS array, I was surprised to see
92b6753b and I assumed it works but
apparently the test command got broken.

This patch properly returning a Scriptable object that Javascript
code understands, it acquires a thread specific Rhino Context that
is used to cast the test names to a JS array, and from there the JS
code picks it up.
parent 30f1782a
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,7 @@ package com.cloudius.cli.tests; ...@@ -3,6 +3,7 @@ package com.cloudius.cli.tests;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import sun.org.mozilla.javascript.Context;
import sun.org.mozilla.javascript.Scriptable; import sun.org.mozilla.javascript.Scriptable;
import com.cloudius.cli.main.RhinoCLI; import com.cloudius.cli.main.RhinoCLI;
...@@ -58,7 +59,12 @@ public class TestRunner { ...@@ -58,7 +59,12 @@ public class TestRunner {
this.registerELFTests(); this.registerELFTests();
} }
public String[] getTestNames() { public Scriptable getTestNames() {
return _tests.keySet().toArray(new String[_tests.size()]); Context cx = Context.enter();
Object[] names = _tests.keySet().toArray();
Scriptable tests = cx.newArray(cx.initStandardObjects(), names);
Context.exit();
return (tests);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment