Example #1
0
    def run_test(self, filename, n_doc = 1, total_docs = 1):
        if filename in self._skip:
            doc_path = os.path.join(self._docsdir, filename)
            self._skipped.append("%s" % (doc_path))
            print("Skipping test '%s' (%d/%d)" % (doc_path, n_doc, total_docs))
            return

        out_path = os.path.join(self._outdir, filename)
        try:
            os.makedirs(out_path)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise
        except:
            raise
        doc_path = os.path.join(self._docsdir, filename)
        refs_path = os.path.join(self._refsdir, filename)

        if not os.path.isdir(refs_path):
            self._skipped.append("%s" % (doc_path))
            print("Reference dir not found for %s, skipping (%d/%d)" % (doc_path, n_doc, total_docs))
            return

        if self.config.backends:
            backends = [get_backend(name) for name in self.config.backends]
        else:
            backends = get_all_backends()

        for backend in backends:
            self.test(refs_path, doc_path, out_path, backend, n_doc, total_docs)
Example #2
0
    def create_refs_for_file(self, filename, n_doc = 1, total_docs = 1):
        if filename in self._skipped:
            print("Skipping test '%s' (%d/%d)" % (os.path.join(self._docsdir, filename), n_doc, total_docs))
            return

        refs_path = os.path.join(self._refsdir, filename)
        try:
            os.makedirs(refs_path)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise
        except:
            raise
        doc_path = os.path.join(self._docsdir, filename)

        if self.config.backends:
            backends = [get_backend(name) for name in self.config.backends]
        else:
            backends = get_all_backends()

        for backend in backends:
            if not self.config.force and backend.has_results(refs_path):
                print("Results found, skipping '%s' for %s backend (%d/%d)" % (doc_path, backend.get_name(), n_doc, total_docs))
                continue
            print("Creating refs for '%s' using %s backend (%d/%d)" % (doc_path, backend.get_name(), n_doc, total_docs))
            if backend.create_refs(doc_path, refs_path):
                backend.create_checksums(refs_path, self.config.checksums_only)
Example #3
0
    def _get_backends(self):
        if self.config.backends:
            return [get_backend(name) for name in self.config.backends]

        return get_all_backends()
Example #4
0
def main(args):
    n_cpus = cpu_count()

    parser = argparse.ArgumentParser(
        description = 'Poppler regression tests',
        prog = 'poppler-regtest',
        usage = '%(prog)s [options ...] command [command-options ...] tests',
        add_help = False)
    parser.add_argument('-h', '--help',
                        action = HelpAction, nargs = 0)
    parser.add_argument('--help-command', metavar = 'COMMAND',
                        action = HelpAction,
                        help = 'Show help for a given command')
    parser.add_argument('-v', '--verbose',
                        action = 'store_true', dest = 'verbose', default = False,
                        help = 'Run in verbose mode')
    parser.add_argument('--utils-dir',
                        action = 'store', dest = 'utils_dir', default = os.path.abspath("../utils"),
                        help = 'Directory of poppler utils used for the tests')
    parser.add_argument('-b', '--backends',
                        action = ListAction, dest = 'backends',
                        help = 'List of backends that will be used (separated by comma)')
    parser.add_argument('--skip', metavar = 'FILE',
                        action = 'store', dest = 'skipped_file',
                        help = 'File containing tests to skip')
    parser.add_argument('-p', '--passwords', metavar = 'FILE',
                        action = 'store', dest = 'passwords_file',
                        help = 'File containing the documents passwords')
    parser.add_argument('-t', '--threads',
                        action = 'store', dest = 'threads', type = int, default = n_cpus,
                        help = 'Number of worker threads (Default: %d)' % n_cpus)

    ns, args = parser.parse_known_args(args)
    if not args:
        parser.print_help()
        sys.exit(0)

    c = Config(vars(ns))

    if c.threads <= 0:
        c.threads = n_cpus - c.threads

    try:
        return commands.run(args)
    except commands.UnknownCommandError:
        sys.stderr.write("Unknown command: %s\n" % (args[0]))
        commands.print_help()
        return 1
    except backends.UnknownBackendError as e:
        sys.stderr.write(str(e) + "\n")
        sys.stdout.write("Backends are: %s\n" % (", ".join([backend.get_name() for backend in backends.get_all_backends()])))
        return 1
