예제 #1
0
 def run(self, outfile=None):
     ''' Load urls, run checks and make report, '''
     # pylint: disable=bare-except
     started_at = time.time()
     self.log.debug('fedora-review ' + __version__ + ' ' +
                    BUILD_FULL + ' started')
     self.log.debug("Command  line: " + ' '.join(sys.argv))
     try:
         rcode = 0
         self._do_run(outfile)
     except ReviewError as err:
         if isinstance(err, SpecParseReviewError):
             nvr = _Nvr(self.bug.get_name())
             result = SimpleTestResult("SpecFileParseError",
                                       "Can't parse the spec file: ",
                                       str(err))
             write_xml_report(nvr, [result])
         self.log.debug("ReviewError: " + str(err), exc_info=True)
         if not err.silent:
             msg = 'ERROR: ' + str(err)
             if err.show_logs:
                 msg += ' (logs in ' + Settings.session_log + ')'
             self.log.error(msg)
         rcode = err.exitcode
     except:
         self.log.debug("Exception down the road...", exc_info=True)
         self.log.error('Exception down the road...'
                        '(logs in ' + Settings.session_log + ')')
         rcode = 1
     self.log.debug("Report completed:  %.3f seconds"
                    % (time.time() - started_at))
     return rcode
예제 #2
0
 def run(self, outfile=None):
     ''' Load urls, run checks and make report, '''
     # pylint: disable=bare-except
     started_at = time.time()
     self.log.debug('fedora-review ' + __version__ + ' ' + BUILD_FULL +
                    ' started')
     self.log.debug("Command  line: " + ' '.join(sys.argv))
     try:
         rcode = 0
         self._do_run(outfile)
     except ReviewError as err:
         if isinstance(err, SpecParseReviewError):
             nvr = _Nvr(self.bug.get_name())
             result = SimpleTestResult("SpecFileParseError",
                                       "Can't parse the spec file: ",
                                       str(err))
             write_xml_report(nvr, [result])
         self.log.debug("ReviewError: " + str(err), exc_info=True)
         if not err.silent:
             msg = 'ERROR: ' + str(err)
             if err.show_logs:
                 msg += ' (logs in ' + Settings.session_log + ')'
             self.log.error(msg)
         rcode = err.exitcode
     except:
         self.log.debug("Exception down the road...", exc_info=True)
         self.log.error('Exception down the road...'
                        '(logs in ' + Settings.session_log + ')')
         rcode = 1
     self.log.debug("Report completed:  %.3f seconds" %
                    (time.time() - started_at))
     return rcode
예제 #3
0
    def run_checks(self, output=sys.stdout, writedown=True):
        ''' Run all checks. '''

        def run_check(name):
            """ Run check. Update results, attachments and issues. """
            check = self.checkdict[name]
            if check.is_run:
                return
            self.log.debug('Running check: ' + name)
            check.run()
            now = time.time()
            self.log.debug('    %s completed: %.3f seconds'
                               % (name, (now - self._clock)))
            self._clock = now
            attachments.extend(check.attachments)
            result = check.result
            if not result:
                return
            results.append(result)
            if result.type == 'MUST' and result.result == "fail":
                issues.append(result)

        issues = []
        results = []
        attachments = []
        has_deprecated = False

        tests_to_run = self._get_ready_to_run()
        self._clock = time.time()
        while tests_to_run != []:
            for name in tests_to_run:
                if self.checkdict[name].deprecates and not has_deprecated:
                    self.deprecate()
                    has_deprecated = True
                    break
                run_check(name)
            tests_to_run = self._get_ready_to_run()

        if writedown:
            key_getter = attrgetter('group', 'type', 'name')
            write_template(output,
                           sorted(results, key=key_getter),
                           issues,
                           attachments)
            write_xml_report(self.spec, results)
        else:
            with open('.testlog.txt', 'w') as f:
                for r in results:
                    f.write('\n' + 24 * ' '
                            + "('%s', '%s')," % (r.state, r.name))
예제 #4
0
    def run_checks(self, output=sys.stdout, writedown=True):
        ''' Run all checks. '''
        def run_check(name):
            """ Run check. Update results, attachments and issues. """
            check = self.checkdict[name]
            if check.is_run:
                return
            self.log.debug('Running check: ' + name)
            check.run()
            now = time.time()
            self.log.debug('    %s completed: %.3f seconds' %
                           (name, (now - self._clock)))
            self._clock = now
            attachments.extend(check.attachments)
            result = check.result
            if not result:
                return
            results.append(result)
            if result.type == 'MUST' and result.result == "fail":
                issues.append(result)

        issues = []
        results = []
        attachments = []
        has_deprecated = False

        tests_to_run = self._get_ready_to_run()
        self._clock = time.time()
        while tests_to_run != []:
            for name in tests_to_run:
                if self.checkdict[name].deprecates and not has_deprecated:
                    self.deprecate()
                    has_deprecated = True
                    break
                run_check(name)
            tests_to_run = self._get_ready_to_run()

        if writedown:
            key_getter = attrgetter('group', 'type', 'name')
            write_template(output, sorted(results, key=key_getter), issues,
                           attachments)
            write_xml_report(self.spec, results)
        else:
            with open('.testlog.txt', 'w') as f:
                for r in results:
                    f.write('\n' + 24 * ' ' + "('%s', '%s')," %
                            (r.state, r.name))