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:
Lovell Fuller 2016-02-11 18:30:50 +00:00
parent 6ca2a4a9cd
commit 2a56de69cc
10 changed files with 141 additions and 100 deletions

View File

@ -5,6 +5,7 @@
"maxcomplexity": 13, "maxcomplexity": 13,
"globals": { "globals": {
"before": true, "before": true,
"beforeEach": true,
"after": true, "after": true,
"describe": true, "describe": true,
"it": true "it": true

View File

@ -6,13 +6,13 @@ if ! type docker >/dev/null; then
exit 1 exit 1
fi 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 # Debian 7, 8
# Ubuntu 12.04, 14.04 # Ubuntu 12.04, 14.04
for dist in wheezy jessie precise trusty; do for dist in wheezy jessie precise trusty; do
echo "Testing $dist..." 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" then echo "$dist OK"
else echo "$dist fail" && cat packaging/$dist.log else echo "$dist fail" && cat packaging/$dist.log
fi fi
@ -20,7 +20,7 @@ done
# Centos 6 # Centos 6
echo "Testing centos6..." 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" then echo "centos6 OK"
else echo "centos6 fail" && cat packaging/centos6.log else echo "centos6 fail" && cat packaging/centos6.log
fi fi
@ -29,7 +29,7 @@ fi
# Fedora 20, 21 # Fedora 20, 21
for dist in centos7 fedora20 fedora21; do for dist in centos7 fedora20 fedora21; do
echo "Testing $dist..." 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" then echo "$dist OK"
else echo "$dist fail" && cat packaging/$dist.log else echo "$dist fail" && cat packaging/$dist.log
fi 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" then echo "archlinux OK"
else echo "archlinux fail" && cat packaging/archlinux.log else echo "archlinux fail" && cat packaging/archlinux.log
fi 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
View 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
View 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);
});

View File

