Checks the scriptExitCode value of the script execution and fails the operation if exit code is different than zero.
@param resultMap
162131
public static void verifyScriptExecutionStatus(final Map<String, String> resultMap) {
        if (ZERO_SCRIPT_EXIT_CODE.equals(resultMap.get(SCRIPT_EXIT_CODE))) {
            resultMap.put(RETURN_CODE, RETURN_CODE_SUCCESS);
        } else {
            resultMap.put(RETURN_CODE, RETURN_CODE_FAILURE);
        }
    }
1087988
@Override
    public void doExecute() throws MojoExecutionException, MojoFailureException {
        if (!ignoreResultFailures && !scanResultsForFailedRequests) {
            getLog().warn(String.format(
                    "current value of scanResultsForFailedRequests(%s) is incompatible with ignoreResultFailures(%s), setting scanResultsForFailedRequests to true",
                    scanResultsForFailedRequests,
                    ignoreResultFailures
            ));
            scanResultsForFailedRequests = true;
        }
        if (scanResultsForSuccessfulRequests || scanResultsForFailedRequests) {
            getLog().info(" ");
            getLog().info(LINE_SEPARATOR);
            getLog().info("S C A N N I N G    F O R    R E S U L T S");
            getLog().info(LINE_SEPARATOR);
            getLog().info(" ");
            TestConfig testConfig = new TestConfig(new File(testConfigFile));
            String resultFormat = testConfig.getResultsOutputIsCSVFormat() ? "CSV" : "JTL";
            getLog().info(String.format("Will scan results using format: %s", resultFormat));
            ResultScanner resultScanner = new ResultScanner(
                    scanResultsForSuccessfulRequests,
                    scanResultsForFailedRequests,
                    testConfig.getResultsOutputIsCSVFormat()
            );
            for (String resultFileLocation : testConfig.getResultsFileLocations()) {
                resultScanner.parseResultFile(new File(resultFileLocation));
            }
            getLog().info(" ");
            getLog().info(LINE_SEPARATOR);
            getLog().info("P E R F O R M A N C E    T E S T    R E S U L T S");
            getLog().info(LINE_SEPARATOR);
            getLog().info(" ");
            getLog().info(String.format("Result (.%s) files scanned: %s", resultFormat.toLowerCase(), testConfig.getResultsFileLocations().size()));
            getLog().info(String.format("Successful requests:         %s", resultScanner.getSuccessCount()));
            getLog().info(String.format("Failed requests:             %s", resultScanner.getFailureCount()));
            TestFailureDecider decider = new TestFailureDecider(ignoreResultFailures, errorRateThresholdInPercent, resultScanner);
            decider.runChecks();
            getLog().info(String.format("Failures:                    %s%% (%s%% accepted)", decider.getErrorPercentage(), decider.getErrorPercentageThreshold()));
            getLog().info(" ");
            if (decider.failBuild()) {
                throw new MojoFailureException(String.format(
                        "Failing build because error percentage %s is above accepted threshold %s. JMeter logs are available at: '%s'",
                        logsDirectory.getAbsolutePath(),
                        decider.getErrorPercentage(),
                        decider.getErrorPercentageThreshold()
                ));
            }
        } else {
            getLog().info(" ");
            getLog().info("Results of Performance Test(s) have not been scanned.");
            getLog().info(" ");
        }
    }
