| @@ -14,7 +14,7 @@ npm <command> [args] | ||
| .fi | ||
| . | ||
| .SH "VERSION" | ||
| 1.1.0-beta-7 | ||
| . | ||
| .SH "DESCRIPTION" | ||
| npm is the package manager for the Node JavaScript platform\. It puts | ||
| @@ -21,7 +21,7 @@ npm\.load(configObject, function (er, npm) { | ||
| .fi | ||
| . | ||
| .SH "VERSION" | ||
| 1.1.0-beta-7 | ||
| . | ||
| .SH "DESCRIPTION" | ||
| This is the API documentation for npm\. | ||
| @@ -0,0 +1,7 @@ | ||
| /sub/ignore1 | ||
| ./sub/include2 | ||
| ignore3 | ||
| ./include4 | ||
| ignoredir1 | ||
| ignoredir2/ | ||
| *.tgz |
| @@ -0,0 +1,9 @@ | ||
| { "name":"npm-test-files" | ||
| , "version":"1.2.5" | ||
| , "files": | ||
| [ "include4" | ||
| , "sub/include" | ||
| , "sub/include2" | ||
| , "sub/include4" | ||
| , "test.sh" ] | ||
| , "scripts":{"test":"bash test.sh"}} |
| @@ -0,0 +1 @@ | ||
| This file should be in the package. |
| @@ -0,0 +1,27 @@ | ||
| x=`find . | grep ignore | grep -v npmignore` | ||
| if [ "$x" != "" ]; then | ||
| echo "ignored files included: $x" | ||
| exit 1 | ||
| fi | ||
|
|
||
| x=`find . | grep -v ignore | sort` | ||
| y=". | ||
| ./include4 | ||
| ./package.json | ||
| ./sub | ||
| ./sub/include | ||
| ./sub/include2 | ||
| ./sub/include4 | ||
| ./test.sh" | ||
| if [ "$x" != "$y" ]; then | ||
| echo "missing included files" | ||
| echo "got:" | ||
| echo "===" | ||
| echo "$x" | ||
| echo "===" | ||
| echo "wanted:" | ||
| echo "===" | ||
| echo "$y" | ||
| echo "===" | ||
| exit 1 | ||
| fi |
| @@ -0,0 +1,209 @@ | ||
| // Everything in this file uses child processes, because we're | ||
| // testing a command line utility. | ||
|
|
||
| var chain = require("slide").chain | ||
| var child_process = require("child_process") | ||
| var path = require("path") | ||
| , testdir = __dirname | ||
| , fs = require("graceful-fs") | ||
| , npmpkg = path.dirname(testdir) | ||
| , npmcli = path.join(__dirname, "bin", "npm-cli.js") | ||
|
|
||
| var temp = process.env.TMPDIR | ||
| || process.env.TMP | ||
| || process.env.TEMP | ||
| || ( process.platform === "win32" | ||
| ? "c:\\windows\\temp" | ||
| : "/tmp" ) | ||
|
|
||
| temp = path.resolve(temp, "npm-test-" + process.pid) | ||
|
|
||
| var root = path.resolve(temp, "root") | ||
|
|
||
| var failures = 0 | ||
| , mkdir = require("mkdirp") | ||
| , rimraf = require("rimraf") | ||
|
|
||
| var pathEnvSplit = process.platform === "win32" ? ";" : ":" | ||
| , pathEnv = process.env.PATH.split(pathEnvSplit) | ||
| , npmPath = process.platform === "win32" ? root : path.join(root, "bin") | ||
|
|
||
| pathEnv.unshift(npmPath, path.join(root, "node_modules", ".bin")) | ||
|
|
||
| // lastly, make sure that we get the same node that is being used to do | ||
| // run this script. That's very important, especially when running this | ||
| // test file from in the node source folder. | ||
| pathEnv.unshift(path.dirname(process.execPath)) | ||
|
|
||
| // the env for all the test installs etc. | ||
| var env = {} | ||
| Object.keys(process.env).forEach(function (i) { | ||
| env[i] = process.env[i] | ||
| }) | ||
| env.npm_config_prefix = root | ||
| env.npm_config_color = "always" | ||
| env.npm_config_global = "true" | ||
| // have to set this to false, or it'll try to test itself forever | ||
| env.npm_config_npat = "false" | ||
| env.PATH = pathEnv.join(pathEnvSplit) | ||
| env.NODE_PATH = path.join(root, "node_modules") | ||
|
|
||
|
|
||
|
|
||
| function cleanup (cb) { | ||
| if (failures !== 0) return | ||
| rimraf(root, function (er) { | ||
| if (er) cb(er) | ||
| mkdir(root, 0755, cb) | ||
| }) | ||
| } | ||
|
|
||
| function prefix (content, pref) { | ||
| return pref + (content.trim().split(/\r?\n/).join("\n" + pref)) | ||
| } | ||
|
|
||
| var execCount = 0 | ||
| function exec (cmd, shouldFail, cb) { | ||
| if (typeof shouldFail === "function") { | ||
| cb = shouldFail, shouldFail = false | ||
| } | ||
| console.error("\n+"+cmd + (shouldFail ? " (expect failure)" : "")) | ||
|
|
||
| // special: replace 'node' with the current execPath, | ||
| // and 'npm' with the thing we installed. | ||
| cmd = cmd.replace(/^npm /, path.resolve(npmPath, "npm") + " ") | ||
| cmd = cmd.replace(/^node /, process.execPath + " ") | ||
|
|
||
| child_process.exec(cmd, {env: env}, function (er, stdout, stderr) { | ||
| if (stdout) { | ||
| console.error(prefix(stdout, " 1> ")) | ||
| } | ||
| if (stderr) { | ||
| console.error(prefix(stderr, " 2> ")) | ||
| } | ||
|
|
||
| execCount ++ | ||
| if (!shouldFail && !er || shouldFail && er) { | ||
| // stdout = (""+stdout).trim() | ||
| console.log("ok " + execCount + " " + cmd) | ||
| return cb() | ||
| } else { | ||
| console.log("not ok " + execCount + " " + cmd) | ||
| cb(new Error("failed "+cmd)) | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| function execChain (cmds, cb) { | ||
| chain(cmds.reduce(function (l, r) { | ||
| return l.concat(r) | ||
| }, []).map(function (cmd) { | ||
| return [exec, cmd] | ||
| }), cb) | ||
| } | ||
|
|
||
| function flatten (arr) { | ||
| return arr.reduce(function (l, r) { | ||
| return l.concat(r) | ||
| }, []) | ||
| } | ||
|
|
||
| function setup (cb) { | ||
| cleanup(function (er) { | ||
| if (er) return cb(er) | ||
| execChain([ "node \""+path.resolve(npmpkg, "bin", "npm-cli.js") | ||
| + "\" install \""+npmpkg+"\"" | ||
| , "npm config set package-config:foo boo" | ||
| ], cb) | ||
| }) | ||
| } | ||
|
|
||
| function main (cb) { | ||
| console.log("# testing in %s", temp) | ||
| console.log("# global prefix = %s", root) | ||
|
|
||
|
|
||
|
|
||
| failures = 0 | ||
|
|
||
| process.chdir(testdir) | ||
|
|
||
| // get the list of packages | ||
| var packages = fs.readdirSync(path.resolve(testdir, "packages")) | ||
| packages = packages.filter(function (p) { | ||
| return p && !p.match(/^\./) | ||
| }) | ||
|
|
||
| installAllThenTestAll() | ||
|
|
||
| function installAllThenTestAll () { | ||
| chain | ||
| ( [ setup | ||
| , [ exec, "npm install "+npmpkg ] | ||
| , [ execChain, packages.map(function (p) { | ||
| return "npm install packages/"+p | ||
| }) ] | ||
| , [ execChain, packages.map(function (p) { | ||
| return "npm test "+p | ||
| }) ] | ||
| , [ execChain, packages.concat("npm").map(function (p) { | ||
| return "npm rm " + p | ||
| }) ] | ||
| , installAndTestEach | ||
| ] | ||
| , cb | ||
| ) | ||
| } | ||
|
|
||
| function installAndTestEach (cb) { | ||
| chain | ||
| ( [ setup | ||
| , [ execChain, packages.map(function (p) { | ||
| return [ "npm install packages/"+p | ||
| , "npm test "+p | ||
| , "npm rm "+p ] | ||
| }) ] | ||
| , [exec, "npm rm npm"] | ||
| , publishTest | ||
| ], cb ) | ||
| } | ||
|
|
||
| function publishTest (cb) { | ||
| if (process.env.npm_package_config_publishtest !== "true") { | ||
| console.error("To test publishing: "+ | ||
| "npm config set npm:publishtest true") | ||
| return cb() | ||
| } | ||
|
|
||
| chain | ||
| ( [ setup | ||
| , [ execChain, packages.filter(function (p) { | ||
| return !p.match(/private/) | ||
| }).map(function (p) { | ||
| return [ "npm publish packages/"+p | ||
| , "npm install "+p | ||
| , "npm unpublish "+p+" --force" | ||
| ] | ||
| }) ] | ||
| , publishPrivateTest | ||
| ], cb ) | ||
|
|
||
| } | ||
|
|
||
| function publishPrivateTest (cb) { | ||
| exec("npm publish packages/npm-test-private -s", true, function (er) { | ||
| if (er) { | ||
| exec( "npm unpublish npm-test-private --force" | ||
| , function (e2) { | ||
| cb(er || e2) | ||
| }) | ||
| } | ||
| cleanup(cb) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| main(function (er) { | ||
| console.log("1.." + execCount) | ||
| if (er) throw er | ||
| }) |
| @@ -148,6 +148,7 @@ Socket.prototype.setTimeout = function(msecs, callback) { | ||
|
|
||
|
|
||
| Socket.prototype._onTimeout = function() { | ||
| debug("_onTimeout"); | ||
| this.emit('timeout'); | ||
| }; | ||
|
|
||
| @@ -222,7 +222,6 @@ if (isWindows) { | ||
| return arr.slice(start, end - start + 1); | ||
| } | ||
|
|
||
| var toParts = trim(to.split('\\')); | ||
|
|
||
| var lowerFromParts = trim(lowerFrom.split('\\')); | ||
| @@ -0,0 +1,62 @@ | ||
| // 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. | ||
|
|
||
| if (!process.versions.openssl) { | ||
| console.error('Skipping because node compiled without OpenSSL.'); | ||
| process.exit(0); | ||
| } | ||
|
|
||
| var common = require('../common'); | ||
| var assert = require('assert'); | ||
| var https = require('https'); | ||
| var fs = require('fs'); | ||
| var path = require('path'); | ||
|
|
||
| var options = { | ||
| key: fs.readFileSync(path.join(common.fixturesDir, 'keys/agent1-key.pem')), | ||
| cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem')) | ||
| }; | ||
| var serverErrorHappened = false; | ||
| var clientErrorHappened = false; | ||
|
|
||
| var server = https.Server(options, function(req, res) { | ||
| assert(false); | ||
| }); | ||
| server.on('clientError', function(err) { | ||
| serverErrorHappened = true; | ||
| common.debug('Server: ' + err); | ||
| server.close(); | ||
| }); | ||
|
|
||
| server.listen(common.PORT, function() { | ||
| var req = https.get({port: common.PORT}, function(res) { | ||
| assert(false); | ||
| }); | ||
| req.on('error', function(err) { | ||
| clientErrorHappened = true; | ||
| common.debug('Client: ' + err); | ||
| }); | ||
| }); | ||
|
|
||
| process.on('exit', function() { | ||
| assert(serverErrorHappened); | ||
| assert(clientErrorHappened); | ||
| }); |
| @@ -0,0 +1,50 @@ | ||
| // 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 example sets a timeout then immediately attempts to disable the timeout | ||
| // https://github.com/joyent/node/pull/2245 | ||
|
|
||
| var common = require('../common'); | ||
| var net = require('net'); | ||
| var assert = require('assert'); | ||
|
|
||
| var T = 100; | ||
|
|
||
| var server = net.createServer(function(c) { | ||
| c.write('hello'); | ||
| }); | ||
| server.listen(common.PORT); | ||
|
|
||
| var socket = net.createConnection(common.PORT, 'localhost'); | ||
|
|
||
| socket.setTimeout(T, function() { | ||
| socket.destroy(); | ||
| server.close(); | ||
| assert.ok(false); | ||
| }); | ||
|
|
||
| socket.setTimeout(0); | ||
|
|
||
| setTimeout(function() { | ||
| socket.destroy(); | ||
| server.close(); | ||
| assert.ok(true); | ||
| }, T*2); |
| @@ -0,0 +1,62 @@ | ||
| // 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. | ||
|
|
||
| if (!process.versions.openssl) { | ||
| console.error('Skipping because node compiled without OpenSSL.'); | ||
| process.exit(0); | ||
| } | ||
|
|
||
| var common = require('../common'); | ||
| var assert = require('assert'); | ||
| var tls = require('tls'); | ||
| var fs = require('fs'); | ||
| var path = require('path'); | ||
|
|
||
| var options = { | ||
| key: fs.readFileSync(path.join(common.fixturesDir, 'keys/agent1-key.pem')), | ||
| cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem')) | ||
| }; | ||
| var serverErrorHappened = false; | ||
| var clientErrorHappened = false; | ||
|
|
||
| var server = tls.Server(options, function(socket) { | ||
| assert(false); | ||
| }); | ||
| server.on('clientError', function(err) { | ||
| serverErrorHappened = true; | ||
| common.debug('Server: ' + err); | ||
| server.close(); | ||
| }); | ||
|
|
||
| server.listen(common.PORT, function() { | ||
| var client = tls.connect(common.PORT, function() { | ||
| assert(false); | ||
| }); | ||
| client.on('error', function(err) { | ||
| clientErrorHappened = true; | ||
| common.debug('Client: ' + err); | ||
| }); | ||
| }); | ||
|
|
||
| process.on('exit', function() { | ||
| assert(serverErrorHappened); | ||
| assert(clientErrorHappened); | ||
| }); |