mirror of
https://github.com/nextcloud/server.git
synced 2026-07-11 10:36:08 -04:00
Merge pull request #61873 from nextcloud/backport/61858/stable34
[stable34] test: fix HEIC tests
This commit is contained in:
commit
eefefe589e
2 changed files with 36 additions and 9 deletions
16
.github/workflows/phpunit-sqlite.yml
vendored
16
.github/workflows/phpunit-sqlite.yml
vendored
|
|
@ -90,9 +90,23 @@ jobs:
|
|||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Enable HEIC support in ImageMagick
|
||||
run: |
|
||||
# The HEIC preview tests need ImageMagick to actually decode HEIC files.
|
||||
# GitHub-hosted runners register the HEIC coder (so the tests are not
|
||||
# skipped) but decoding fails because the libheif delegate is missing
|
||||
# and/or the coder is blocked by ImageMagick's security policy. Install
|
||||
# the delegate and allow the HEIC/HEIF/AVIF coders so decoding succeeds.
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends libheif1 libheif-dev
|
||||
for policy in /etc/ImageMagick-{6,7}/policy.xml; do
|
||||
if [ -f "$policy" ]; then
|
||||
sudo sed -i -E 's/rights="none" pattern="(HEIC|HEIF|AVIF)"/rights="read|write" pattern="\1"/g' "$policy"
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Set up dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ghostscript
|
||||
composer i
|
||||
|
||||
|
|
|
|||
|
|
@ -21,14 +21,27 @@ class HEICTest extends Provider {
|
|||
protected function setUp(): void {
|
||||
if (!in_array('HEIC', \Imagick::queryFormats('HEI*'))) {
|
||||
$this->markTestSkipped('ImageMagick is not HEIC aware. Skipping tests');
|
||||
} else {
|
||||
parent::setUp();
|
||||
|
||||
$fileName = 'testimage.heic';
|
||||
$this->imgPath = $this->prepareTestFile($fileName, \OC::$SERVERROOT . '/tests/data/' . $fileName);
|
||||
$this->width = 1680;
|
||||
$this->height = 1050;
|
||||
$this->provider = new HEIC;
|
||||
}
|
||||
|
||||
$fileName = 'testimage.heic';
|
||||
$sourcePath = \OC::$SERVERROOT . '/tests/data/' . $fileName;
|
||||
|
||||
// queryFormats() only reports that the HEIC coder is registered, not that
|
||||
// ImageMagick can actually decode a HEIC file: the libheif delegate may be
|
||||
// missing or the coder may be disabled by ImageMagick's policy.xml. In that
|
||||
// case decoding throws, the provider returns null and the tests fail instead
|
||||
// of being skipped. Verify a real decode before running the tests.
|
||||
try {
|
||||
(new \Imagick())->readImage($sourcePath . '[0]');
|
||||
} catch (\ImagickException $e) {
|
||||
$this->markTestSkipped('ImageMagick cannot decode HEIC in this environment: ' . $e->getMessage() . '. Skipping tests');
|
||||
}
|
||||
|
||||
parent::setUp();
|
||||
|
||||
$this->imgPath = $this->prepareTestFile($fileName, $sourcePath);
|
||||
$this->width = 1680;
|
||||
$this->height = 1050;
|
||||
$this->provider = new HEIC;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue