From 52b517c6ab962f6c51529f77a0b8226343c850cd Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 17 Jun 2011 14:01:27 +0200 Subject: [PATCH] Revert "Add --cov code coverage option" This can be done in user space. EG https://github.com/cloudkick/whiskey This reverts commit da9b3340ebb7501ebb8a2896d2c259ffabdab340. This reverts commit b4ff36a41b242c0b379d3c27fb30818de54fe2d4. Conflicts: src/node.cc --- lib/module.js | 16 ------------- src/node.cc | 6 ----- src/node.js | 17 -------------- test/common.js | 4 ---- tools/covhtml.js | 60 ------------------------------------------------ 5 files changed, 103 deletions(-) delete mode 100644 tools/covhtml.js diff --git a/lib/module.js b/lib/module.js index 06fa80fe9c89a6..be5475f9cff199 100644 --- a/lib/module.js +++ b/lib/module.js @@ -347,22 +347,6 @@ Module.prototype._compile = function(content, filename) { // remove shebang content = content.replace(/^\#\!.*/, ''); - // add coverage - if (process.cov) { - var lines = content.split('\n'); - - if (lines.length > 0) { - lines[0] = '__cov[__filename] = { 0: true}; ' + lines[0]; - } - - for (var i = 0; i < lines.length; i++) { - lines[i] = - lines[i].replace(/;$/, '; __cov[__filename][' + i + '] = true;'); - } - - content = lines.join('\n'); - } - function require(path) { return Module._load(path, self); } diff --git a/src/node.cc b/src/node.cc index 9d289dba9b429a..fe39942ac3218f 100644 --- a/src/node.cc +++ b/src/node.cc @@ -109,7 +109,6 @@ static char *eval_string = NULL; static int option_end_index = 0; static bool use_debug_agent = false; static bool debug_wait_connect = false; -static bool cov = false; static int debug_port=5858; static int max_stack_size = 0; @@ -2093,7 +2092,6 @@ Handle SetupProcessObject(int argc, char *argv[]) { process->Set(String::NewSymbol("ENV"), ENV); process->Set(String::NewSymbol("pid"), Integer::New(getpid())); - process->Set(String::NewSymbol("cov"), cov ? True() : False()); process->Set(String::NewSymbol("useUV"), use_uv ? True() : False()); // -e, --eval @@ -2237,7 +2235,6 @@ static void PrintHelp() { " --v8-options print v8 command line options\n" " --vars print various compiled-in variables\n" " --max-stack-size=val set max v8 stack size (bytes)\n" - " --cov code coverage; writes node-cov.json \n" " --use-uv use the libuv backend\n" "\n" "Enviromental variables:\n" @@ -2261,9 +2258,6 @@ static void ParseArgs(int argc, char **argv) { if (strstr(arg, "--debug") == arg) { ParseDebugOpt(arg); argv[i] = const_cast(""); - } else if (!strcmp(arg, "--cov")) { - cov = true; - argv[i] = const_cast(""); } else if (!strcmp(arg, "--use-uv")) { use_uv = true; argv[i] = const_cast(""); diff --git a/src/node.js b/src/node.js index dd156eec0cd1bc..1ab424473f598a 100644 --- a/src/node.js +++ b/src/node.js @@ -113,9 +113,6 @@ global.GLOBAL = global; global.root = global; global.Buffer = NativeModule.require('buffer').Buffer; - if (process.cov) { - global.__cov = {}; - } }; startup.globalTimeouts = function() { @@ -364,20 +361,6 @@ var path = NativeModule.require('path'); process.argv[0] = path.join(cwd, process.argv[0]); } - - if (process.cov) { - process.on('exit', function() { - var coverage = JSON.stringify(__cov); - var path = NativeModule.require('path'); - var fs = NativeModule.require('fs'); - var filename = path.join(cwd, 'node-cov.json'); - try { - fs.unlinkSync(filename); - } catch(e) { - } - fs.writeFileSync(filename, coverage); - }); - } }; // Below you find a minimal module system, which is used to load the node diff --git a/test/common.js b/test/common.js index ba9663b5663b3d..636029578c0271 100644 --- a/test/common.js +++ b/test/common.js @@ -68,10 +68,6 @@ process.on('exit', function() { knownGlobals.push(gc); } - if (global.__cov) { - knownGlobals.push(__cov); - } - if (global.DTRACE_HTTP_SERVER_RESPONSE) { knownGlobals.push(DTRACE_HTTP_SERVER_RESPONSE); knownGlobals.push(DTRACE_HTTP_SERVER_REQUEST); diff --git a/tools/covhtml.js b/tools/covhtml.js deleted file mode 100644 index cb262d8b4f3ecb..00000000000000 --- a/tools/covhtml.js +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -// This tool is to make pretty HTML from --cov output. - -var fs = require('fs'); -var path = require('path'); - -var jsonFilename = process.argv[2]; -if (!jsonFilename) { - console.error("covhtml.js node-cov.json > out.html"); - process.exit(1); -} - -var jsonFile = fs.readFileSync(jsonFilename); -var cov = JSON.parse(jsonFile); - -var out = ''; - -for (var fn in cov) { - var source = fs.readFileSync(fn, 'utf8'); - var lines = source.split('\n'); - - out += '

' + path.basename(fn) + '

\n
\n'; - - for (var i = 0; i < lines.length; i++) { - lines[i] = lines[i].replace('<', '<'); - lines[i] = lines[i].replace('>', '>'); - if (cov[fn][i]) { - out += '
'
-    } else {
-      out += '
'
-    }
-    out += lines[i] + '
\n'; - } - - out += '
\n'; -} - -out += '' - -console.log(out);