890050
public <T> T eval(String name, final String script, Map<String,Object> data) throws ScriptException,ScriptLimitException,SyntaxException {
        long t = System.currentTimeMillis();
        if(data==null)
            data = Objects.newHashMap();
        if(script.length()>sizeLimit)
            throw new ScriptLimitException(ScriptLimitException.Limits.SIZE,getSizeLimit());
        if(LOG.isDebugEnabled()){
            LOG.debug("Evaluating S1 script:\n"+script+"\nWith data:"+data);
        }

        AstRoot _root = null;
        if(Objects.isNullOrEmpty(name)){
            _root = parseScript(script);
        }else{
            _root = astCache.get(name,new Closure<String, AstRoot>() {
                @Override
                public AstRoot call(String input) {
                    return parseScript(script);
                }
            });
        }
        final AstRoot root = _root;

        final Context ctx=new Context(getMemoryLimit());
        ctx.getVariables().putAll(data);

        //functions from options
        for(final Map<String,Object> f:functions){
            String clName = Objects.get(f,"class");
            String ns = Objects.get(f,"namespace","");
            Map<String,Object> set_cfg = Objects.get(f,"config",Objects.newSOHashMap());
            Class<? extends ScriptFunctionSet> cls = null;
            try {
                cls = (Class<? extends ScriptFunctionSet>)Class.forName(clName);
                ScriptFunctionSet set = cls.newInstance();
                set.setConfig(set_cfg);
                set.setContext(new Context(getMemoryLimit()));
                Objects.set(ctx.getVariables(),ns,set);
            } catch (Throwable e) {
                LOG.warn("Class "+cls+" cannot be initialized as ScriptFunctions: "+e.getMessage(),e);
            }
        }

        //system functions
        ScriptFunctionSet set = new SystemFunctionSet();
        //set.setConfig(set_cfg);
        set.setContext(new Context(getMemoryLimit()));
        Objects.set(ctx.getVariables(),SYSTEM_FUNCTION_NS,set);

        final Session.SessionBean sb = Session.getSessionBean();

        Future<Object> f = null;
        if(isInside.get() == null || !isInside.get()) {
            if (sb != null) {
                //run script
                f = getService().submit(new Callable<Object>() {
                    @Override
                    public Object call() throws Exception {
                        String id = null;
                        try {
                            isInside.set(true);
                            id = Session.start(sb.getId());
                            ASTEvaluator ast = new ASTEvaluator();
                            Object o = ast.eval(root, ctx);
                            return o;
                        } finally {
                            Session.end(id);
                            isInside.set(false);
                        }
                    }
                });
            } else {
                //run script
                f = getService().submit(new Callable<Object>() {
                    @Override
                    public Object call() throws Exception {
                        try {
                            isInside.set(true);
                            ASTEvaluator ast = new ASTEvaluator();
                            Object o = ast.eval(root, ctx);
                            return o;
                        }finally {
                            isInside.set(false);
                        }
                    }
                });
            }
        }

        try {
            long l = System.currentTimeMillis();
            T result = null;
            /*try {
                // Try to get answer in short timeout, should be available
                result = (T)f.get(getTimeLimit(), TimeUnit.MILLISECONDS);
            } catch (TimeoutException te) {
                f.cancel(true);
                throw new ScriptLimitException(ScriptLimitException.Limits.TIME,getTimeLimit());
            }*/
            if(f==null || getTimeLimit()<=0){
                ASTEvaluator ast = new ASTEvaluator();
                result = (T)ast.eval(root, ctx);
            }else {
                while (true) {
                    if (System.currentTimeMillis() - l > getTimeLimit()) {
                        f.cancel(true);
                        throw new ScriptLimitException(ScriptLimitException.Limits.TIME, getTimeLimit());
                    }

                    if (f.isDone()) {
                        break;
                    }
                    Thread.sleep(1);
                }
                result = (T) f.get();
            }
            if(LOG.isDebugEnabled()){
                LOG.debug("Script result ("+(System.currentTimeMillis()-t)+"ms.): "+result);
            }
            return result;
        } catch (InterruptedException e){
            throw S1SystemError.wrap(e);
        } catch (ExecutionException e){
            if(e.getCause()!=null){
                if(e.getCause() instanceof ScriptLimitException)
                    throw (ScriptLimitException)e.getCause();
                if(e.getCause() instanceof ScriptException) {
                    ScriptException se = (ScriptException) e.getCause();
                    int line = se.getLine();
                    if(line>=0){
                        String arr [] = script.split("\n",-1);
                        String m = (arr.length>line?(arr[line]):"");
                        se.setCode(m);
                        throw se;
                    }
                    throw se;
                }
            }
            throw S1SystemError.wrap(e);
        } catch (ScriptException se){
            int line = se.getLine();
            if(line>=0){
                String arr [] = script.split("\n",-1);
                String m = (arr.length>line?(arr[line]):"");
                se.setCode(m);
                throw se;
            }
            throw se;
        }
    }
