Comparing version 14.1.3 to 14.1.4
@@ -14,2 +14,3 @@ var async = require("async"), path = require("path"), util = require("util"), http = require("http"), EventEmitter = require("events").EventEmitter, express = require("express"), io = require("socket.io"), Errors = require("./errors"), Const = require("./const"); | ||
this.recorder = testCafe.recorder; | ||
this.uxlog = testCafe.uxlog; | ||
this.socketIO = null; | ||
@@ -116,2 +117,4 @@ this.testsViewFirstRun = true; | ||
POST("/worker/heartbeat", this._workerHeartbeatHandler); | ||
POST("/worker/force-close/", this._forceBrowserWindowClose); | ||
POST("/worker/force-close", this._forceBrowserWindowClose); | ||
GET("/tasks/:taskID/", this._getDetailTaskReport); | ||
@@ -161,2 +164,4 @@ GET("/tasks/:taskID", this._getDetailTaskReport); | ||
GET("/check_updates", this._checkUpdates); | ||
POST("/uxlog/", this._uxlog); | ||
POST("/uxlog", this._uxlog); | ||
ALL("*", this._page404Handler); | ||
@@ -422,2 +427,8 @@ }; | ||
Server.prototype._forceBrowserWindowClose = function(req, res) { | ||
var targetWindowMark = req.param("targetWindowMark"); | ||
res.end(); | ||
this.testRunner.workerPool.forceBrowserWindowClose(targetWindowMark); | ||
}; | ||
Server.prototype._listWorkers = function(req, res) { | ||
@@ -857,2 +868,8 @@ var render = req.param("render"), browsers = this.api.config.browsers || {}, workerNames = this.api.listConnectedWorkers(); | ||
Server.prototype._uxlog = function(req, res) { | ||
this.uxlog.addEntry(this.uxlog.CONTROL_PANEL_ACTION_KIND, req.param("msg")); | ||
res.status(200); | ||
res.end(); | ||
}; | ||
Server.prototype._page404Handler = function(req, res) { | ||
@@ -859,0 +876,0 @@ res.status(404); |
@@ -1,4 +0,4 @@ | ||
var ERR = require("./../server/server_errs"), async = require("async"), child_process = require("child_process"), dns = require("dns"), fs = require("fs"), os = require("os"), path = require("path"), http = require("http"), InstalledBrowsers = require("./installed_browsers"), TCPPorts = require("./tcp_ports"), Validator = require("./validator"); | ||
var ERR = require("./../server/server_errs"), async = require("async"), child_process = require("child_process"), dns = require("dns"), fs = require("fs"), os = require("os"), path = require("path"), http = require("http"), uuid = require("node-uuid"), InstalledBrowsers = require("./installed_browsers"), TCPPorts = require("./tcp_ports"), Validator = require("./validator"); | ||
var CFG_FILE_NAME = "config.json", PACKAGE_JSON_FILE_NAME = "package.json", DEFAULT_CONTROL_PANEL_PORT = 1337, DEFAULT_SERVICE_PORT = 1338, CHECKING_HOST_PORT = 1400, CHECKING_REQUEST_TIMEOUT = 3e3, WIN_PLATFORM = /^win/.test(process.platform), MAC_PLATFORM = process.platform === "darwin", WIN_DEFAULT_TESTS_DIR = WIN_PLATFORM ? path.join(process.env["USERPROFILE"], "Documents", "TestCafe", "Tests") : "", EXAMPLES_DIR = path.join(__dirname, "../../examples"), DEFAULT_TESTS_DIR = path.join(__dirname, "../../my_tests"), INSTALL_DATE_REG_KEY = "HKEY_CLASSES_ROOT\\Licenses\\6F0F8269-1516-44C6-BD30-0E90BE27871C", LICENSE_DATE_REG_KEY = "HKEY_CLASSES_ROOT\\Licenses\\0378852D-D597-4A32-B6D9-680A16A3CDA6"; | ||
var CFG_FILE_NAME = "config.json", PACKAGE_JSON_FILE_NAME = "package.json", DEFAULT_CONTROL_PANEL_PORT = 1337, DEFAULT_SERVICE_PORT = 1338, CHECKING_HOST_PORT = 1400, CHECKING_REQUEST_TIMEOUT = 3e3, WIN_PLATFORM = /^win/.test(process.platform), WIN64_PLATFORM = WIN_PLATFORM && process.arch === "x64", MAC_PLATFORM = process.platform === "darwin", WIN_USER_DIR = WIN_PLATFORM ? path.join(process.env["USERPROFILE"], "Documents", "TestCafe") : "", MAC_USER_DIR = MAC_PLATFORM ? "/Library/Application Support/TestCafe/" + process.env["USER"] : "", WIN_DEFAULT_TESTS_DIR = WIN_PLATFORM ? path.join(WIN_USER_DIR, "Tests") : "", MAC_DEFAULT_TESTS_DIR = MAC_PLATFORM ? path.join(MAC_USER_DIR, "my_tests") : "", EXAMPLES_DIR = path.join(__dirname, "../../examples"), DEFAULT_TESTS_DIR = path.join(__dirname, "../../my_tests"), INSTALL_DATE_REG_KEY = "HKEY_CLASSES_ROOT\\Licenses\\6F0F8269-1516-44C6-BD30-0E90BE27871C", LICENSE_DATE_REG_KEY = "HKEY_CLASSES_ROOT\\Licenses\\0378852D-D597-4A32-B6D9-680A16A3CDA6", TRIAL_SEND_INFO_REG_KEY = WIN64_PLATFORM ? "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\DevExpress" : "HKEY_LOCAL_MACHINE\\SOFTWARE\\DevExpress", USER_ID_REG_KEY = "HKEY_CLASSES_ROOT\\Licenses\\5FCB5B35-D11E-4374-AD58-19A608D8228C"; | ||
@@ -19,2 +19,5 @@ function copyDirRecursiveSync(from, to) { | ||
var dirPathArr = dirPath.split(path.sep), currentPath = dirPathArr.shift(); | ||
if (!WIN_PLATFORM) { | ||
currentPath = path.sep + currentPath; | ||
} | ||
while (dirPathArr.length) { | ||
@@ -40,3 +43,3 @@ currentPath = path.join(currentPath, dirPathArr.shift()); | ||
Config.CFG_FILE_PATH = path.join(Config.TESTCAFE_DIR, CFG_FILE_NAME); | ||
Config.CFG_FILE_PATH = path.join(WIN_USER_DIR || MAC_USER_DIR || Config.TESTCAFE_DIR, CFG_FILE_NAME); | ||
@@ -293,3 +296,12 @@ Config.PACKAGE_JSON_FILE_PATH = path.join(Config.TESTCAFE_DIR, PACKAGE_JSON_FILE_NAME); | ||
if (!fs.existsSync(cfgTestsDir)) { | ||
var testsDir = WIN_PLATFORM ? WIN_DEFAULT_TESTS_DIR : DEFAULT_TESTS_DIR; | ||
var testsDir = ""; | ||
if (WIN_PLATFORM) { | ||
testsDir = WIN_DEFAULT_TESTS_DIR; | ||
} else { | ||
if (MAC_PLATFORM) { | ||
testsDir = MAC_DEFAULT_TESTS_DIR; | ||
} else { | ||
testsDir = DEFAULT_TESTS_DIR; | ||
} | ||
} | ||
if (!fs.existsSync(testsDir)) { | ||
@@ -426,6 +438,9 @@ mkdirRecursiveSync(testsDir); | ||
Config.prototype._getRegistryKeyValue = function(key, field, callback) { | ||
var cmd = 'reg query "' + key + '" /v ' + field; | ||
var cmd = 'reg query "' + key + '"'; | ||
if (field) { | ||
cmd += " /v " + field; | ||
} | ||
child_process.exec(cmd, function(err, stdout) { | ||
try { | ||
var fieldString = stdout.split("\r\n")[2].split(" ")[3]; | ||
var fieldString = stdout.split("\r\n")[2].split(" ")[3]; | ||
callback(fieldString); | ||
@@ -438,2 +453,9 @@ } catch (e) { | ||
Config.prototype._setRegistryKeyValue = function(key, field, value, callback) { | ||
var fieldParam = field ? " /v " + field : "", cmd = [ 'reg add "', key, '"', fieldParam, ' /f /d "', value, '"' ].join(""); | ||
child_process.exec(cmd, function(err, stdout, stderr) { | ||
callback(err, stdout, stderr); | ||
}); | ||
}; | ||
Config.prototype.getInstallDate = function(callback) { | ||
@@ -464,2 +486,36 @@ var config = this; | ||
}); | ||
}; | ||
Config.prototype.getLoggingAllowedFlag = function(callback) { | ||
var config = this; | ||
if (!WIN_PLATFORM) { | ||
callback(false); | ||
return; | ||
} | ||
config.getCurrentVersion(function(version) { | ||
var versionArr = version.split("."), fieldName = [ versionArr[0], versionArr[1] ].join(""); | ||
config._getRegistryKeyValue(LICENSE_DATE_REG_KEY, fieldName, function(isLicense) { | ||
if (isLicense) { | ||
callback(false); | ||
} else { | ||
config._getRegistryKeyValue(TRIAL_SEND_INFO_REG_KEY, "TrialSendInfo", function(val) { | ||
callback(val); | ||
}); | ||
} | ||
}); | ||
}); | ||
}; | ||
Config.prototype.getUserID = function(callback) { | ||
var config = this; | ||
this._getRegistryKeyValue(USER_ID_REG_KEY, "", function(val) { | ||
if (!val) { | ||
var userID = uuid.v4(); | ||
config._setRegistryKeyValue(USER_ID_REG_KEY, "", userID, function() { | ||
callback(userID); | ||
}); | ||
} else { | ||
callback(val); | ||
} | ||
}); | ||
}; |
@@ -5,6 +5,7 @@ var util = require("util"), uuid = require("node-uuid"), cmd = require("../shared/service_msg_cmd"), ERR = require("./server_errs"), errMsgBuilder = require("./err_msg_builder"), FixtureCode = require("../fixture_code/"), AssetsManager = require("./assets_manager"); | ||
var Recorder = exports.Recorder = function(hammerhead, vfs) { | ||
var Recorder = exports.Recorder = function(hammerhead, vfs, uxlog) { | ||
this.hammerhead = hammerhead; | ||
this.vfs = vfs; | ||
this.silentMode = false; | ||
this.uxlog = uxlog; | ||
this.silentMode = true; | ||
this.disableTooltip = false; | ||
@@ -125,2 +126,6 @@ this.recordings = {}; | ||
case cmd.UXLOG: | ||
this.uxlog.addEntry(this.uxlog.RECORDER_ACTION_KIND, msg.msg); | ||
break; | ||
default: | ||
@@ -127,0 +132,0 @@ break; |
@@ -1,4 +0,4 @@ | ||
var EventEmitter = require("events").EventEmitter, ChildProcess = require("child_process"), moment = require("moment"), os = require("os"), util = require("util"), Api = require("./api").Api, AssetsManager = require("./assets_manager"), Config = require("./../config"), ControlPanel = require("./../../control_panel"), ERR = require("./server_errs"), ErrMsgBuilder = require("./err_msg_builder"), Hammerhead = require("./../../hammerhead").Hammerhead, Recorder = require("./recorder").Recorder, TestRunner = require("../test_runner"), VirtualFS = require("../vfs"); | ||
var EventEmitter = require("events").EventEmitter, ChildProcess = require("child_process"), moment = require("moment"), os = require("os"), util = require("util"), Api = require("./api").Api, AssetsManager = require("./assets_manager"), Config = require("./../config"), ControlPanel = require("./../../control_panel"), ERR = require("./server_errs"), ErrMsgBuilder = require("./err_msg_builder"), Hammerhead = require("./../../hammerhead").Hammerhead, Recorder = require("./recorder").Recorder, TestRunner = require("../test_runner"), UXLog = require("./uxlog"), VirtualFS = require("../vfs"); | ||
var GREETING = "DevExpress TestCafe - functional testing for the web.\n" + "Copyright (C) 2012 - %s Developer Express Inc.\n" + "-----------------------------------------------\n", CONTROL_PANEL_URL_INFO_PATTERN = "Control Panel URL - http://%s\n\n", SHUTDOWN_MSG_PATTERN = "%s - Initialization Error:\n%s\n"; | ||
var GREETING = "DevExpress TestCafe - functional testing for the web.\n" + "Copyright (C) 2012 - %s Developer Express Inc.\n" + "-----------------------------------------------\n", CONTROL_PANEL_URL_INFO_PATTERN = "Control Panel URL - http://%s\n\n", SHUTDOWN_MSG_PATTERN = "%s - Error:\n%s\n"; | ||
@@ -22,6 +22,10 @@ var TestCafe = module.exports = function(startupCfg, standalone) { | ||
var shutDownMsg = util.format(SHUTDOWN_MSG_PATTERN, moment().format("L LT"), errMsg); | ||
this.uxlog.addEntry(this.uxlog.FATAL_ERROR_ACTION_KIND, errMsg); | ||
this.uxlog.sendCollectedData(); | ||
this.close(); | ||
if (standalone) { | ||
util.error(shutDownMsg); | ||
process.exit(1); | ||
setTimeout(function() { | ||
process.exit(1); | ||
}, 200); | ||
} else { | ||
@@ -49,2 +53,5 @@ throw shutDownMsg; | ||
} | ||
if (this.uxlog) { | ||
this.uxlog.shutDown(); | ||
} | ||
}; | ||
@@ -65,2 +72,3 @@ | ||
testCafe.config.initConfig(startupCfg, function(err) { | ||
testCafe.uxlog = new UXLog(testCafe.config); | ||
if (err) { | ||
@@ -83,3 +91,3 @@ var messages = ErrMsgBuilder.build(util.isArray(err) ? err : [ err ]); | ||
testCafe.testRunner = new TestRunner(testCafe.hammerhead, testCafe.config); | ||
testCafe.recorder = new Recorder(testCafe.hammerhead, testCafe.vfs); | ||
testCafe.recorder = new Recorder(testCafe.hammerhead, testCafe.vfs, testCafe.uxlog); | ||
Api.call(testCafe, testCafe.testRunner, testCafe.vfs, testCafe.config, standalone); | ||
@@ -105,2 +113,6 @@ testCafe.controlPanel = new ControlPanel.Server(testCafe); | ||
} | ||
process.removeAllListeners("uncaughtException"); | ||
process.on("uncaughtException", function(err) { | ||
testCafe._fatalError(err.msg + "\n" + err.stack, standalone); | ||
}); | ||
}); | ||
@@ -107,0 +119,0 @@ }; |
@@ -19,3 +19,4 @@ (function() { | ||
RESTART_RECORD: "CMD_RESTART_RECORD", | ||
AUTH_CREDENTIALS_SET: "CMD_AUTH_CREDENTIALS_SET" | ||
AUTH_CREDENTIALS_SET: "CMD_AUTH_CREDENTIALS_SET", | ||
UXLOG: "CMD_UXLOG" | ||
}; | ||
@@ -22,0 +23,0 @@ if (typeof module !== "undefined" && module.exports) { |
@@ -1,4 +0,4 @@ | ||
var async = require("async"), EventEmitter = require("events").EventEmitter, execFile = require("child_process").execFile, url = require("url"), util = require("util"), userAgentParser = require("useragent"), ERR = require("./../server/server_errs"); | ||
var async = require("async"), EventEmitter = require("events").EventEmitter, childProc = require("child_process"), url = require("url"), util = require("util"), userAgentParser = require("useragent"), uuid = require("node-uuid"), ERR = require("./../server/server_errs"); | ||
var ADD_WORKER_URL_PATHNAME_PATTERN = "/worker/add/%s/", WORKER_IDLE_URL_PATHNAME_PATTERN = "/worker/idle/%s/", CREATE_WORKER_ON_LOCAL_BROWSER_TIMEOUT = 30 * 1e3; | ||
var WIN_PLATFORM = /^win/.test(process.platform), MAC_PLATFORM = process.platform === "darwin", ADD_WORKER_URL_PATHNAME_PATTERN = "/worker/add/%s/", WORKER_IDLE_URL_PATHNAME_PATTERN = "/worker/idle/%s/", CREATE_WORKER_ON_LOCAL_BROWSER_TIMEOUT = 30 * 1e3, FORCE_BROWSER_CLOSE_DELAY = 1e3; | ||
@@ -81,3 +81,3 @@ function sanitizeWorkerName(name) { | ||
worker.browserProc.kill(); | ||
worker.browserProc = execFile(execParams.path, execParams.cmdArr, function(execError) { | ||
worker.browserProc = childProc.execFile(execParams.path, execParams.cmdArr, function(execError) { | ||
if (execError && execError.code === 127) { | ||
@@ -173,4 +173,4 @@ workerPool._disconnectWorker(workerName); | ||
returnUrl: returnUrl, | ||
browserName: null, | ||
browserProc: null, | ||
browserName: null, | ||
userAgent: userAgent, | ||
@@ -203,2 +203,11 @@ taskReport: null, | ||
WorkerPool.prototype.forceBrowserWindowClose = function(targetWindowMark) { | ||
if (WIN_PLATFORM) { | ||
var execCmd = util.format('taskkill -FI "WINDOWTITLE eq %s*"', targetWindowMark); | ||
setTimeout(function() { | ||
childProc.exec(execCmd); | ||
}, FORCE_BROWSER_CLOSE_DELAY); | ||
} | ||
}; | ||
WorkerPool.prototype.getWorkerStatus = function(workerName, nextTestRunUrl) { | ||
@@ -209,9 +218,10 @@ var worker = this.get(workerName); | ||
delete this.workers[workerName]; | ||
if (worker.type === WORKER_TYPE.NEW_BROWSER_WINDOW) { | ||
if (worker.browserProc) { | ||
if (worker.type === WORKER_TYPE.NEW_BROWSER_WINDOW && worker.browserProc) { | ||
if (!WIN_PLATFORM) { | ||
worker.browserProc.kill(); | ||
return { | ||
status: "utilized" | ||
}; | ||
} | ||
return { | ||
status: "utilized", | ||
targetWindowMark: "ForceBrowserWindowCloseTargetMark[" + uuid.v4() + "]" | ||
}; | ||
} | ||
@@ -238,3 +248,3 @@ return { | ||
var cmdArr = browser.cmd ? browser.cmd.split(" ") : []; | ||
if (process.platform === "darwin") { | ||
if (MAC_PLATFORM) { | ||
return { | ||
@@ -268,3 +278,3 @@ cmdArr: [ "-a", browser.path, startupUrl, "--args" ].concat(cmdArr), | ||
}; | ||
var browserProc = execFile(execParams.path, execParams.cmdArr, function(execError) { | ||
var browserProc = childProc.execFile(execParams.path, execParams.cmdArr, function(execError) { | ||
if (execError && execError.code === 127) { | ||
@@ -271,0 +281,0 @@ errs.push({ |
@@ -174,10 +174,16 @@ var fs = require("fs"), path = require("path"), util = require("util"), EventEmitter = require("events").EventEmitter, Process = require("child_process"), async = require("async"), TestSuiteFactory = require("./test_suite_factory"), FixtureCode = require("../fixture_code"), ERR = require("./../server/server_errs"); | ||
VirtualFS.prototype._setupFSWatchers = function(dirPath) { | ||
var vfs = this, fsWatcher = fs.watch(dirPath, function() { | ||
vfs.watchRevisionChanges(); | ||
}); | ||
vfs.fsWatchers.push(fsWatcher); | ||
fsWatcher.on("error", function() { | ||
vfs.fsWatchers.splice(vfs.fsWatchers.indexOf(fsWatcher), 1); | ||
fsWatcher.close(); | ||
}); | ||
try { | ||
var vfs = this, fsWatcher = fs.watch(dirPath, function() { | ||
vfs.watchRevisionChanges(); | ||
}); | ||
vfs.fsWatchers.push(fsWatcher); | ||
fsWatcher.on("error", function() { | ||
vfs.fsWatchers.splice(vfs.fsWatchers.indexOf(fsWatcher), 1); | ||
fsWatcher.close(); | ||
}); | ||
} catch (e) { | ||
if (e.code !== "EPERM" || !VirtualFS.WIN_PLATFORM) { | ||
throw e; | ||
} | ||
} | ||
}; | ||
@@ -184,0 +190,0 @@ |
{ | ||
"name": "testcafe", | ||
"description": "Functional testing for the web", | ||
"version": "14.1.3", | ||
"version": "14.1.4", | ||
"dependencies": { | ||
@@ -18,3 +18,5 @@ "async": "0.2.6", | ||
"useragent": "2.0.6", | ||
"webauth": "0.1.0" | ||
"webauth": "0.1.0", | ||
"node-int64": "0.3.0", | ||
"buffer-crc32": "0.2.3" | ||
}, | ||
@@ -21,0 +23,0 @@ "main": "index", |
@@ -75,2 +75,6 @@ ��D E V E L O P E R E X P R E S S I N C | ||