Esempio n. 1
0
def _get_pdiff(example):
    img_path, ref_path, diff_path = example.img_path, example.ref_path, example.diff_path
    trace("generated image: " + img_path)

    ref = example.fetch_ref()

    if not ref:
        warn("reference image %s doesn't exist" % example.ref_url)
    else:
        ref_dir = dirname(ref_path)
        if not exists(ref_dir):
            os.makedirs(ref_dir)

        with open(ref_path, "wb") as f:
            f.write(ref)

        trace("saved reference: " + ref_path)

        example.pixels = image_diff(diff_path, img_path, ref_path)
        if example.pixels != 0:
            comment = "dimensions don't match" if example.pixels == -1 else white(
                "%.02f%%" % example.pixels) + " of pixels"
            warn("generated and reference images differ: %s" % comment)
        else:
            ok("generated and reference images match")
Esempio n. 2
0
def _print_phantomjs_output(result):
    errors = result['errors']
    messages = result['messages']
    resources = result['resources']

    for message in messages:
        msg = message['msg']
        line = message.get('line')
        source = message.get('source')

        if source is None:
            write(msg)
        elif line is None:
            write("%s: %s" % (source, msg))
        else:
            write("%s:%s: %s" % (source, line, msg))

    # Process resources
    for resource in resources:
        url = resource['url']
        if url.endswith(".png"):
            ok("%s: %s (%s)" % (url, yellow(resource['status']), resource['statusText']))
        else:
            warn("Resource error:: %s: %s (%s)" % (url, red(resource['status']), resource['statusText']))

    # You can have a successful test, and still have errors reported, so not failing here.
    for error in errors:
        warn("%s: %s" % (red("PhatomJS Error: "), error['msg']))
        for item in error['trace']:
            write("    %s: %d" % (item['file'], item['line']))
Esempio n. 3
0
def _print_phantomjs_output(result):
    errors = result['errors']
    messages = result['messages']
    resources = result['resources']

    for message in messages:
        msg = message['msg']
        line = message.get('line')
        source = message.get('source')

        if source and line:
            msg = "%s:%s: %s" % (source, line, msg)

        info(msg, label="JS")

    # Process resources
    for resource in resources:
        url = resource['url']
        if url.endswith(".png"):
            ok("%s: %s (%s)" %
               (url, yellow(resource['status']), resource['statusText']))
        else:
            fail("Resource error:: %s: %s (%s)" %
                 (url, red(resource['status']), resource['statusText']),
                 label="JS")

    # You can have a successful test, and still have errors reported, so not failing here.
    for error in errors:
        fail(error['msg'], label="JS")
        for item in error['trace']:
            file = item['file']
            line = item['line']

            if file and line:
                fail("  %s: %d" % (file, line), label="JS")
Esempio n. 4
0
def _get_pdiff(example, diff):
    test_png, ref_png, diff_png = get_example_pngs(example, diff)
    info("generated image: " + test_png)

    retrieved_reference_image = _get_reference_image_from_s3(example, diff)

    if retrieved_reference_image:
        ref_png_path = dirname(ref_png)
        if not exists(ref_png_path):
            os.makedirs(ref_png_path)

        with open(ref_png, "wb") as f:
            f.write(retrieved_reference_image)

        info("saved reference: " + ref_png)

        code = process_image_diff(diff_png, test_png, ref_png)
        if code != 0:
            warn("generated and reference images differ")
            warn("diff: " + diff_png)
        else:
            ok("generated and reference images match")
Esempio n. 5
0
def _get_pdiff(example):
    img_path, ref_path, diff_path = example.img_path, example.ref_path, example.diff_path
    trace("generated image: " + img_path)

    ref = example.fetch_ref()

    if not ref:
        warn("reference image %s doesn't exist" % example.ref_url)
    else:
        ref_dir = dirname(ref_path)
        if not exists(ref_dir):
            os.makedirs(ref_dir)

        with open(ref_path, "wb") as f:
            f.write(ref)

        trace("saved reference: " + ref_path)

        example.pixels = image_diff(diff_path, img_path, ref_path)
        if example.pixels != 0:
            comment = "dimensions don't match" if example.pixels == -1 else white("%.02f%%" % example.pixels) + " of pixels"
            warn("generated and reference images differ: %s" % comment)
        else:
            ok("generated and reference images match")