Example #5
0
def main(args):
    n_cpus = cpu_count()

    parser = argparse.ArgumentParser(
        description="Poppler regression tests",
        prog="poppler-regtest",
        usage="%(prog)s [options ...] command [command-options ...] tests",
        add_help=False,
    )
    parser.add_argument("-h", "--help", action=HelpAction, nargs=0)
    parser.add_argument("--help-command", metavar="COMMAND", action=HelpAction, help="Show help for a given command")
    parser.add_argument(
        "-v", "--verbose", action="store_true", dest="verbose", default=False, help="Run in verbose mode"
    )
    parser.add_argument(
        "--utils-dir",
        action="store",
        dest="utils_dir",
        default=os.path.abspath("../utils"),
        help="Directory of poppler utils used for the tests",
    )
    parser.add_argument(
        "-b",
        "--backends",
        action=ListAction,
        dest="backends",
        help="List of backends that will be used (separated by comma)",
    )
    parser.add_argument(
        "--skip", metavar="FILE", action="store", dest="skipped_file", help="File containing tests to skip"
    )
    parser.add_argument(
        "-t",
        "--threads",
        action="store",
        dest="threads",
        type=int,
        default=n_cpus,
        help="Number of worker threads (Default: %d)" % n_cpus,
    )

    ns, args = parser.parse_known_args(args)
    if not args:
        parser.print_help()
        sys.exit(0)

    c = Config(vars(ns))

    if c.threads <= 0:
        c.threads = n_cpus - c.threads

    try:
        commands.run(args)
    except commands.UnknownCommandError:
        sys.stderr.write("Unknown command: %s\n" % (args[0]))
        commands.print_help()
        sys.exit(1)
    except backends.UnknownBackendError as e:
        sys.stderr.write(str(e) + "\n")
        sys.stdout.write(
            "Backends are: %s\n" % (", ".join([backend.get_name() for backend in backends.get_all_backends()]))
        )
        sys.exit(1)
Example #6
0
    def create(self, launch_browser):
        html = "<html><body><a name='top'></a>"
        if self.config.backends:
            backends = [get_backend(name) for name in self.config.backends]
        else:
            backends = get_all_backends()

        results = {}
        for root, dirs, files in os.walk(self._outdir, False):
            if not files:
                continue
            if not root.lower().endswith('.pdf'):
                continue
            if root.startswith(self._htmldir):
                continue

            results[root] = TestResult(self._docsdir, self._refsdir, self._outdir, root, files, backends)

        tests = results.keys()
        tests.sort()

        failed_anchors = []
        failed = ""
        crashed = ""
        failed_to_run = ""
        for test_name in tests:
            test = results[test_name]
            if test.is_failed():
                failed_anchors.append(test.get_test())
                failed += test.get_failed_html()
            crashed += test.get_crashed_html()
            failed_to_run += test.get_failed_to_run_html()

        if failed:
            failed = "<h1><a name='failed'>Tests Failed (differences were found)</name></h1>\n%s" % (failed)
        if crashed:
            crashed = "<h1><a name='crashed'>Tests Crashed</a></h1>\n%s" % (crashed)
        if failed_to_run:
            failed_to_run = "<h1><a name='failed_to_run'>Tests that failed to run (command returned an error status)</a></h1>\n%s" % (failed_to_run)

        if failed or crashed or failed_to_run:
            html += "<ul>\n"
            if failed:
                html += "<li><a href='#failed'>Tests Failed (differences were found)</a></li>\n<ul>"
                for anchor in failed_anchors:
                    html += "<li><a href='#%s'>%s</a></li>" % (anchor, anchor)
                html += "</ul>\n"
            if crashed:
                html += "<li><a href='#crashed'>Tests Crashed(differences were found)</a></li>\n"
            if failed_to_run:
                html += "<li><a href='#failed_to_run'>Tests that failed to run (command returned an error status)</a></li>\n"
            html += "</ul>\n"

        html += failed + crashed + failed_to_run + "</body></html>"

        report_index = os.path.join(self._htmldir, 'index.html')
        f = open(report_index, 'wb')
        f.write(html)
        f.close()

        if launch_browser:
            subprocess.Popen(['xdg-open', report_index])
