Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move non-x86 tests to GHA #5088

Merged
merged 4 commits into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/test-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ jobs:
fail-fast: false
matrix:
docker: [
# Run slower jobs first to give them a headstart and reduce waiting time
ubuntu-20.04-focal-arm64v8,
ubuntu-20.04-focal-ppc64le,
ubuntu-20.04-focal-s390x,
# Then run the remainder
alpine,
amazon-2-amd64,
arch,
Expand All @@ -22,6 +27,13 @@ jobs:
ubuntu-20.04-focal-amd64,
]
dockerTag: [master]
include:
- docker: "ubuntu-20.04-focal-arm64v8"
qemu-arch: "aarch64"
- docker: "ubuntu-20.04-focal-ppc64le"
qemu-arch: "ppc64le"
- docker: "ubuntu-20.04-focal-s390x"
qemu-arch: "s390x"

name: ${{ matrix.docker }}

Expand All @@ -31,6 +43,11 @@ jobs:
- name: Build system information
run: python .github/workflows/system-info.py

- name: Set up QEMU
if: "matrix.qemu-arch"
run: |
docker run --rm --privileged aptman/qus -s -- -p ${{ matrix.qemu-arch }}

- name: Docker pull
run: |
docker pull pythonpillow/${{ matrix.docker }}:${{ matrix.dockerTag }}
Expand Down
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

6 changes: 6 additions & 0 deletions Tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ def is_big_endian():
return sys.byteorder == "big"


def is_ppc64le():
import platform

return platform.machine() == "ppc64le"


def is_win32():
return sys.platform.startswith("win32")

Expand Down
6 changes: 6 additions & 0 deletions Tests/test_file_libtiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
assert_image_similar,
assert_image_similar_tofile,
hopper,
is_big_endian,
skip_unless_feature,
)

Expand Down Expand Up @@ -813,11 +814,13 @@ def test_strip_cmyk_16l_jpeg(self):
with Image.open(infile) as im:
assert_image_similar_tofile(im, "Tests/images/pil_sample_cmyk.jpg", 0.5)

@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian")
def test_strip_ycbcr_jpeg_2x2_sampling(self):
infile = "Tests/images/tiff_strip_ycbcr_jpeg_2x2_sampling.tif"
with Image.open(infile) as im:
assert_image_similar_tofile(im, "Tests/images/flower.jpg", 0.5)

@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian")
def test_strip_ycbcr_jpeg_1x1_sampling(self):
infile = "Tests/images/tiff_strip_ycbcr_jpeg_1x1_sampling.tif"
with Image.open(infile) as im:
Expand All @@ -828,16 +831,19 @@ def test_tiled_cmyk_jpeg(self):
with Image.open(infile) as im:
assert_image_similar_tofile(im, "Tests/images/pil_sample_cmyk.jpg", 0.5)

@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian")
def test_tiled_ycbcr_jpeg_1x1_sampling(self):
infile = "Tests/images/tiff_tiled_ycbcr_jpeg_1x1_sampling.tif"
with Image.open(infile) as im:
assert_image_equal_tofile(im, "Tests/images/flower2.jpg")

@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian")
def test_tiled_ycbcr_jpeg_2x2_sampling(self):
infile = "Tests/images/tiff_tiled_ycbcr_jpeg_2x2_sampling.tif"
with Image.open(infile) as im:
assert_image_similar_tofile(im, "Tests/images/flower.jpg", 0.5)

@pytest.mark.xfail(is_big_endian(), reason="Fails on big-endian")
def test_old_style_jpeg(self):
infile = "Tests/images/old-style-jpeg-compression.tif"
with Image.open(infile) as im:
Expand Down
3 changes: 2 additions & 1 deletion Tests/test_image_quantize.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from PIL import Image

from .helper import assert_image, assert_image_similar, hopper
from .helper import assert_image, assert_image_similar, hopper, is_ppc64le


def test_sanity():
Expand All @@ -17,6 +17,7 @@ def test_sanity():
assert_image_similar(converted.convert("RGB"), image, 60)


@pytest.mark.xfail(is_ppc64le(), reason="failing on ppc64le on GHA")
def test_libimagequant_quantize():
image = hopper()
try:
Expand Down
64 changes: 17 additions & 47 deletions Tests/test_imagefont.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,6 @@
class TestImageFont:
LAYOUT_ENGINE = ImageFont.LAYOUT_BASIC

# Freetype has different metrics depending on the version.
# (and, other things, but first things first)
METRICS = {
(">=2.7",): {"multiline": 6.2, "textsize": 2.5, "getlength": (36, 21, 24, 33)},
"Default": {"multiline": 0.5, "textsize": 0.5, "getlength": (36, 24, 24, 33)},
}

@classmethod
def setup_class(self):
freetype = parse_version(features.version_module("freetype2"))

self.metrics = self.METRICS["Default"]
for conditions, metrics in self.METRICS.items():
if not isinstance(conditions, tuple):
continue

for condition in conditions:
version = parse_version(re.sub("[<=>]", "", condition))
if (condition.startswith(">=") and freetype >= version) or (
condition.startswith("<") and freetype < version
):
# Condition was met
continue

# Condition failed
break
else:
# All conditions were met
self.metrics = metrics

