JS test: turn rhino optimization off for stdlib tests
This commit is contained in:
committed by
Zalim Bashorov
parent
3f2d4b31be
commit
15e963de25
@@ -41,7 +41,13 @@ public final class RhinoUtils {
|
||||
private static final Set<String> IGNORED_JSHINT_WARNINGS = Sets.newHashSet();
|
||||
|
||||
private static final NativeObject JSHINT_OPTIONS = new NativeObject();
|
||||
|
||||
|
||||
public static final String OPTIMIZATION_LEVEL_TEST_VARIABLE = "rhinoOptimizationLevel";
|
||||
|
||||
public static final int OPTIMIZATION_OFF = -1;
|
||||
|
||||
public static final int OPTIMIZATION_DEFAULT = 0;
|
||||
|
||||
@NotNull
|
||||
private static final Map<EcmaVersion, ScriptableObject> versionToScope = ContainerUtil.newHashMap();
|
||||
|
||||
@@ -127,6 +133,11 @@ public final class RhinoUtils {
|
||||
@NotNull EcmaVersion ecmaVersion,
|
||||
@NotNull List<String> jsLibraries) throws Exception {
|
||||
Context context = createContext(ecmaVersion);
|
||||
|
||||
if (variables != null) {
|
||||
context.setOptimizationLevel(getOptimizationLevel(variables));
|
||||
}
|
||||
|
||||
try {
|
||||
ScriptableObject scope = getScope(ecmaVersion, context, jsLibraries);
|
||||
putGlobalVariablesIntoScope(scope, variables);
|
||||
@@ -268,4 +279,14 @@ public final class RhinoUtils {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static int getOptimizationLevel(@NotNull Map<String, Object> testVariables) {
|
||||
Object optimizationLevel = testVariables.get(OPTIMIZATION_LEVEL_TEST_VARIABLE);
|
||||
|
||||
if (optimizationLevel instanceof Integer) {
|
||||
return (Integer) optimizationLevel;
|
||||
}
|
||||
|
||||
return OPTIMIZATION_DEFAULT;
|
||||
}
|
||||
}
|
||||
@@ -26,11 +26,9 @@ import org.jetbrains.k2js.test.MultipleFilesTranslationTest;
|
||||
import org.jetbrains.k2js.test.config.JsUnitTestReporter;
|
||||
import org.jetbrains.k2js.test.config.TestConfigWithUnitTests;
|
||||
import org.jetbrains.k2js.test.rhino.RhinoSystemOutputChecker;
|
||||
import org.jetbrains.k2js.test.rhino.RhinoUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.k2js.test.utils.LibraryFilePathsUtil.getAdditionalLibraryFiles;
|
||||
|
||||
@@ -103,6 +101,9 @@ public abstract class JsUnitTestBase extends MultipleFilesTranslationTest {
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getRhinoTestVariables() throws Exception {
|
||||
return Collections.<String, Object>singletonMap("jsTestReporter", JS_UNIT_TEST_REPORTER);
|
||||
Map<String, Object> testVariables = new HashMap<String, Object>();
|
||||
testVariables.put(RhinoUtils.OPTIMIZATION_LEVEL_TEST_VARIABLE, RhinoUtils.OPTIMIZATION_OFF);
|
||||
testVariables.put("jsTestReporter", JS_UNIT_TEST_REPORTER);
|
||||
return testVariables;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user