Example #7
0
def main(args):
    parser = argparse.ArgumentParser(
        description = 'Poppler regression tests',
        prog = 'poppler-regtest',
        usage = '%(prog)s [options ...] command [command-options ...] tests',
        add_help = False)
    parser.add_argument('-h', '--help',
                        action = HelpAction, nargs = 0)
    parser.add_argument('--help-command', metavar = 'COMMAND',
                        action = HelpAction,
                        help = 'Show help for a given command')
    parser.add_argument('--utils-dir',
                        action = 'store', dest = 'utils_dir', default = os.path.abspath("../utils"),
                        help = 'Directory of poppler utils used for the tests')
    parser.add_argument('-b', '--backends',
                        action = ListAction, dest = 'backends',
                        help = 'List of backends that will be used (separated by comma)')
    parser.add_argument('--skip', metavar = 'FILE',
                        action = 'store', dest = 'skipped_file',
                        help = 'File containing tests to skip')

    ns, args = parser.parse_known_args(args)
    if not args:
        parser.print_help()
        sys.exit(0)

    Config(vars(ns))
    try:
        commands.run(args)
    except commands.UnknownCommandError:
        sys.stderr.write("Unknown command: %s\n" % (args[0]))
        commands.print_help()
        sys.exit(1)
    except backends.UnknownBackendError as e:
        sys.stderr.write(str(e) + "\n")
        sys.stdout.write("Backends are: %s\n" % (", ".join([backend.get_name() for backend in backends.get_all_backends()])))
        sys.exit(1)
Example #8
0
def main(args):
    n_cpus = cpu_count()

    parser = argparse.ArgumentParser(
        description='Poppler regression tests',
        prog='poppler-regtest',
        usage='%(prog)s [options ...] command [command-options ...] tests',
        add_help=False)
    parser.add_argument('-h', '--help', action=HelpAction, nargs=0)
    parser.add_argument('--help-command',
                        metavar='COMMAND',
                        action=HelpAction,
                        help='Show help for a given command')
    parser.add_argument('-v',
                        '--verbose',
                        action='store_true',
                        dest='verbose',
                        default=False,
                        help='Run in verbose mode')
    parser.add_argument('--utils-dir',
                        action='store',
                        dest='utils_dir',
                        default=os.path.abspath("../utils"),
                        help='Directory of poppler utils used for the tests')
    parser.add_argument(
        '-b',
        '--backends',
        action=ListAction,
        dest='backends',
        help='List of backends that will be used (separated by comma)')
    parser.add_argument('--skip',
                        metavar='FILE',
                        action='store',
                        dest='skipped_file',
                        help='File containing tests to skip')
    parser.add_argument('-t',
                        '--threads',
                        action='store',
                        dest='threads',
                        type=int,
                        default=n_cpus,
                        help='Number of worker threads (Default: %d)' % n_cpus)

    ns, args = parser.parse_known_args(args)
    if not args:
        parser.print_help()
        sys.exit(0)

    c = Config(vars(ns))

    if c.threads <= 0:
        c.threads = n_cpus - c.threads

    try:
        commands.run(args)
    except commands.UnknownCommandError:
        sys.stderr.write("Unknown command: %s\n" % (args[0]))
        commands.print_help()
        sys.exit(1)
    except backends.UnknownBackendError as e:
        sys.stderr.write(str(e) + "\n")
        sys.stdout.write("Backends are: %s\n" % (", ".join(
            [backend.get_name() for backend in backends.get_all_backends()])))
        sys.exit(1)
Example #9
0
    def _get_backends(self):
        if self.config.backends:
            return [get_backend(name) for name in self.config.backends]

        return get_all_backends()