From ad25afe2f9a0d990b99879f21c34d6076b7bff29 Mon Sep 17 00:00:00 2001 From: Albin Mattsson Date: Sun, 22 May 2016 18:29:35 +0200 Subject: [PATCH] Add Travis configuration This closes #108 --- .travis.yml | 11 +++++++++++ package.json | 1 + test/api.js | 12 +++++++----- test/lib/visually-verify-image.js | 32 ++++++++++++++++++++++++++----- 4 files changed, 46 insertions(+), 10 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..8b49feb --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: node_js +osx_image: xcode7.3 +os: + - osx +node_js: + - 6 +script: + - sw_vers -productVersion + - defaults write NSGlobalDomain AppleShowAllExtensions -bool true + - killall Finder + - npm test diff --git a/package.json b/package.json index a8c4bc8..e4ccb0b 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ }, "devDependencies": { "capture-window": "^0.1.3", + "imgur": "^0.1.7", "looks-same": "^2.1.0", "mocha": "^2.2.5", "standard": "^7.0.1" diff --git a/test/api.js b/test/api.js index f0b2987..88daff3 100644 --- a/test/api.js +++ b/test/api.js @@ -11,6 +11,8 @@ var assert = require('assert') var STEPS = 20 +var CI_PREFIX = process.env.TRAIVS ? 'travis-' : '' + function runAppdmg (opts, verify, cb) { var progressCalled = 0 var ee = appdmg(opts) @@ -56,7 +58,7 @@ describe('api', function () { var verify = { format: 'UDZO', title: 'Test Title', - visually: 'accepted-1.png' + visually: CI_PREFIX + 'accepted-1.png' } runAppdmg(opts, verify, done) @@ -73,7 +75,7 @@ describe('api', function () { var verify = { format: 'UDZO', title: 'Test Title', - visually: 'accepted-1.png' + visually: CI_PREFIX + 'accepted-1.png' } runAppdmg(opts, verify, done) @@ -100,7 +102,7 @@ describe('api', function () { var verify = { format: 'UDZO', title: 'Test Title', - visually: 'accepted-1.png' + visually: CI_PREFIX + 'accepted-1.png' } runAppdmg(opts, verify, done) @@ -128,7 +130,7 @@ describe('api', function () { var verify = { format: 'UDRO', title: 'Test Title', - visually: 'accepted-1.png' + visually: CI_PREFIX + 'accepted-1.png' } runAppdmg(opts, verify, done) @@ -145,7 +147,7 @@ describe('api', function () { var verify = { format: 'UDZO', title: 'Test Title', - visually: 'accepted-2.png' + visually: CI_PREFIX + 'accepted-2.png' } runAppdmg(opts, verify, done) diff --git a/test/lib/visually-verify-image.js b/test/lib/visually-verify-image.js index 1631f30..e2097ae 100644 --- a/test/lib/visually-verify-image.js +++ b/test/lib/visually-verify-image.js @@ -4,6 +4,7 @@ var looksSame = require('looks-same') var spawnSync = require('child_process').spawnSync var captureWindow = require('capture-window') var sizeOf = require('image-size') +var imgur = require('imgur') var hdiutil = require('../../lib/hdiutil') @@ -63,11 +64,32 @@ function captureAndSaveDiff (title, expectedPath, cb) { looksSame.createDiff(opts, function (err, data) { if (err) return cb(err) - temp.writeFile(data, function (err, diffPath) { - if (err) return cb(err) - - cb(null, { diff: diffPath, actual: pngPath }) - }) + if (process.env.CI) { + imgur.uploadFile(pngPath) + .then(function (json) { + const pngUrl = json.data.link + imgur.uploadBase64(data.toString('base64')) + .then(function (json) { + cb(null, { diff: json.data.link, actual: pngUrl }) + }) + .catch(function (err) { + setImmediate(function () { + cb(err) + }) + }) + }) + .catch(function (err) { + setImmediate(function () { + cb(err) + }) + }) + } else { + temp.writeFile(data, function (err, diffPath) { + if (err) return cb(err) + + cb(null, { diff: diffPath, actual: pngPath }) + }) + } }) }) }