1011664
@SneakyThrows
    public static <T> T executeGroovyScript(final GroovyObject groovyObject,
                                            final String methodName,
                                            final Object[] args,
                                            final Class<T> clazz,
                                            final boolean failOnError) {
        try {
            LOGGER.trace("Executing groovy script's [{}] method, with parameters [{}]", methodName, args);
            val result = groovyObject.invokeMethod(methodName, args);
            LOGGER.trace("Results returned by the groovy script are [{}]", result);

            if (!clazz.equals(Void.class)) {
                return getGroovyScriptExecutionResultOrThrow(clazz, result);
            }
        } catch (final Exception e) {
            var cause = (Throwable) null;
            if (e instanceof InvokerInvocationException) {
                cause = e.getCause();
            } else {
                cause = e;
            }
            if (failOnError) {
                throw cause;
            }
            LOGGER.error(cause.getMessage(), cause);
        }
        return null;
    }
192109
@Override
  public void exec(Result<Object> result, Object ...args)
  {
    TableKelp tableKelp = _table.getTableKelp();
    
    RowCursor minCursor = tableKelp.cursor();
    RowCursor maxCursor = tableKelp.cursor();
    
    minCursor.clear();
    maxCursor.setKeyMax();
    
    _keyExpr.fillMinCursor(minCursor, args);
    _keyExpr.fillMaxCursor(maxCursor, args);
    
    //QueryKelp whereKelp = _whereExpr.bind(args);
    // XXX: binding should be with unique
    EnvKelp whereKelp = new EnvKelp(_whereKelp, args);

    //tableKelp.findOne(minCursor, maxCursor, whereKelp,
    //                  result.from((cursor,r)->remove(cursor,r)));
    
    BackupKelp backup = _table.getBackupCallback();
    
    if (isStaticNode()) {
      tableKelp.remove(minCursor, backup, (Result) result);
    }
    else {
      tableKelp.removeRange(minCursor, maxCursor, whereKelp, backup,
                            (Result) result);
    }
    
    // result.completed(null);
  }
833440
@Override
   public void process(Map<String, String> varMap, Writer out)
   {
      try
      {
         if (templateText == null)
         {
            templateText = Utils.readFileIntoString(input);
         }
         String replacedString = replace(varMap);
         out.write(replacedString);
         out.flush();
      }
      catch (IOException e)
      {
         e.printStackTrace();
      }
   }
1340988
private void executeScript(String script) {
        try {
            final StatementSplitter statementSplitter =
                new StatementSplitterResolver(scriptConfigurationInstance.get()).resolve();
            final ScriptExecutor scriptExecutor =
                new ScriptExecutor(databaseConnection.get().getConnection(), scriptConfigurationInstance.get(),
                    statementSplitter);
            scriptExecutor.execute(script);
        } catch (SQLException e) {
            throw new DBUnitConnectionException("Unable to execute script.", e);
        }
    }
809419
@SuppressWarnings("unchecked")
    private V report(int s) throws ExecutionException {
        Object x = outcome;
        if (s == NORMAL)
            return (V)x;
        if (s >= CANCELLED)
            throw new CancellationException();
        throw new ExecutionException((Throwable)x);
    }
