From b9e9eba15e37db160a454fec1c3884cf0c5b0a28 Mon Sep 17 00:00:00 2001 From: Evgeniy Generalov Date: Sat, 7 Apr 2018 11:32:47 +0300 Subject: [PATCH 1/6] fix: tests aren't running on Windows see https://github.com/gotwarlost/istanbul/issues/13 for more details --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index dbe5e01d7..12c7817cd 100644 --- a/package.json +++ b/package.json @@ -55,11 +55,11 @@ "standard-version": "^4.0.0" }, "scripts": { - "test-unit": "istanbul test _mocha -- --recursive test/unit", + "test-unit": "istanbul test node_modules/mocha/bin/_mocha -- --recursive test/unit", "postpublish": "npm run publish-site", - "test-func": "istanbul test _mocha test/functional", - "test-browser": "istanbul test _mocha test/browser", - "test": "istanbul test _mocha -- --recursive test/unit test/functional test/browser", + "test-func": "istanbul test node_modules/mocha/bin/_mocha test/functional", + "test-browser": "istanbul test node_modules/mocha/bin/_mocha test/browser", + "test": "istanbul test node_modules/mocha/bin/_mocha -- --recursive test/unit test/functional test/browser", "lint": "eslint .", "release": "standard-version", "precommit": "npm run lint", From ea66320d582e93890b1a277540ec9a3c19d41ccb Mon Sep 17 00:00:00 2001 From: Evgeniy Generalov Date: Sat, 7 Apr 2018 14:03:44 +0300 Subject: [PATCH 2/6] fix: windows --- lib/runner/browser-runner/index.js | 6 +++--- lib/utils.js | 6 ++++++ test/unit/browser-config.test.js | 11 ++++++----- test/unit/config-options/config-options.test.js | 17 +++++++++-------- test/unit/config/index.js | 11 ++++++----- test/unit/tests-api/index.js | 6 ++++-- 6 files changed, 34 insertions(+), 23 deletions(-) diff --git a/lib/runner/browser-runner/index.js b/lib/runner/browser-runner/index.js index 357e7c750..2faa932a0 100644 --- a/lib/runner/browser-runner/index.js +++ b/lib/runner/browser-runner/index.js @@ -2,11 +2,11 @@ const _ = require('lodash'); const url = require('url'); -const path = require('path'); const {BrowserAgent, promiseUtils} = require('gemini-core'); const Runner = require('../runner'); const SuiteRunner = require('../suite-runner'); const Events = require('../../constants/events'); +const urlJoin = require('../../utils').urlJoin; module.exports = class BrowserRunner extends Runner { constructor(browserId, config, browserPool) { @@ -46,9 +46,9 @@ module.exports = class BrowserRunner extends Runner { _mkFullUrl(suiteUrl) { const rootUrl = this._config.rootUrl; - const urlObj = url.parse(rootUrl + '/' + suiteUrl); + const urlObj = url.parse(urlJoin(rootUrl, suiteUrl)); - return path.resolve(path.normalize(urlObj.path)); + return urlObj.path; } _runSuite(suite, stateProcessor) { diff --git a/lib/utils.js b/lib/utils.js index c25c89150..253405cf7 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,4 +1,5 @@ 'use strict'; +const _ = require('lodash'); exports.requireWithNoCache = function(moduleName) { delete require.cache[moduleName]; @@ -10,3 +11,8 @@ exports.logger = { warn: console.warn, error: console.error }; + +exports.urlJoin = (...args) => + args + .map((value, index) => (index ? _.trim : _.trimEnd)(value, '/')) + .join('/'); diff --git a/test/unit/browser-config.test.js b/test/unit/browser-config.test.js index ea5b7f6c4..9975d6fcc 100644 --- a/test/unit/browser-config.test.js +++ b/test/unit/browser-config.test.js @@ -1,6 +1,7 @@ 'use strict'; var BrowserConfig = require('lib/config/browser-config'), - createSuite = require('lib/suite').create; + createSuite = require('lib/suite').create, + path = require('path'); describe('BrowserConfig', function() { function createConfig(options) { @@ -33,7 +34,7 @@ describe('BrowserConfig', function() { suite = createSuite('suite'), dir = config.getScreenshotsDir(suite, 'state'); - assert.equal(dir, '/screens/suite/state'); + assert.equal(dir, path.resolve('/screens/suite/state')); }); it('should return path for nested suite and state', function() { @@ -42,7 +43,7 @@ describe('BrowserConfig', function() { child = createSuite('child', parent), dir = config.getScreenshotsDir(child, 'state'); - assert.equal(dir, '/screens/parent/child/state'); + assert.equal(dir, path.resolve('/screens/parent/child/state')); }); }); @@ -52,8 +53,8 @@ describe('BrowserConfig', function() { screenshotsDir: '/screens' }), suite = createSuite('suite'), - path = config.getScreenshotPath(suite, 'state'); - assert.equal(path, '/screens/suite/state/browser.png'); + screenshotPath = config.getScreenshotPath(suite, 'state'); + assert.equal(screenshotPath, path.resolve('/screens/suite/state/browser.png')); }); }); }); diff --git a/test/unit/config-options/config-options.test.js b/test/unit/config-options/config-options.test.js index c25821fc6..3bfa618af 100644 --- a/test/unit/config-options/config-options.test.js +++ b/test/unit/config-options/config-options.test.js @@ -3,6 +3,7 @@ var Config = require('lib/config'), parser = require('lib/config/options'), GeminiError = require('lib/errors/gemini-error'), MissingOptionError = require('gemini-configparser').MissingOptionError, + path = require('path'), _ = require('lodash'); describe('config', function() { @@ -290,7 +291,7 @@ describe('config', function() { projectRoot: './rel/path' } }); - assert.equal(config.system.projectRoot, '/some/path/rel/path'); + assert.equal(config.system.projectRoot, path.resolve('/some/path/rel/path')); }); it('should leave absolute path unchanged', function() { @@ -300,7 +301,7 @@ describe('config', function() { } }); - assert.equal(config.system.projectRoot, '/some/absolute/path'); + assert.equal(config.system.projectRoot, path.resolve('/some/absolute/path')); }); }); @@ -312,7 +313,7 @@ describe('config', function() { } }); - assert.equal(config.system.sourceRoot, '/some/absolute/path'); + assert.equal(config.system.sourceRoot, path.resolve('/some/absolute/path')); }); it('should resolve relative paths relatively to projectRoot', function() { @@ -322,10 +323,10 @@ describe('config', function() { sourceRoot: './rel/path' } }); - assert.equal(config.system.sourceRoot, '/root/rel/path'); + assert.equal(config.system.sourceRoot, path.resolve('/root/rel/path')); }); - it('should leave absolute path unchanged', function() { + it('should normalize absolute path', function() { var config = createConfig({ system: { projectRoot: '/root', @@ -333,7 +334,7 @@ describe('config', function() { } }); - assert.equal(config.system.sourceRoot, '/some/absolute/path'); + assert.equal(config.system.sourceRoot, path.resolve('/some/absolute/path')); }); }); @@ -764,12 +765,12 @@ describe('config', function() { var config = createBrowserConfig({ screenshotsDir: 'screens' }); - assert.equal(config.screenshotsDir, '/some/path/screens'); + assert.equal(config.screenshotsDir, path.resolve('/some/path/screens')); }); it('should be gemini/screens by default', function() { var config = createBrowserConfig({}); - assert.equal(config.screenshotsDir, '/some/path/gemini/screens'); + assert.equal(config.screenshotsDir, path.resolve('/some/path/gemini/screens')); }); //TODO: toplevel diff --git a/test/unit/config/index.js b/test/unit/config/index.js index c489c85a9..0eb092b6e 100644 --- a/test/unit/config/index.js +++ b/test/unit/config/index.js @@ -1,6 +1,7 @@ 'use strict'; var Config = require('lib/config'), configReader = require('lib/config/config-reader'), + path = require('path'), _ = require('lodash'); describe('config', function() { @@ -59,23 +60,23 @@ describe('config', function() { }); it('should not override anything by default', function() { - assert.equal(this.getFinalConfigValue(), this.configValue); + assert.equal(this.getFinalConfigValue(), path.resolve(this.configValue)); }); it('should not override value with env if allowOverredies.env is false', function() { - assert.equal(this.getFinalConfigValue({env: false}), this.configValue); + assert.equal(this.getFinalConfigValue({env: false}), path.resolve(this.configValue)); }); it('should override value with env if allowOverredies.env is true', function() { - assert.equal(this.getFinalConfigValue({env: true}), this.envValue); + assert.equal(this.getFinalConfigValue({env: true}), path.resolve(this.envValue)); }); it('should not override value with cli if allowOverredies.cli is false', function() { - assert.equal(this.getFinalConfigValue({cli: false}), this.configValue); + assert.equal(this.getFinalConfigValue({cli: false}), path.resolve(this.configValue)); }); it('should override value with cli if allowOverredies.cli is true', function() { - assert.equal(this.getFinalConfigValue({cli: true}), this.cliValue); + assert.equal(this.getFinalConfigValue({cli: true}), path.resolve(this.cliValue)); }); }); diff --git a/test/unit/tests-api/index.js b/test/unit/tests-api/index.js index 1a380d5a9..db7c696ef 100644 --- a/test/unit/tests-api/index.js +++ b/test/unit/tests-api/index.js @@ -1,5 +1,6 @@ 'use strict'; +const path = require('path'); const testsAPI = require('lib/tests-api'); const Suite = require('lib/suite'); @@ -194,6 +195,7 @@ describe('tests-api', () => { describe('file path', () => { const file = '/root/path/file.js'; const relativeFile = 'path/file.js'; + const osPath = unixPath => unixPath.split('/').join(path.sep); beforeEach(() => { gemini = testsAPI(rootSuite, [], file, {system: {projectRoot: '/root'}}); @@ -202,7 +204,7 @@ describe('tests-api', () => { it('should be set relative for suite', () => { gemini.suite('suite', () => {}); - assert.equal(rootSuite.children[0].file, relativeFile); + assert.equal(rootSuite.children[0].file, osPath(relativeFile)); assert.isTrue(rootSuite.children[0].hasOwnProperty('file')); }); @@ -211,7 +213,7 @@ describe('tests-api', () => { gemini.suite('child', () => {}); }); - assert.equal(rootSuite.children[0].children[0].file, relativeFile); + assert.equal(rootSuite.children[0].children[0].file, osPath(relativeFile)); assert.isFalse(rootSuite.children[0].children[0].hasOwnProperty('file')); }); }); From e109d5313138e426a4d274e34f6de58b64999754 Mon Sep 17 00:00:00 2001 From: Evgeniy Generalov Date: Sat, 7 Apr 2018 11:47:35 +0300 Subject: [PATCH 3/6] chore: add appveyor.yml to run tests on Windows --- appveyor.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..6a6f13b1f --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,23 @@ +build: off +version: "{build}" +environment: + matrix: + - nodejs_version: "6" + - nodejs_version: "8" +platform: + # - x86 + - x64 +matrix: + fast_finish: true +cache: + - node_modules +install: + - ps: Install-Product node $env:nodejs_version $env:platform + - if exist node_modules npm prune + - if exist node_modules npm rebuild + - npm install +test_script: + - node --version + - npm --version + - npm run test-unit + - npm run test-func \ No newline at end of file From 1509c6e33854388296e2f1bd70ec72b2e95028e1 Mon Sep 17 00:00:00 2001 From: Evgeniy Generalov Date: Sat, 7 Apr 2018 14:35:29 +0300 Subject: [PATCH 4/6] fix: functional tests on Windows --- test/functional/config.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/functional/config.test.js b/test/functional/config.test.js index 7155bb150..4f0d0c242 100644 --- a/test/functional/config.test.js +++ b/test/functional/config.test.js @@ -26,7 +26,7 @@ describe('config', function() { it('should read valid config', function() { var config = new Config(configPath('validConfig.yml')); - assert.deepPropertyVal(config, 'system.projectRoot', '/it/works'); + assert.deepPropertyVal(config, 'system.projectRoot', path.resolve('/it/works')); }); it('should set correct root', function() { @@ -43,7 +43,7 @@ describe('config', function() { describe('.js', function() { it('should read valid config', function() { var config = new Config(configPath('validConfig.js')); - assert.deepPropertyVal(config, 'system.projectRoot', '/it/works'); + assert.deepPropertyVal(config, 'system.projectRoot', path.resolve('/it/works')); }); it('should throw on non-existent file', function() { @@ -56,7 +56,7 @@ describe('config', function() { describe('.json', function() { it('should read valid config', function() { var config = new Config(configPath('validConfig.json')); - assert.deepPropertyVal(config, 'system.projectRoot', '/it/works'); + assert.deepPropertyVal(config, 'system.projectRoot', path.resolve('/it/works')); }); it('should throw on non-existent file', function() { From 6ff0b143311e336049ab9ebff70a9f6192c6e008 Mon Sep 17 00:00:00 2001 From: Evgeniy Generalov Date: Sat, 7 Apr 2018 14:56:00 +0300 Subject: [PATCH 5/6] chore: add Appveyor badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 945e3a0f4..bf1e2f8d6 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![npm](https://img.shields.io/npm/v/gemini.svg?maxAge=2592000)](https://www.npmjs.com/package/gemini) [![Build Status](https://travis-ci.org/gemini-testing/gemini.svg?branch=master)](https://travis-ci.org/gemini-testing/gemini) +[![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/gemini/gemini/branch/master?svg=true)](https://ci.appveyor.com/project/gemini/gemini/branch/master) [![Coverage Status](https://img.shields.io/coveralls/gemini-testing/gemini.svg)](https://coveralls.io/r/gemini-testing/gemini) [![Join the chat at https://gitter.im/gemini-testing/gemini](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/gemini-testing/gemini?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Stories on waffle.io](https://img.shields.io/badge/waffle-dashboard-green.svg)](http://waffle.io/gemini-testing/gemini) From 17b3b8227809bab8fb7aa09c837f96e212d24843 Mon Sep 17 00:00:00 2001 From: Evgeniy Generalov Date: Sat, 7 Apr 2018 15:22:15 +0300 Subject: [PATCH 6/6] chore: disable node_modules cache on Appveyor See more details at https://github.com/npm/npm/issues/17781 --- appveyor.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 6a6f13b1f..ffd7a4186 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,21 +1,22 @@ build: off version: "{build}" + environment: matrix: - nodejs_version: "6" - nodejs_version: "8" + platform: # - x86 - x64 + matrix: fast_finish: true -cache: - - node_modules + install: - ps: Install-Product node $env:nodejs_version $env:platform - - if exist node_modules npm prune - - if exist node_modules npm rebuild - npm install + test_script: - node --version - npm --version