diff --git a/.travis.yml b/.travis.yml index a0927fb07..a6a1eab01 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,4 +9,7 @@ before_script: - grunt build script: - - grunt test + - grunt test:unit + - grunt test:client + - grunt test:e2e:basic + - grunt test:e2e:mocha diff --git a/lib/launcher.js b/lib/launcher.js index 058c9825f..67d1e204b 100644 --- a/lib/launcher.js +++ b/lib/launcher.js @@ -37,7 +37,7 @@ var Browser = function(id) { return [url]; }; - this._tempDir = (env.TMPDIR || env.TMP || env.TEMP || '/tmp') + '/testacular-' + id; + this._tempDir = (env.TMPDIR || env.TMP || env.TEMP || '/tmp') + '/testacular-' + id.toString(); try { log.debug('Creating temp dir at ' + this._tempDir); @@ -112,25 +112,42 @@ var FirefoxBrowser = function() { var self = this; var command = this._getCommand(); + if (fs.existsSync(this._tempDir + '/prefs.js')) { + log.warn('Profile already exists at %s', this._tempDir); + self._execCommand(command + ' ' + url); + return; + } + // create profile first - exec(command + ' -CreateProfile testacular', function(e, stdout, stderr) { + // https://developer.mozilla.org/en-US/docs/Command_Line_Options + exec(command + ' -CreateProfile "testacular ' + this._tempDir + '"', function(e, stdout, stderr) { if (e) { log.error(e); + return; } + console.log(stderr); var match = /at\s\'(.*)\/prefs\.js\'/.exec(stderr.toString()); if (match) { - var profile = self._tempDir = match[1]; - var prefs = 'user_pref("browser.shell.checkDefaultBrowser", false);\n' + - 'user_pref("browser.bookmarks.restore_default_bookmarks", false);\n'; - - fs.createWriteStream(profile + '/prefs.js', {flags: 'a'}).write(prefs); - self._execCommand(command + ' -profile "' + profile + '" ' + url); - } else { - log.warn('Can not create Firefox profile'); - self._execCommand(command + ' ' + url); + log.debug('changing temp dir to %s', match[1]) + self._tempDir = match[1]; } + + var prefsFile = self._tempDir + '/prefs.js'; + + fs.exists(prefsFile, function(exists) { + if (exists) { + var prefs = 'user_pref("browser.shell.checkDefaultBrowser", false);\n' + + 'user_pref("browser.bookmarks.restore_default_bookmarks", false);\n'; + + fs.createWriteStream(prefsFile, {flags: 'a'}).write(prefs); + self._execCommand(command + ' -profile "' + self._tempDir + '" ' + url); + } else { + log.warn('Firefox can not create profile'); + self._execCommand(command + ' ' + url); + } + }); }); }; }; diff --git a/tasks/test.js b/tasks/test.js index 2df7f1743..34aff27ea 100644 --- a/tasks/test.js +++ b/tasks/test.js @@ -32,9 +32,9 @@ module.exports = function(grunt) { if (this.target === 'e2e') { var tests = grunt.file.expand(this.data); var processToKill; - var cmd = './bin/testacular'; + var cmd = 'testacular'; var args = [ - 'start', null, '--single-run', '--no-auto-watch', '--reporter=dots', '--browsers=' + BROWSERS + 'start', null, '--log-level=debug', '--single-run', '--no-auto-watch', '--reporter=dots', '--browsers=' + BROWSERS ]; var next = function(err, result, code) { @@ -89,7 +89,7 @@ module.exports = function(grunt) { // CLIENT unit tests else if (this.target === 'client') { - exec('testacular', ['start', this.data, '--single-run', '--no-auto-watch', '--reporter=dots', + exec('testacular', ['start', this.data, '--single-run', '--log-level=debug', '--no-auto-watch', '--reporter=dots', '--browsers=' + BROWSERS], 'Client unit tests failed.'); } });