def get_font(self):
return ImageFont.truetype(
FONT_PATH, FONT_SIZE, layout_engine=self.LAYOUT_ENGINE
Expand Down Expand Up @@ -177,24 +147,24 @@ def test_textsize_equal(self):
with Image.open(target) as target_img:

# Epsilon ~.5 fails with FreeType 2.7
assert_image_similar(im, target_img, self.metrics["textsize"])
assert_image_similar(im, target_img, 2.5)

@pytest.mark.parametrize(
"text, mode, font, size, length_basic_index, length_raqm",
"text, mode, font, size, length_basic, length_raqm",
(
# basic test
("text", "L", "FreeMono.ttf", 15, 0, 36),
("text", "1", "FreeMono.ttf", 15, 0, 36),
("text", "L", "FreeMono.ttf", 15, 36, 36),
("text", "1", "FreeMono.ttf", 15, 36, 36),
# issue 4177
("rrr", "L", "DejaVuSans.ttf", 18, 1, 22.21875),
("rrr", "1", "DejaVuSans.ttf", 18, 2, 22.21875),
("rrr", "L", "DejaVuSans.ttf", 18, 21, 22.21875),
("rrr", "1", "DejaVuSans.ttf", 18, 24, 22.21875),
# test 'l' not including extra margin
# using exact value 2047 / 64 for raqm, checked with debugger
("ill", "L", "OpenSansCondensed-LightItalic.ttf", 63, 3, 31.984375),
("ill", "1", "OpenSansCondensed-LightItalic.ttf", 63, 3, 31.984375),
("ill", "L", "OpenSansCondensed-LightItalic.ttf", 63, 33, 31.984375),
("ill", "1", "OpenSansCondensed-LightItalic.ttf", 63, 33, 31.984375),
),
)
def test_getlength(self, text, mode, font, size, length_basic_index, length_raqm):
def test_getlength(self, text, mode, font, size, length_basic, length_raqm):
f = ImageFont.truetype(
"Tests/fonts/" + font, size, layout_engine=self.LAYOUT_ENGINE
)
Expand All @@ -204,7 +174,7 @@ def test_getlength(self, text, mode, font, size, length_basic_index, length_raqm

if self.LAYOUT_ENGINE == ImageFont.LAYOUT_BASIC:
length = d.textlength(text, f)
assert length == self.metrics["getlength"][length_basic_index]
assert length == length_basic
else:
# disable kerning, kerning metrics changed
length = d.textlength(text, f, features=["-kern"])
Expand All @@ -227,7 +197,7 @@ def test_render_multiline(self):
# some versions of freetype have different horizontal spacing.
# setting a tight epsilon, I'm showing the original test failure
# at epsilon = ~38.
assert_image_similar(im, target_img, self.metrics["multiline"])
assert_image_similar(im, target_img, 6.2)

def test_render_multiline_text(self):
ttf = self.get_font()
Expand All @@ -242,7 +212,7 @@ def test_render_multiline_text(self):
with Image.open(target) as target_img:

# Epsilon ~.5 fails with FreeType 2.7
assert_image_similar(im, target_img, self.metrics["multiline"])
assert_image_similar(im, target_img, 6.2)

# Test that text() can pass on additional arguments
# to multiline_text()
Expand All @@ -261,7 +231,7 @@ def test_render_multiline_text(self):
with Image.open(target) as target_img:

# Epsilon ~.5 fails with FreeType 2.7
assert_image_similar(im, target_img, self.metrics["multiline"])
assert_image_similar(im, target_img, 6.2)

def test_unknown_align(self):
im = Image.new(mode="RGB", size=(300, 100))
Expand Down Expand Up @@ -319,7 +289,7 @@ def test_multiline_spacing(self):
with Image.open(target) as target_img:

# Epsilon ~.5 fails with FreeType 2.7
assert_image_similar(im, target_img, self.metrics["multiline"])
assert_image_similar(im, target_img, 6.2)

def test_rotated_transposed_font(self):
img_grey = Image.new("L", (100, 100))
Expand Down Expand Up @@ -906,7 +876,7 @@ def test_standard_embedded_color(self):
d.text((10, 10), txt, font=ttf, fill="#fa6", embedded_color=True)

with Image.open("Tests/images/standard_embedded.png") as expected:
assert_image_similar(im, expected, max(self.metrics["multiline"], 3))
assert_image_similar(im, expected, 6.2)

@skip_unless_feature_version("freetype2", "2.5.0")
def test_cbdt(self):
Expand All @@ -923,7 +893,7 @@ def test_cbdt(self):
d.text((10, 10), "\U0001f469", embedded_color=True, font=font)

with Image.open("Tests/images/cbdt_notocoloremoji.png") as expected:
assert_image_similar(im, expected, self.metrics["multiline"])
assert_image_similar(im, expected, 6.2)
except IOError as e:
assert str(e) in ("unimplemented feature", "unknown file format")
pytest.skip("freetype compiled without libpng or unsupported")
Expand All @@ -943,7 +913,7 @@ def test_cbdt_mask(self):
d.text((10, 10), "\U0001f469", "black", font=font)

with Image.open("Tests/images/cbdt_notocoloremoji_mask.png") as expected:
assert_image_similar(im, expected, self.metrics["multiline"])
assert_image_similar(im, expected, 6.2)
except IOError as e:
assert str(e) in ("unimplemented feature", "unknown file format")
pytest.skip("freetype compiled without libpng or unsupported")
Expand Down