@ -29,7 +29,7 @@ describe('Colour space conversion', function() {
.toFile(fixtures.path('output.greyscale-not.jpg'), done); .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) { it('From 1-bit TIFF to sRGB WebP [slow]', function(done) {
sharp(fixtures.inputTiff) sharp(fixtures.inputTiff)
.webp() .webp()

View File

@ -65,17 +65,19 @@ describe('Partial image extraction', function() {
}); });
} }
it('TIFF', function(done) { if (sharp.format.tiff.output.file) {
sharp(fixtures.inputTiff) it('TIFF', function(done) {
.extract({ left: 34, top: 63, width: 341, height: 529 }) sharp(fixtures.inputTiff)
.jpeg() .extract({ left: 34, top: 63, width: 341, height: 529 })
.toBuffer(function(err, data, info) { .jpeg()
if (err) throw err; .toBuffer(function(err, data, info) {
assert.strictEqual(341, info.width); if (err) throw err;
assert.strictEqual(529, info.height); assert.strictEqual(341, info.width);
fixtures.assertSimilar(fixtures.expected('extract.tiff'), data, done); assert.strictEqual(529, info.height);
}); fixtures.assertSimilar(fixtures.expected('extract.tiff'), data, done);
}); });
});
}
it('Before resize', function(done) { it('Before resize', function(done) {
sharp(fixtures.inputJpg) sharp(fixtures.inputJpg)

View File

@ -438,19 +438,21 @@ describe('Input/output', function() {
}); });
} }
it('Match TIFF input', function(done) { if (sharp.format.tiff.input.file) {
sharp(fixtures.inputTiff) it('Match TIFF input', function(done) {
.resize(320, 80) sharp(fixtures.inputTiff)
.toFile(fixtures.outputZoinks, function(err, info) { .resize(320, 80)
if (err) throw err; .toFile(fixtures.outputZoinks, function(err, info) {
assert.strictEqual(true, info.size > 0); if (err) throw err;
assert.strictEqual('tiff', info.format); assert.strictEqual(true, info.size > 0);
assert.strictEqual(320, info.width); assert.strictEqual('tiff', info.format);
assert.strictEqual(80, info.height); assert.strictEqual(320, info.width);
fs.unlinkSync(fixtures.outputZoinks); assert.strictEqual(80, info.height);
done(); fs.unlinkSync(fixtures.outputZoinks);
}); done();
}); });
});
}
it('Match GIF input, therefore fail', function(done) { it('Match GIF input, therefore fail', function(done) {
sharp(fixtures.inputGif) sharp(fixtures.inputGif)

View File

@ -55,22 +55,24 @@ describe('Image metadata', function() {
}); });
}); });
it('TIFF', function(done) { if (sharp.format.tiff.input.file) {
sharp(fixtures.inputTiff).metadata(function(err, metadata) { it('TIFF', function(done) {
if (err) throw err; sharp(fixtures.inputTiff).metadata(function(err, metadata) {
assert.strictEqual('tiff', metadata.format); if (err) throw err;
assert.strictEqual(2464, metadata.width); assert.strictEqual('tiff', metadata.format);
assert.strictEqual(3248, metadata.height); assert.strictEqual(2464, metadata.width);
assert.strictEqual('b-w', metadata.space); assert.strictEqual(3248, metadata.height);
assert.strictEqual(1, metadata.channels); assert.strictEqual('b-w', metadata.space);
assert.strictEqual(false, metadata.hasProfile); assert.strictEqual(1, metadata.channels);
assert.strictEqual(false, metadata.hasAlpha); assert.strictEqual(false, metadata.hasProfile);
assert.strictEqual('undefined', typeof metadata.orientation); assert.strictEqual(false, metadata.hasAlpha);
assert.strictEqual('undefined', typeof metadata.exif); assert.strictEqual('undefined', typeof metadata.orientation);
assert.strictEqual('undefined', typeof metadata.icc); assert.strictEqual('undefined', typeof metadata.exif);
done(); assert.strictEqual('undefined', typeof metadata.icc);
done();
});
}); });
}); }
it('PNG', function(done) { it('PNG', function(done) {
sharp(fixtures.inputPng).metadata(function(err, metadata) { sharp(fixtures.inputPng).metadata(function(err, metadata) {
@ -125,21 +127,23 @@ describe('Image metadata', function() {
}); });
} }
it('GIF via libmagick', function(done) { if (sharp.format.magick.input.file) {
sharp(fixtures.inputGif).metadata(function(err, metadata) { it('GIF via libmagick', function(done) {
if (err) throw err; sharp(fixtures.inputGif).metadata(function(err, metadata) {
assert.strictEqual('magick', metadata.format); if (err) throw err;
assert.strictEqual(800, metadata.width); assert.strictEqual('magick', metadata.format);
assert.strictEqual(533, metadata.height); assert.strictEqual(800, metadata.width);
assert.strictEqual(3, metadata.channels); assert.strictEqual(533, metadata.height);
assert.strictEqual(false, metadata.hasProfile); assert.strictEqual(3, metadata.channels);
assert.strictEqual(false, metadata.hasAlpha); assert.strictEqual(false, metadata.hasProfile);
assert.strictEqual('undefined', typeof metadata.orientation); assert.strictEqual(false, metadata.hasAlpha);
assert.strictEqual('undefined', typeof metadata.exif); assert.strictEqual('undefined', typeof metadata.orientation);
assert.strictEqual('undefined', typeof metadata.icc); assert.strictEqual('undefined', typeof metadata.exif);
done(); assert.strictEqual('undefined', typeof metadata.icc);
done();
});
}); });
}); }
if (sharp.format.openslide.input.file) { if (sharp.format.openslide.input.file) {
it('Aperio SVS via openslide', function(done) { it('Aperio SVS via openslide', function(done) {

View File

@ -128,27 +128,58 @@ describe('Resize dimensions', function() {
done(); done();
}); });
it('TIFF embed known to cause rounding errors', function(done) { if (sharp.format.tiff.input.file) {
sharp(fixtures.inputTiff).resize(240, 320).embed().jpeg().toBuffer(function(err, data, info) { it('TIFF embed known to cause rounding errors', function(done) {
if (err) throw err; sharp(fixtures.inputTiff)
assert.strictEqual(true, data.length > 0); .resize(240, 320)
assert.strictEqual('jpeg', info.format); .embed()
assert.strictEqual(240, info.width); .jpeg()
assert.strictEqual(320, info.height); .toBuffer(function(err, data, info) {
done(); 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) { it('TIFF known to cause rounding errors', function(done) {
sharp(fixtures.inputTiff).resize(240, 320).jpeg().toBuffer(function(err, data, info) { sharp(fixtures.inputTiff)
if (err) throw err; .resize(240, 320)
assert.strictEqual(true, data.length > 0); .jpeg()
assert.strictEqual('jpeg', info.format); .toBuffer(function(err, data, info) {
assert.strictEqual(240, info.width); if (err) throw err;
assert.strictEqual(320, info.height); assert.strictEqual(true, data.length > 0);
done(); 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) { it('Max width or height considering ratio (landscape)', function(done) {
sharp(fixtures.inputJpg).resize(320, 320).max().toBuffer(function(err, data, info) { 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) { it('Provide only one dimension with max, should default to crop', function(done) {
sharp(fixtures.inputJpg).resize(320).max().toBuffer(function(err, data, info) { sharp(fixtures.inputJpg).resize(320).max().toBuffer(function(err, data, info) {
if (err) throw err; 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) { it('Provide only one dimension with min, should default to crop', function(done) {
sharp(fixtures.inputJpg).resize(320).min().toBuffer(function(err, data, info) { sharp(fixtures.inputJpg).resize(320).min().toBuffer(function(err, data, info) {
if (err) throw err; if (err) throw err;

View File

@ -111,7 +111,7 @@ describe('Rotation', function() {
}); });
it('Attempt to auto-rotate image format without EXIF support', function(done) { it('Attempt to auto-rotate image format without EXIF support', function(done) {
sharp(fixtures.inputGif) sharp(fixtures.inputPng)
.rotate() .rotate()
.resize(320) .resize(320)
.jpeg() .jpeg()
@ -120,7 +120,7 @@ describe('Rotation', function() {
assert.strictEqual(true, data.length > 0); assert.strictEqual(true, data.length > 0);
assert.strictEqual('jpeg', info.format); assert.strictEqual('jpeg', info.format);
assert.strictEqual(320, info.width); assert.strictEqual(320, info.width);
assert.strictEqual(213, info.height); assert.strictEqual(236, info.height);
done(); done();
}); });
}); });