Check result exit code against expectated exit code.

@param {Object} result: command execution result
@param {Object} test: test expectation
@return {Object} error if actual exit code doesn't equal expected exit code
336544
function _checkExitCode(result, test) {

  var actual = result.exitcode;
  var expect = test.exitcode;
  var error;

  if (typeof expect === 'string') {
    expect = parseInt(expect, 10);
  }

  if (expect !== undefined && expect !== actual) {
    error = util.format('Exit code %d does not match expected %d', actual, expect);
  }

  return error;
}
247689
def `(command)
      result    = super(command)
      exit_code = $?.to_i
      raise Error::CommandFailed.new(result, exit_code) unless exit_code == 0
      result
    end
150810
function _end(debug) {

  const DEBUG_FIELDS = ['exitcode', 'output', 'stdout', 'stderr'];

  var summary = util.format(
    '%d test%s, %d success%s, %d failure%s',
    successes.length + failures.length,
    (successes.length + failures.length > 1) ? 's' : '',
    successes.length,
    (successes.length > 1) ? 'es' : '',
    failures.length,
    (failures.length > 1) ? 's' : ''
  );

  console.log('');

  if (failures.length === 0) {
    console.log(summary.green);

  } else {

    failures.forEach(function (failure) {
      console.error(util.format('' +
          '\n----------------' +
          '\n%s%s' +
          '\n%s',
        failure.test.description ? failure.test.description + '\n' : '',
        failure.test.file.cyan,
        failure.test.command));

      failure.errors.forEach(function (error) {
        console.error(error.red);
      });

      if (debug) {
        console.error('exec dir: %s\n'.grey, failure.test.dir);

        DEBUG_FIELDS.forEach(function (field) {
          if (failure.test[field]) {
            console.error('%s: %s\n'.grey, field, failure.result[field]);
          }
        });
      }
    });

    console.error(summary.red);
  }

}
389090
def errback(self, result):
        

        assert(isinstance(result, BaseException))
        self._start_callbacks(result, True)
945568
function assertOut(key, expected, result) {
  var actual = result[key];
  var statement = expected instanceof RegExp
    ? expected.test(actual)
    : expected === actual;

  if (statement !== true) {
    var message = 'Expected ' + key +' to match "' + expected + '". Actual: "' + actual + '"';
    return error(result, message, expected, actual);
  }
}
935086
function(err) {
        if (err) { done(err); return; }
        var assert = require('assert');
        var difflet = require('difflet')({indent: 2, comment: true});
        try {
          assert.deepEqual(options.test.actual, options.expected, 'Actual should match expected.');
          grunt.log.writeln('Test passed.');
          done();
        } catch (err) {
          grunt.log.subhead('Assertion Failure');
          console.log(difflet.compare(err.expected, err.actual));
          done(err);
        }
      }
314253
def result(self, result):
        
        if result is None:
            raise ValueError("Invalid value for `result`, must not be `None`")  # noqa: E501
        allowed_values = ["OK", "ERROR"]  # noqa: E501
        if result not in allowed_values:
            raise ValueError(
                "Invalid value for `result` ({0}), must be one of {1}"  # noqa: E501
                .format(result, allowed_values)
            )

        self._result = result
746531
def check_valid_rx_can_msg(result):
    
    return (result.value == ReturnCode.SUCCESSFUL) or (result.value > ReturnCode.WARNING)
300554
def _analyze_result(self, exitcode, output, isTimeout, termination_reason):
        """"""

        # Ask tool info.
        tool_status = None
        if exitcode is not None:
            logging.debug("My subprocess returned %s.", exitcode)
            tool_status = self.runSet.benchmark.tool.determine_result(
                exitcode.value or 0, exitcode.signal or 0, output, isTimeout)

            if tool_status in result.RESULT_LIST_OTHER:
                # for unspecific results provide some more information if possible
                if exitcode.signal == 6:
                    tool_status = 'ABORTED'
                elif exitcode.signal == 11:
                    tool_status = 'SEGMENTATION FAULT'
                elif exitcode.signal == 15:
                    tool_status = 'KILLED'
                elif exitcode.signal:
                    tool_status = 'KILLED BY SIGNAL '+str(exitcode.signal)

                elif exitcode.value:
                    tool_status = '{} ({})'.format(result.RESULT_ERROR, exitcode.value)

        # Tools sometimes produce a result even after violating a resource limit.
        # This should not be counted, so we overwrite the result with TIMEOUT/OOM
        # here, if this is the case.
        # However, we don't want to forget more specific results like SEGFAULT,
        # so we do this only if the result is a "normal" one like TRUE/FALSE
        # or an unspecific one like UNKNOWN/ERROR.
        status = None
        if isTimeout:
            status = "TIMEOUT"
        elif termination_reason:
            status = _ERROR_RESULTS_FOR_TERMINATION_REASON.get(termination_reason, termination_reason)

        if not status:
            # regular termination
            status = tool_status
        elif tool_status and tool_status not in (
                result.RESULT_LIST_OTHER + [status, 'KILLED', 'KILLED BY SIGNAL 9']):
            # timeout/OOM but tool still returned some result
            status = '{} ({})'.format(status, tool_status)

        return status
30774
function Result(cmd, err, stdout, stderr) {
  this.cmd = cmd;
  this.err = err;
  this.stdout = strip(stdout);
  this.stderr = strip(stderr);
}
209950
function success(result, ignore) {
    return ((typeof result.error === 'undefined' &&
        typeof result.status === 'undefined' &&
        typeof result.success === 'undefined') ||
        (result.status && result.status === 'success') ||
        (result.success && result.success === true) ||
        (ignore && result.error && !ignore.test(result.error))) ? true : false;
}
590299
public function assertCommandResult($result) {
        $exitCode = $this->getExitCode();

        // Escape % as the callback will pass this value to sprintf() if the assertion fails, and
        // sprintf might complain about too few arguments as the output might contain stuff like %s
        // or %d.
        $output = str_replace('%', '%%', $this->getOutput());

        if ($result === 'fail') {
            $callback = 'notEq';
            $errorMessage = sprintf(
                'Invalid exit code, did not expect 0. Command output: %s',
                $output
            );
        } else {
            $callback = 'eq';
            $errorMessage = sprintf(
                'Expected exit code 0, got %d. Command output: %s',
                $exitCode,
                $output
            );
        }

        Assertion::$callback(0, $exitCode, $errorMessage);
    }
474286
def _check_result(self):
        '''
        
        '''
        if not self.__call_result:
            raise CommandExecutionError('No output result from Zypper?')

        self.exit_code = self.__call_result['retcode']
        if self._is_lock():
            return False

        if self._is_error():
            _error_msg = list()
            if not self._is_xml_mode():
                msg = self.__call_result['stderr'] and self.__call_result['stderr'].strip() or ""
                if msg:
                    _error_msg.append(msg)
            else:
                try:
                    doc = dom.parseString(self.__call_result['stdout'])
                except ExpatError as err:
                    log.error(err)
                    doc = None
                if doc:
                    msg_nodes = doc.getElementsByTagName('message')
                    for node in msg_nodes:
                        if node.getAttribute('type') == 'error':
                            _error_msg.append(node.childNodes[0].nodeValue)
                elif self.__call_result['stderr'].strip():
                    _error_msg.append(self.__call_result['stderr'].strip())
            self.error_msg = _error_msg
        return True
742465
function assertStd (result, std) {
    var message = 'Expected value to match following regexp: ' + std + ', but got: ' + result;

    if (typeof std === 'string' || typeof std === 'number') {
      assert.equal(result && result.code || result, std);
    }
    else if (std instanceof RegExp) {
      assert.isNotNull(result.match(std), message);
    }
    else if (typeof std === 'function') {
      assert.ok(std(result));
    }
    else if (typeof result !== 'string' && result !== null) {
      assert.equal(result.code, 0);
    }
  }
942346
function checkJs (mode, callback) {
  var exercise = this

  if (!exercise.passed)
    return callback(null, true) // shortcut if we've already had a failure

  gyp.rebuild(copyFauxTempDir, function (err) {
    if (err) {
      exercise.emit('fail', 'Compile mock C++ to test JavaScript: ' + err.message)
      return callback(null, false)
    }

    childProcess.exec(
          '"'
        + process.execPath
        + '" "'
        + copyFauxTempDir
        + '" "FAUX"'
      , function (err, stdout, stderr) {
          if (err) {
            process.stderr.write(stderr)
            process.stdout.write(stdout)
            return callback(err)
          }

          var pass = stdout.toString().replace('\r', '') == 'FAUX\n'
          if (!pass) {
            process.stderr.write(stderr)
            process.stdout.write(stdout)
          }
          exercise.emit(pass ? 'pass' : 'fail', 'JavaScript code loads addon and invokes `print(str)` method')

          callback(null, pass)
        }
    )
  })
}
697212
def command_output(command, expect_command = true)  #:doc:
      # get everything except for the ending prompt.
      ret =
          if (prompt_pos = (output =~ prompt_match))
            output[0...prompt_pos]
          else
            output
          end

      if expect_command
        command_regex = command_match(command)

        # Go until we run out of data or we find one of the possible command starts.
        # Note that we EXPECT the command to the first line of the output from the command because we expect the
        # shell to echo it back to us.
        result_cmd,_,result_data = ret.partition("\n")
        until result_data.to_s.strip == '' || result_cmd.strip =~ command_regex
          result_cmd,_,result_data = result_data.partition("\n")
        end

        if result_cmd.nil? || !(result_cmd =~ command_regex)
          STDERR.puts "SHELL WARNING: Failed to match #{command_regex.inspect}."
        end

        result_data
      else
        ret
      end
    end
82239
function (fn, repeatTest = 0, args = []) {
    let result, error

    /**
     * if a new hook gets executed we can assume that all commands should have finised
     * with exception of timeouts where `commandIsRunning` will never be reset but here
     */
    // commandIsRunning = false

    try {
        result = fn.apply(this, args)
    } catch (e) {
        error = e
    }

    /**
     * handle errors that get thrown directly and are not cause by
     * rejected promises
     */
    if (error) {
        if (repeatTest) {
            return executeAsync(fn, --repeatTest, args)
        }
        return new Promise((resolve, reject) => reject(error))
    }

    /**
     * if we don't retry just return result
     */
    if (repeatTest === 0 || !result || typeof result.catch !== 'function') {
        return new Promise(resolve => resolve(result))
    }

    /**
     * handle promise response
     */
    return result.catch((e) => {
        if (repeatTest) {
            return executeAsync(fn, --repeatTest, args)
        }

        e.stack = e.stack.split('\n').filter(STACKTRACE_FILTER_FN).join('\n')
        return Promise.reject(e)
    })
}