From 88ca973cacf596f00601d927b9ad367a51ec2865 Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Fri, 29 Mar 2019 19:49:37 +0100 Subject: [PATCH 1/6] Test Electron in Travis and AppVeyor --- .travis.yml | 17 +++++++++-------- appveyor.yml | 1 + package.json | 2 ++ test/electron.js | 21 +++++++++++++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 test/electron.js diff --git a/.travis.yml b/.travis.yml index 71ba60c7..17fda8ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,22 +4,22 @@ jobs: include: - os: linux node_js: 8 - env: [TEST_CMD=test] + env: [TEST=1] - os: linux node_js: 10 - env: [TEST_CMD=test] + env: [TEST=1] - os: linux node_js: node - env: [TEST_CMD=test, BUILD_CMD=prebuild, BUILD_GROUP=linux-x64] + env: [TEST=1, TEST_ELECTRON=1, BUILD_CMD=prebuild, BUILD_GROUP=linux-x64] - os: osx node_js: 8 - env: [TEST_CMD=test] + env: [TEST=1] - os: osx node_js: 10 - env: [TEST_CMD=test] + env: [TEST=1] - os: osx node_js: node - env: [TEST_CMD=test, BUILD_CMD=prebuild, BUILD_GROUP=darwin-x64] + env: [TEST=1, TEST_ELECTRON=1, BUILD_CMD=prebuild, BUILD_GROUP=darwin-x64] - name: arm os: linux node_js: node @@ -27,10 +27,11 @@ jobs: if: tag is present script: - - if [[ ! -z "$TEST_CMD" ]]; then npm run $TEST_CMD; fi + - if [[ ! -z "$TEST" ]]; then npm run test; fi + - if [[ ! -z "$TEST_ELECTRON" ]]; then npm run test-electron; fi after_success: - - if [[ ! -z "$TEST_CMD" ]]; then npm run coverage; fi + - if [[ ! -z "$TEST" ]]; then npm run coverage; fi before_deploy: - export ARCHIVE_NAME="${TRAVIS_TAG:-latest}-$BUILD_GROUP.tar.gz" diff --git a/appveyor.yml b/appveyor.yml index 465ef8a9..ece3de2b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -22,6 +22,7 @@ test_script: - node --version - npm --version - npm test + - ps: if ($env:nodejs_version -eq "Current") { npm run test-electron } before_deploy: - SET ARCHIVE_NAME=%APPVEYOR_REPO_TAG_NAME%-win32-%PLATFORM%.tar.gz diff --git a/package.json b/package.json index 0b3cfb8d..b19bd99a 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "install": "node-gyp-build", "test": "standard && nyc tape test/*-test.js", "test-gc": "npx -n=--expose-gc tape test/{cleanup,iterator-gc}*-test.js", + "test-electron": "electron test/electron.js", "coverage": "nyc report --reporter=text-lcov | coveralls", "rebuild": "node-gyp rebuild", "prebuild": "prebuildify -t 8.14.0 -t electron@3.0.0 --napi --strip", @@ -33,6 +34,7 @@ "delayed": "^1.0.1", "dependency-check": "^3.3.0", "du": "~0.1.0", + "electron": "^4.1.2", "hallmark": "^0.1.0", "level-community": "^3.0.0", "level-concat-iterator": "^2.0.0", diff --git a/test/electron.js b/test/electron.js new file mode 100644 index 00000000..086c5a94 --- /dev/null +++ b/test/electron.js @@ -0,0 +1,21 @@ +'use strict' + +const tape = require('tape') +const electron = require('electron') +const path = require('path') +const glob = require('glob') +const app = electron.app + +process.on('uncaughtException', function (err) { + console.error(err) + app.exit(1) +}) + +app.on('ready', function () { + tape.onFinish(() => app.quit()) + tape.onFailure(() => app.exit(1)) + + for (let file of glob.sync('test/*-test.js')) { + require(path.resolve('.', file)) + } +}) From 317e0453415aedc99e9f8885abf176d4a1ae61aa Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Fri, 29 Mar 2019 20:03:20 +0100 Subject: [PATCH 2/6] Try targeting 8.14.0 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b19bd99a..836f67ed 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,10 @@ "install": "node-gyp-build", "test": "standard && nyc tape test/*-test.js", "test-gc": "npx -n=--expose-gc tape test/{cleanup,iterator-gc}*-test.js", - "test-electron": "electron test/electron.js", + "test-electron": "npm run prebuild && electron test/electron.js", "coverage": "nyc report --reporter=text-lcov | coveralls", "rebuild": "node-gyp rebuild", - "prebuild": "prebuildify -t 8.14.0 -t electron@3.0.0 --napi --strip", + "prebuild": "prebuildify -t 8.14.0 --napi --strip", "download-prebuilds": "prebuildify-ci download", "hallmark": "hallmark --fix", "dependency-check": "dependency-check . test/*.js bench/*.js", From d1822d3ce4e649ecfff411d3cceaa10665440a2e Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Fri, 29 Mar 2019 20:24:49 +0100 Subject: [PATCH 3/6] Add xvfb to Linux job (not sure Travis supports nesting like this) --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index 17fda8ed..fc0dfd6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,13 @@ jobs: - os: linux node_js: node env: [TEST=1, TEST_ELECTRON=1, BUILD_CMD=prebuild, BUILD_GROUP=linux-x64] + addons: + apt: + packages: + - xvfb + install: + - export DISPLAY=':99.0' + - Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & - os: osx node_js: 8 env: [TEST=1] From 5b9bc3b1f98c54ee86eb271d10a67c3c240f50e2 Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Fri, 29 Mar 2019 20:29:56 +0100 Subject: [PATCH 4/6] Fix phase --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fc0dfd6a..c58f7ec1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ jobs: apt: packages: - xvfb - install: + before_script: - export DISPLAY=':99.0' - Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & - os: osx From 7a9f55d3c44f69e531b7c6ed784b27636786ef2d Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Fri, 29 Mar 2019 20:38:33 +0100 Subject: [PATCH 5/6] Revert "Try targeting 8.14.0" This reverts commit 317e0453415aedc99e9f8885abf176d4a1ae61aa. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 836f67ed..b19bd99a 100644 --- a/package.json +++ b/package.json @@ -8,10 +8,10 @@ "install": "node-gyp-build", "test": "standard && nyc tape test/*-test.js", "test-gc": "npx -n=--expose-gc tape test/{cleanup,iterator-gc}*-test.js", - "test-electron": "npm run prebuild && electron test/electron.js", + "test-electron": "electron test/electron.js", "coverage": "nyc report --reporter=text-lcov | coveralls", "rebuild": "node-gyp rebuild", - "prebuild": "prebuildify -t 8.14.0 --napi --strip", + "prebuild": "prebuildify -t 8.14.0 -t electron@3.0.0 --napi --strip", "download-prebuilds": "prebuildify-ci download", "hallmark": "hallmark --fix", "dependency-check": "dependency-check . test/*.js bench/*.js", From 7ec44bf66e50d71fa0d1861b4dbbf05732a50b84 Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Fri, 29 Mar 2019 20:39:47 +0100 Subject: [PATCH 6/6] Add missing glob devDependency --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index b19bd99a..db290c55 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "dependency-check": "^3.3.0", "du": "~0.1.0", "electron": "^4.1.2", + "glob": "^7.1.3", "hallmark": "^0.1.0", "level-community": "^3.0.0", "level-concat-iterator": "^2.0.0",