diff --git a/.cirrus.yml b/.cirrus.yml new file mode 100644 index 00000000..1ea79391 --- /dev/null +++ b/.cirrus.yml @@ -0,0 +1,13 @@ +freebsd_instance: + image_family: freebsd-12-0 + +task: + prerequisites_script: + - sed -i '' 's/quarterly/latest/g' /etc/pkg/FreeBSD.conf + - pkg update -f + - pkg upgrade -y + - pkg install -y pkgconf vips libnghttp2 node npm + install_script: + - npm install --unsafe-perm + test_script: + - npm test diff --git a/binding.gyp b/binding.gyp index a20c3f41..3a189384 100644 --- a/binding.gyp +++ b/binding.gyp @@ -183,16 +183,22 @@ }, 'configurations': { 'Release': { - 'cflags_cc': [ - '-Wno-cast-function-type' - ], - 'msvs_settings': { - 'VCCLCompilerTool': { - 'ExceptionHandling': 1 - } - }, - 'msvs_disabled_warnings': [ - 4275 + 'conditions': [ + ['OS == "linux"', { + 'cflags_cc': [ + '-Wno-cast-function-type' + ] + }], + ['OS == "win"', { + 'msvs_settings': { + 'VCCLCompilerTool': { + 'ExceptionHandling': 1 + } + }, + 'msvs_disabled_warnings': [ + 4275 + ] + }] ] } }, diff --git a/package.json b/package.json index b08ca7f9..719e3229 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "scripts": { "install": "(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)", "clean": "rm -rf node_modules/ build/ vendor/ .nyc_output/ coverage/ test/fixtures/output.*", - "test": "semistandard && cc && npm run test-unit && npm run test-licensing && prebuild-ci", + "test": "semistandard && cpplint && npm run test-unit && npm run test-licensing && prebuild-ci", "test-unit": "nyc --reporter=lcov --branches=99 mocha --slow=5000 --timeout=60000 ./test/unit/*.js", "test-licensing": "license-checker --production --summary --onlyAllow=\"Apache-2.0;BSD;ISC;MIT\"", "test-coverage": "./test/coverage/report.sh", @@ -118,7 +118,7 @@ }, "devDependencies": { "async": "^3.1.0", - "cc": "^1.0.2", + "cc": "^2.0.1", "decompress-zip": "^0.3.2", "documentation": "^12.1.3", "exif-reader": "^1.0.3", diff --git a/test/unit/tiff.js b/test/unit/tiff.js index 97e71bd4..a5bf0208 100644 --- a/test/unit/tiff.js +++ b/test/unit/tiff.js @@ -2,6 +2,7 @@ const fs = require('fs'); const assert = require('assert'); +const promisify = require('util').promisify; const rimraf = require('rimraf'); const sharp = require('../../'); @@ -150,40 +151,40 @@ describe('TIFF', function () { }); }); - it('TIFF setting xres and yres on file', function (done) { - const res = 1000.0; // inputTiff has a dpi of 300 (res*2.54) + it('TIFF setting xres and yres on file', () => sharp(fixtures.inputTiff) .tiff({ - xres: (res), - yres: (res) + xres: 1000, + yres: 1000 }) - .toFile(fixtures.outputTiff, (err, info) => { - if (err) throw err; - assert.strictEqual('tiff', info.format); - sharp(fixtures.outputTiff).metadata(function (err, metadata) { - if (err) throw err; - assert.strictEqual(metadata.density, res * 2.54); // convert to dpi - rimraf(fixtures.outputTiff, done); - }); - }); - }); + .toFile(fixtures.outputTiff) + .then(() => sharp(fixtures.outputTiff) + .metadata() + .then(({ density }) => { + assert.strictEqual(true, + density === 2540 || // libvips <= 8.8.2 + density === 25400); // libvips >= 8.8.3 + return promisify(rimraf)(fixtures.outputTiff); + }) + ) + ); - it('TIFF setting xres and yres on buffer', function (done) { - const res = 1000.0; // inputTiff has a dpi of 300 (res*2.54) + it('TIFF setting xres and yres on buffer', () => sharp(fixtures.inputTiff) .tiff({ - xres: (res), - yres: (res) + xres: 1000, + yres: 1000 }) - .toBuffer(function (err, data, info) { - if (err) throw err; - sharp(data).metadata(function (err, metadata) { - if (err) throw err; - assert.strictEqual(metadata.density, res * 2.54); // convert to dpi - done(); - }); - }); - }); + .toBuffer() + .then(data => sharp(data) + .metadata() + .then(({ density }) => { + assert.strictEqual(true, + density === 2540 || // libvips <= 8.8.2 + density === 25400); // libvips >= 8.8.3 + }) + ) + ); it('TIFF invalid xres value should throw an error', function () { assert.throws(function () {