mirror of
https://github.com/lovell/sharp.git
synced 2025-07-12 03:50:13 +02:00
Add Alpine Linux packaging test #354
Requires libvips cache to be disabled for tests Skip tiff/magick tests when format unavailable
This commit is contained in:
parent
6ca2a4a9cd
commit
2a56de69cc
@ -5,6 +5,7 @@
|
||||
"maxcomplexity": 13,
|
||||
"globals": {
|
||||
"before": true,
|
||||
"beforeEach": true,
|
||||
"after": true,
|
||||
"describe": true,
|
||||
"it": true
|
||||
|
@ -6,13 +6,13 @@ if ! type docker >/dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
test="npm run clean; NODE_ENV=development npm install --unsafe-perm; npm test"
|
||||
test="npm run clean; npm install --unsafe-perm; npm test"
|
||||
|
||||
# Debian 7, 8
|
||||
# Ubuntu 12.04, 14.04
|
||||
for dist in wheezy jessie precise trusty; do
|
||||
echo "Testing $dist..."
|
||||
if docker run -i -t --rm -v $PWD:/v nodesource/$dist:0.12 >packaging/$dist.log 2>&1 sh -c "cd /v; ./packaging/test/debian.sh; $test";
|
||||
if docker run -i -t --rm -v $PWD:/v -e "NODE_ENV=development" nodesource/$dist:0.12 >packaging/$dist.log 2>&1 sh -c "cd /v; ./packaging/test/debian.sh; $test";
|
||||
then echo "$dist OK"
|
||||
else echo "$dist fail" && cat packaging/$dist.log
|
||||
fi
|
||||
@ -20,7 +20,7 @@ done
|
||||
|
||||
# Centos 6
|
||||
echo "Testing centos6..."
|
||||
if docker run -i -t --rm -v $PWD:/v nodesource/centos6:0.12 >packaging/centos6.log 2>&1 sh -c "cd /v; source ./packaging/test/centos6.sh; ./preinstall.sh; $test";
|
||||
if docker run -i -t --rm -v $PWD:/v -e "NODE_ENV=development" nodesource/centos6:0.12 >packaging/centos6.log 2>&1 sh -c "cd /v; source ./packaging/test/centos6.sh; ./preinstall.sh; $test";
|
||||
then echo "centos6 OK"
|
||||
else echo "centos6 fail" && cat packaging/centos6.log
|
||||
fi
|
||||
@ -29,7 +29,7 @@ fi
|
||||
# Fedora 20, 21
|
||||
for dist in centos7 fedora20 fedora21; do
|
||||
echo "Testing $dist..."
|
||||
if docker run -i -t --rm -v $PWD:/v nodesource/$dist:0.12 >packaging/$dist.log 2>&1 sh -c "cd /v; $test";
|
||||
if docker run -i -t --rm -v $PWD:/v -e "NODE_ENV=development" nodesource/$dist:0.12 >packaging/$dist.log 2>&1 sh -c "cd /v; $test";
|
||||
then echo "$dist OK"
|
||||
else echo "$dist fail" && cat packaging/$dist.log
|
||||
fi
|
||||
@ -48,3 +48,10 @@ if docker run -i -t --rm -v $PWD:/v base/archlinux:2015.06.01 >packaging/archlin
|
||||
then echo "archlinux OK"
|
||||
else echo "archlinux fail" && cat packaging/archlinux.log
|
||||
fi
|
||||
|
||||
# Alpine
|
||||
echo "Testing alpine..."
|
||||
if docker run -i -t --rm -v $PWD:/v -e "SHARP_TEST_WITHOUT_CACHE=0" wjordan/libvips >packaging/alpine.log 2>&1 sh -c "cd /v; ./packaging/test/alpine.sh; $test";
|
||||
then echo "alpine OK"
|
||||
else echo "alpine fail" && cat packaging/alpine.log
|
||||
fi
|
||||
|
7
packaging/test/alpine.sh
Executable file
7
packaging/test/alpine.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Install Node.js
|
||||
apk add --update make gcc g++ python nodejs
|
||||
|
||||
# Install libvips dependencies
|
||||
apk add --update glib-dev libpng-dev libwebp-dev libexif-dev libxml2-dev orc-dev fftw-dev lcms2-dev
|
9
test/unit/cache.js
Normal file
9
test/unit/cache.js
Normal file
@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var sharp = require('../../index');
|
||||
|
||||
// Define SHARP_TEST_WITHOUT_CACHE environment variable to prevent use of libvips' cache
|
||||
|
||||
beforeEach(function() {
|
||||
sharp.cache(process.env.SHARP_TEST_WITHOUT_CACHE ? false : true);
|
||||
});
|
@ -29,7 +29,7 @@ describe('Colour space conversion', function() {
|
||||
.toFile(fixtures.path('output.greyscale-not.jpg'), done);
|
||||
});
|
||||
|
||||
if (sharp.format.webp.output.buffer) {
|
||||
if (sharp.format.tiff.input.file && sharp.format.webp.output.buffer) {
|
||||
it('From 1-bit TIFF to sRGB WebP [slow]', function(done) {
|
||||
sharp(fixtures.inputTiff)
|
||||
.webp()
|
||||
|
@ -65,17 +65,19 @@ describe('Partial image extraction', function() {
|
||||
});
|
||||
}
|
||||
|
||||
it('TIFF', function(done) {
|
||||
sharp(fixtures.inputTiff)
|
||||
.extract({ left: 34, top: 63, width: 341, height: 529 })
|
||||
.jpeg()
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(341, info.width);
|
||||
assert.strictEqual(529, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('extract.tiff'), data, done);
|
||||
});
|
||||
});
|
||||
if (sharp.format.tiff.output.file) {
|
||||
it('TIFF', function(done) {
|
||||
sharp(fixtures.inputTiff)
|
||||
.extract({ left: 34, top: 63, width: 341, height: 529 })
|
||||
.jpeg()
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(341, info.width);
|
||||
assert.strictEqual(529, info.height);
|
||||
fixtures.assertSimilar(fixtures.expected('extract.tiff'), data, done);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
it('Before resize', function(done) {
|
||||
sharp(fixtures.inputJpg)
|
||||
|
@ -438,19 +438,21 @@ describe('Input/output', function() {
|
||||
});
|
||||
}
|
||||
|
||||
it('Match TIFF input', function(done) {
|
||||
sharp(fixtures.inputTiff)
|
||||
.resize(320, 80)
|
||||
.toFile(fixtures.outputZoinks, function(err, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, info.size > 0);
|
||||
assert.strictEqual('tiff', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(80, info.height);
|
||||
fs.unlinkSync(fixtures.outputZoinks);
|
||||
done();
|
||||
});
|
||||
});
|
||||
if (sharp.format.tiff.input.file) {
|
||||
it('Match TIFF input', function(done) {
|
||||
sharp(fixtures.inputTiff)
|
||||
.resize(320, 80)
|
||||
.toFile(fixtures.outputZoinks, function(err, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, info.size > 0);
|
||||
assert.strictEqual('tiff', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(80, info.height);
|
||||
fs.unlinkSync(fixtures.outputZoinks);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
it('Match GIF input, therefore fail', function(done) {
|
||||
sharp(fixtures.inputGif)
|
||||
|
@ -55,22 +55,24 @@ describe('Image metadata', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('TIFF', function(done) {
|
||||
sharp(fixtures.inputTiff).metadata(function(err, metadata) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('tiff', metadata.format);
|
||||
assert.strictEqual(2464, metadata.width);
|
||||
assert.strictEqual(3248, metadata.height);
|
||||
assert.strictEqual('b-w', metadata.space);
|
||||
assert.strictEqual(1, metadata.channels);
|
||||
assert.strictEqual(false, metadata.hasProfile);
|
||||
assert.strictEqual(false, metadata.hasAlpha);
|
||||
assert.strictEqual('undefined', typeof metadata.orientation);
|
||||
assert.strictEqual('undefined', typeof metadata.exif);
|
||||
assert.strictEqual('undefined', typeof metadata.icc);
|
||||
done();
|
||||
if (sharp.format.tiff.input.file) {
|
||||
it('TIFF', function(done) {
|
||||
sharp(fixtures.inputTiff).metadata(function(err, metadata) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('tiff', metadata.format);
|
||||
assert.strictEqual(2464, metadata.width);
|
||||
assert.strictEqual(3248, metadata.height);
|
||||
assert.strictEqual('b-w', metadata.space);
|
||||
assert.strictEqual(1, metadata.channels);
|
||||
assert.strictEqual(false, metadata.hasProfile);
|
||||
assert.strictEqual(false, metadata.hasAlpha);
|
||||
assert.strictEqual('undefined', typeof metadata.orientation);
|
||||
assert.strictEqual('undefined', typeof metadata.exif);
|
||||
assert.strictEqual('undefined', typeof metadata.icc);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
it('PNG', function(done) {
|
||||
sharp(fixtures.inputPng).metadata(function(err, metadata) {
|
||||
@ -125,21 +127,23 @@ describe('Image metadata', function() {
|
||||
});
|
||||
}
|
||||
|
||||
it('GIF via libmagick', function(done) {
|
||||
sharp(fixtures.inputGif).metadata(function(err, metadata) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('magick', metadata.format);
|
||||
assert.strictEqual(800, metadata.width);
|
||||
assert.strictEqual(533, metadata.height);
|
||||
assert.strictEqual(3, metadata.channels);
|
||||
assert.strictEqual(false, metadata.hasProfile);
|
||||
assert.strictEqual(false, metadata.hasAlpha);
|
||||
assert.strictEqual('undefined', typeof metadata.orientation);
|
||||
assert.strictEqual('undefined', typeof metadata.exif);
|
||||
assert.strictEqual('undefined', typeof metadata.icc);
|
||||
done();
|
||||
if (sharp.format.magick.input.file) {
|
||||
it('GIF via libmagick', function(done) {
|
||||
sharp(fixtures.inputGif).metadata(function(err, metadata) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('magick', metadata.format);
|
||||
assert.strictEqual(800, metadata.width);
|
||||
assert.strictEqual(533, metadata.height);
|
||||
assert.strictEqual(3, metadata.channels);
|
||||
assert.strictEqual(false, metadata.hasProfile);
|
||||
assert.strictEqual(false, metadata.hasAlpha);
|
||||
assert.strictEqual('undefined', typeof metadata.orientation);
|
||||
assert.strictEqual('undefined', typeof metadata.exif);
|
||||
assert.strictEqual('undefined', typeof metadata.icc);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (sharp.format.openslide.input.file) {
|
||||
it('Aperio SVS via openslide', function(done) {
|
||||
|
@ -128,27 +128,58 @@ describe('Resize dimensions', function() {
|
||||
done();
|
||||
});
|
||||
|
||||
it('TIFF embed known to cause rounding errors', function(done) {
|
||||
sharp(fixtures.inputTiff).resize(240, 320).embed().jpeg().toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(240, info.width);
|
||||
assert.strictEqual(320, info.height);
|
||||
done();
|
||||
if (sharp.format.tiff.input.file) {
|
||||
it('TIFF embed known to cause rounding errors', function(done) {
|
||||
sharp(fixtures.inputTiff)
|
||||
.resize(240, 320)
|
||||
.embed()
|
||||
.jpeg()
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(240, info.width);
|
||||
assert.strictEqual(320, info.height);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('TIFF known to cause rounding errors', function(done) {
|
||||
sharp(fixtures.inputTiff).resize(240, 320).jpeg().toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(240, info.width);
|
||||
assert.strictEqual(320, info.height);
|
||||
done();
|
||||
it('TIFF known to cause rounding errors', function(done) {
|
||||
sharp(fixtures.inputTiff)
|
||||
.resize(240, 320)
|
||||
.jpeg()
|
||||
.toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(240, info.width);
|
||||
assert.strictEqual(320, info.height);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('Max width or height considering ratio (portrait)', function(done) {
|
||||
sharp(fixtures.inputTiff).resize(320, 320).max().jpeg().toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(243, info.width);
|
||||
assert.strictEqual(320, info.height);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Min width or height considering ratio (portrait)', function(done) {
|
||||
sharp(fixtures.inputTiff).resize(320, 320).min().jpeg().toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(422, info.height);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
it('Max width or height considering ratio (landscape)', function(done) {
|
||||
sharp(fixtures.inputJpg).resize(320, 320).max().toBuffer(function(err, data, info) {
|
||||
@ -161,17 +192,6 @@ describe('Resize dimensions', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Max width or height considering ratio (portrait)', function(done) {
|
||||
sharp(fixtures.inputTiff).resize(320, 320).max().jpeg().toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(243, info.width);
|
||||
assert.strictEqual(320, info.height);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Provide only one dimension with max, should default to crop', function(done) {
|
||||
sharp(fixtures.inputJpg).resize(320).max().toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
@ -194,17 +214,6 @@ describe('Resize dimensions', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('Min width or height considering ratio (portrait)', function(done) {
|
||||
sharp(fixtures.inputTiff).resize(320, 320).min().jpeg().toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(422, info.height);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('Provide only one dimension with min, should default to crop', function(done) {
|
||||
sharp(fixtures.inputJpg).resize(320).min().toBuffer(function(err, data, info) {
|
||||
if (err) throw err;
|
||||
|
@ -111,7 +111,7 @@ describe('Rotation', function() {
|
||||
});
|
||||
|
||||
it('Attempt to auto-rotate image format without EXIF support', function(done) {
|
||||
sharp(fixtures.inputGif)
|
||||
sharp(fixtures.inputPng)
|
||||
.rotate()
|
||||
.resize(320)
|
||||
.jpeg()
|
||||
@ -120,7 +120,7 @@ describe('Rotation', function() {
|
||||
assert.strictEqual(true, data.length > 0);
|
||||
assert.strictEqual('jpeg', info.format);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(213, info.height);
|
||||
assert.strictEqual(236, info.height);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user