521998
@Override
    public void execute()
            throws MojoExecutionException, MojoFailureException
        {
        boolean fExplicit = this.script != null;
        String  script    = fExplicit
                            ? this.script
                            : execution.getLifecyclePhase();

        String SCRIPT_NOT_FOUND = "Script '" + script + "' is not defined in package.json";

        Package pkg = getPackage();
        if (fExplicit && !pkg.hasScript(script))
            {
            getLog().error(SCRIPT_NOT_FOUND);
            throw new MojoFailureException(SCRIPT_NOT_FOUND);
            }
        else if (pkg.hasScript(script))
            {
            if (!fExplicit && script.endsWith("test") && skipTests)
                {
                getLog().info("Tests are skipped.");
                }
            else
                {
                CommandLine cmdLine = getNpmCommand();
                addCommand(cmdLine);
                cmdLine.addArgument(script);
                addArguments(cmdLine);

                execute(cmdLine);
                }
            }
        else
            {
            getLog().info(SCRIPT_NOT_FOUND);
            }
        }
1040471
protected function handleEventScriptResult(
        /** @noinspection PhpUnusedParameterInspection */
        $script,
        $result
    ) {
        if (array_get($result, 'stop_propagation', false)) {
            Log::info('  * Propagation stopped by script.');

            return false;
        }

        return true;
    }
304433
public static Result createResultForStage1(Result result) {
    VariableMap emptyVariableMap = new VariableMap(ImmutableMap.of());
    return new Result(
        result.errors,
        result.warnings,
        emptyVariableMap,
        emptyVariableMap,
        emptyVariableMap,
        null,
        null,
        "",
        null,
        null,
        null);
  }
577006
private Object getScriptResult(String script, ScriptEngine engine) throws ScriptException {
        String scriptToExecute = script.substring(script.indexOf(":") + 1);
        return engine.eval(scriptToExecute);
    }
970728
public static void validateResults(Map<Integer, Object> results) {
        for (Object result : results.values()) {
            if (result != null && result instanceof CacheClearResponse) {
                Object response = ((CacheClearResponse) result).getResponse();
                if (response instanceof Throwable) {
                    ExceptionUtil.sneakyThrow((Throwable) response);
                }
            }
        }
    }
685667
function declareResultCode(base, moduleCode, message, succeeded) {
        if (succeeded === void 0) { succeeded = false; }
        if (moduleCode <= 0 || CDP.MODULE_RESULT_CODE_RANGE <= moduleCode) {
            console.error("declareResultCode(), invalid localCode range. [localCode: " + moduleCode + "]");
            return;
        }
        var signed = succeeded ? 1 : -1;
        var resultCode = signed * (base + moduleCode);
        s_code2message[resultCode] = message ? message : ("[RESULT_CODE: " + resultCode + "]");
        return resultCode;
    }
1322432
public static Result failure(int code, String message) {
        return new Result(false, String.valueOf(code), message);
    }
447582
@Override
    public ExitMessage newExitMessage(final Object result, final Message message) {
        return new SimpleExitMessage(exitText, result, message);
    }
670155
private void encodeMapBody(StringBuffer result, JsJmsMapMessage msg) {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "encodeMapBody");
    // Internal method to get the map as a Map
    try {
      Map<String, Object> body = ((JsJmsMapMessageImpl)msg).getBodyMap();
      if (body.size() > 0) {
        result.append('~');
        Set<Map.Entry<String, Object>> entries = body.entrySet();
        boolean first = true;
        for (Iterator<Map.Entry<String, Object>> i = entries.iterator(); i.hasNext(); ) {
          Map.Entry<String, Object> entry = i.next();
          encodePair(result, entry.getKey(), entry.getValue(), first);
          first = false;
        }
      }
    }
    catch (UnsupportedEncodingException e) {
      FFDCFilter.processException(e, "com.ibm.ws.sib.mfp.impl.WebJsJmsMessageEncoderImpl.encodeMapBody", "269");
      // Just treat it as null.
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "encodeMapBody");
  }