Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Windows fixes #906

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
build: off
version: "{build}"

environment:
matrix:
- nodejs_version: "6"
- nodejs_version: "8"

platform:
# - x86
- x64

matrix:
fast_finish: true

install:
- ps: Install-Product node $env:nodejs_version $env:platform
- npm install

test_script:
- node --version
- npm --version
- npm run test-unit
- npm run test-func
6 changes: 3 additions & 3 deletions lib/runner/browser-runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
const _ = require('lodash');

exports.requireWithNoCache = function(moduleName) {
delete require.cache[moduleName];
Expand All @@ -10,3 +11,8 @@ exports.logger = {
warn: console.warn,
error: console.error
};

exports.urlJoin = (...args) =>
args
.map((value, index) => (index ? _.trim : _.trimEnd)(value, '/'))
.join('/');
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions test/functional/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand Down
11 changes: 6 additions & 5 deletions test/unit/browser-config.test.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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() {
Expand All @@ -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'));
});
});

Expand All @@ -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'));
});
});
});
17 changes: 9 additions & 8 deletions test/unit/config-options/config-options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand All @@ -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'));
});
});

Expand All @@ -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() {
Expand All @@ -322,18 +323,18 @@ 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',
sourceRoot: '/some/absolute/path'
}
});

assert.equal(config.system.sourceRoot, '/some/absolute/path');
assert.equal(config.system.sourceRoot, path.resolve('/some/absolute/path'));
});
});

Expand Down Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions test/unit/config/index.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -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));
});
});

Expand Down
6 changes: 4 additions & 2 deletions test/unit/tests-api/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const path = require('path');
const testsAPI = require('lib/tests-api');
const Suite = require('lib/suite');

Expand Down Expand Up @@ -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'}});
Expand All @@ -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'));
});

Expand All @@ -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'));
});
});
Expand Down