| --- ../../../soc2/node_modules/testem/lib/browser_launcher.js 2013-08-29 04:49:55.000000000 +0200 |
| +++ ../../node_modules/testem/lib/browser_launcher.js 2013-09-06 12:47:07.868928895 +0200 |
| @@ -11,6 +11,7 @@ |
| var rimraf = require('rimraf') |
| var async = require('async') |
| var fs = require('fs') |
| +var temp = require('temp') |
| var fileutils = require('./fileutils') |
| var browserExeExists = fileutils.browserExeExists |
| var findableByWhich = fileutils.findableByWhich |
| @@ -18,15 +19,34 @@ |
| |
| // Find the temporary directory for the system |
| var tempDir = function(){ |
| - var platform = process.platform |
| - if (platform === 'win32') |
| - return 'C:\\Windows\\Temp' |
| - else |
| - return '/tmp' |
| + return { |
| + chrome: temp.path({prefix: 'testem.chrome'}), |
| + chrome_canary: temp.path({prefix: 'testem.chrome-canary'}), |
| + chromium: temp.path({prefix: 'testem.chromium'}), |
| + firefox: temp.path({prefix: 'testem.firefox'}), |
| + opera: temp.path({prefix: 'testem.opera'}), |
| + safari: temp.path({prefix: 'testem.safari'}) |
| + }; |
| }() |
| |
| var userHomeDir = process.env.HOME || process.env.USERPROFILE |
| |
| +function removeTestemFilesFromTemporaryDirectory(){ |
| + var filesInTmp = fs.readdirSync(temp.dir) |
| + var testemDirectories = filesInTmp.filter(function(file) { |
| + if (file.indexOf('testem') === 0 && fs.lstatSync(temp.dir, file).isDirectory()) { |
| + return true |
| + } |
| + return false |
| + }) |
| + testemDirectories = testemDirectories.map(function(directory){ |
| + return path.join(temp.dir, directory) |
| + }) |
| + testemDirectories.forEach(function(directory){ |
| + rimraf.sync(directory) |
| + }) |
| +} |
| + |
| function setupFirefoxProfile(profileDir, done){ |
| rimraf(profileDir, function(){ |
| // using prefs.js to suppress the check default browser popup |
| @@ -67,9 +87,12 @@ |
| "C:\\Program Files\\Mozilla Firefox\\firefox.exe", |
| "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe" |
| ], |
| - args: ["-profile", tempDir + "\\testem.firefox"], |
| + args: ["-profile", tempDir.firefox], |
| setup: function(config, done){ |
| - setupFirefoxProfile(tempDir + '/testem.firefox', done) |
| + setupFirefoxProfile(tempDir.firefox, done) |
| + }, |
| + tearDown: function(){ |
| + removeTestemFilesFromTemporaryDirectory() |
| }, |
| supported: browserExeExists |
| }, |
| @@ -81,9 +104,9 @@ |
| "C:\\Program Files\\Google\\Chrome\\Application\\Chrome.exe", |
| "C:\\Program Files (x86)\\Google\\Chrome\\Application\\Chrome.exe" |
| ], |
| - args: ["--user-data-dir=" + tempDir + "\\testem.chrome", "--no-default-browser-check", "--no-first-run"], |
| - setup: function(config, done){ |
| - rimraf(tempDir + '\\testem.chrome', done) |
| + args: ["--user-data-dir=" + tempDir.chrome, "--no-default-browser-check", "--no-first-run"], |
| + tearDown: function(){ |
| + removeTestemFilesFromTemporaryDirectory() |
| }, |
| supported: browserExeExists |
| }, |
| @@ -101,9 +124,9 @@ |
| "C:\\Program Files\\Opera\\opera.exe", |
| "C:\\Program Files (x86)\\Opera\\opera.exe" |
| ], |
| - args: ["-pd", tempDir + "\\testem.opera"], |
| - setup: function(config, done){ |
| - rimraf(tempDir + '\\testem.opera', done) |
| + args: ["-pd", tempDir.opera], |
| + tearDown: function(){ |
| + removeTestemFilesFromTemporaryDirectory() |
| }, |
| supported: browserExeExists |
| }, |
| @@ -121,27 +144,27 @@ |
| { |
| name: "Chrome", |
| exe: "/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome", |
| - args: ["--user-data-dir=" + tempDir + "/testem.chrome", "--no-default-browser-check", "--no-first-run"], |
| - setup: function(config, done){ |
| - rimraf(tempDir + '/testem.chrome', done) |
| + args: ["--user-data-dir=" + tempDir.chrome, "--no-default-browser-check", "--no-first-run"], |
| + tearDown: function(){ |
| + removeTestemFilesFromTemporaryDirectory() |
| }, |
| supported: browserExeExists |
| }, |
| { |
| name: "Chrome Canary", |
| exe: "/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary", |
| - args: ["--user-data-dir=" + tempDir + "/testem.chrome-canary", "--no-default-browser-check", "--no-first-run"], |
| - setup: function(config, done){ |
| - rimraf(tempDir + '/testem.chrome-canary', done) |
| + args: ["--user-data-dir=" + tempDir.chrome_canary, "--no-default-browser-check", "--no-first-run"], |
| + tearDown: function(){ |
| + removeTestemFilesFromTemporaryDirectory() |
| }, |
| supported: browserExeExists |
| }, |
| { |
| name: "Firefox", |
| exe: "/Applications/Firefox.app/Contents/MacOS/firefox", |
| - args: ["-profile", tempDir + "/testem.firefox"], |
| - setup: function(config, done){ |
| - setupFirefoxProfile(tempDir + '/testem.firefox', done) |
| + args: ["-profile", tempDir.firefox], |
| + tearDown: function(){ |
| + removeTestemFilesFromTemporaryDirectory() |
| }, |
| supported: browserExeExists |
| }, |
| @@ -150,19 +173,23 @@ |
| exe: "/Applications/Safari.app/Contents/MacOS/Safari", |
| setup: function(config, done){ |
| var url = this.getUrl() |
| - fs.writeFile(tempDir + '/testem.safari.html', "<script>window.location = '" + url + "'</script>", done) |
| + fs.mkdir(tempDir.safari, function() {}) |
| + fs.writeFile(tempDir.safari + '/testem.safari.html', "<script>window.location = '" + url + "'</script>", done) |
| + }, |
| + tearDown: function(){ |
| + removeTestemFilesFromTemporaryDirectory() |
| }, |
| args: function(){ |
| - return [tempDir + '/testem.safari.html'] |
| + return [tempDir.safari + '/testem.safari.html'] |
| }, |
| supported: browserExeExists |
| }, |
| { |
| name: "Opera", |
| exe: "/Applications/Opera.app/Contents/MacOS/Opera", |
| - args: ["-pd", tempDir + "/testem.opera"], |
| - setup: function(config, done){ |
| - rimraf(tempDir + '/testem.opera', done) |
| + args: ["-pd", tempDir.opera], |
| + tearDown: function(){ |
| + removeTestemFilesFromTemporaryDirectory() |
| }, |
| supported: browserExeExists |
| }, |
| @@ -180,35 +207,32 @@ |
| { |
| name: 'Firefox', |
| exe: 'firefox', |
| - args: ["-no-remote", "-profile", tempDir + "/testem.firefox"], |
| + args: ["-no-remote", "-profile", tempDir.firefox], |
| setup: function(config, done){ |
| - rimraf(tempDir + '/testem.firefox', function(err){ |
| - if (!err){ |
| - fs.mkdir(tempDir + '/testem.firefox', done) |
| - }else{ |
| - done() |
| - } |
| - }) |
| + fs.mkdir(tempDir.firefox, done) |
| + }, |
| + tearDown: function(){ |
| + removeTestemFilesFromTemporaryDirectory() |
| }, |
| supported: findableByWhich |
| }, |
| { |
| name: 'Chrome', |
| exe: 'google-chrome', |
| - args: ["--user-data-dir=" + tempDir + "/testem.chrome", |
| + args: ["--user-data-dir=" + tempDir.chrome, |
| "--no-default-browser-check", "--no-first-run"], |
| - setup: function(config, done){ |
| - rimraf(tempDir + '/testem.chrome', done) |
| + tearDown: function(){ |
| + removeTestemFilesFromTemporaryDirectory() |
| }, |
| supported: findableByWhich |
| }, |
| { |
| name: 'Chromium', |
| exe: ['chromium', 'chromium-browser'], |
| - args: ["--user-data-dir=" + tempDir + "/testem.chromium", |
| + args: ["--user-data-dir=" + tempDir.chromium, |
| "--no-default-browser-check", "--no-first-run"], |
| - setup: function(config, done){ |
| - rimraf(tempDir + '/testem.chromium', done) |
| + tearDown: function(){ |
| + removeTestemFilesFromTemporaryDirectory() |
| }, |
| supported: findableByWhich |
| }, |