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,
"globals": {
"before": true,
"beforeEach": true,
"after": true,
"describe": true,
"it": true

View File

@ -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
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);
});
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()

View File

@ -65,6 +65,7 @@ describe('Partial image extraction', function() {
});
}
if (sharp.format.tiff.output.file) {
it('TIFF', function(done) {
sharp(fixtures.inputTiff)
.extract({ left: 34, top: 63, width: 341, height: 529 })
@ -76,6 +77,7 @@ describe('Partial image extraction', function() {
fixtures.assertSimilar(fixtures.expected('extract.tiff'), data, done);
});
});
}
it('Before resize', function(done) {
sharp(fixtures.inputJpg)

View File

@ -438,6 +438,7 @@ describe('Input/output', function() {
});
}
if (sharp.format.tiff.input.file) {
it('Match TIFF input', function(done) {
sharp(fixtures.inputTiff)
.resize(320, 80)
@ -451,6 +452,7 @@ describe('Input/output', function() {
done();
});
});
}
it('Match GIF input, therefore fail', function(done) {
sharp(fixtures.inputGif)

View File

@ -55,6 +55,7 @@ describe('Image metadata', function() {
});
});
if (sharp.format.tiff.input.file) {
it('TIFF', function(done) {
sharp(fixtures.inputTiff).metadata(function(err, metadata) {
if (err) throw err;
@ -71,6 +72,7 @@ describe('Image metadata', function() {
done();
});
});
}
it('PNG', function(done) {
sharp(fixtures.inputPng).metadata(function(err, metadata) {
@ -125,6 +127,7 @@ describe('Image metadata', function() {
});
}
if (sharp.format.magick.input.file) {
it('GIF via libmagick', function(done) {
sharp(fixtures.inputGif).metadata(function(err, metadata) {
if (err) throw err;
@ -140,6 +143,7 @@ describe('Image metadata', function() {
done();
});
});
}
if (sharp.format.openslide.input.file) {
it('Aperio SVS via openslide', function(done) {

View File

@ -128,8 +128,13 @@ describe('Resize dimensions', function() {
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) {
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);
@ -140,7 +145,10 @@ describe('Resize dimensions', function() {
});
it('TIFF known to cause rounding errors', function(done) {
sharp(fixtures.inputTiff).resize(240, 320).jpeg().toBuffer(function(err, data, info) {
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);
@ -150,17 +158,6 @@ describe('Resize dimensions', function() {
});
});
it('Max width or height considering ratio (landscape)', function(done) {
sharp(fixtures.inputJpg).resize(320, 320).max().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(261, 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;
@ -172,6 +169,29 @@ 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('Max width or height considering ratio (landscape)', function(done) {
sharp(fixtures.inputJpg).resize(320, 320).max().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(261, 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;

View File

@ -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();
});
});