Permalink
Browse files

Test renovation for 1.0.

TODO: tap output
  • Loading branch information...
1 parent a055c3c commit 542578a561ae24cb9df9574d91b0bc66bb683bbb @isaacs isaacs committed Mar 21, 2011
Showing with 30 additions and 179 deletions.
  1. +0 −2 test/packages/npm-test-bindir/bin/prog.js
  2. +0 −5 test/packages/npm-test-bindir/package.json
  3. +0 −16 test/packages/npm-test-bindir/test.js
  4. +0 −13 test/packages/npm-test-bundletest/foo.js
  5. +0 −5 test/packages/npm-test-bundletest/package.json
  6. +0 −4 test/packages/npm-test-depends-on-connect/package.json
  7. +0 −5 test/packages/npm-test-depends-on-jsdom/package.json
  8. +0 −13 test/packages/npm-test-depends-on-jsdom/test.js
  9. +0 −5 test/packages/npm-test-depends-on-spark/package.json
  10. +0 −2 test/packages/npm-test-files-array-npmignore/.npmignore
  11. +0 −1 test/packages/npm-test-files-array-npmignore/foo/bar
  12. 0 test/packages/npm-test-files-array-npmignore/foo/baz
  13. 0 test/packages/npm-test-files-array-npmignore/foo/foo/asdf
  14. 0 test/packages/npm-test-files-array-npmignore/foo/foo/bar
  15. 0 test/packages/npm-test-files-array-npmignore/foo/foo/baz
  16. +0 −4 test/packages/npm-test-files-array-npmignore/package.json
  17. +0 −11 test/packages/npm-test-files-array-npmignore/test.sh
  18. +0 −1 test/packages/npm-test-files-array-simple/bar
  19. +0 −1 test/packages/npm-test-files-array-simple/foo
  20. +0 −4 test/packages/npm-test-files-array-simple/package.json
  21. +0 −12 test/packages/npm-test-files-array-simple/test.sh
  22. 0 test/packages/npm-test-npmignore/.dot-keeper
  23. 0 test/packages/npm-test-npmignore/.dotfile
  24. 0 test/packages/npm-test-npmignore/.dotglob-a
  25. 0 test/packages/npm-test-npmignore/.dotglob-b
  26. 0 test/packages/npm-test-npmignore/.dotglob-c
  27. +0 −3 test/packages/npm-test-npmignore/.npmignore
  28. +0 −1 test/packages/npm-test-npmignore/foo/bar
  29. 0 test/packages/npm-test-npmignore/foo/baz
  30. +0 −4 test/packages/npm-test-npmignore/package.json
  31. +0 −14 test/packages/npm-test-npmignore/test.sh
  32. +1 −1 test/packages/npm-test-url-dep/package.json
  33. +29 −52 test/run.sh
View
2 test/packages/npm-test-bindir/bin/prog.js
@@ -1,2 +0,0 @@
-
-console.log("hello from bindir")
View
5 test/packages/npm-test-bindir/package.json
@@ -1,5 +0,0 @@
-{ "name" : "npm-test-bindir"
-, "version" : "1.0.0"
-, "directories" : { "bin" : "./bin" }
-, "scripts" : { "test" : "node ./test.js" }
-}
View
16 test/packages/npm-test-bindir/test.js
@@ -1,16 +0,0 @@
-// ${npm_config_binroot}/prog @ -> ./prog-${npm_package_version}
-// ${npm_config_binroot}/prog-${npm_package_version} = shim
-
-var path = require("path")
- , assert = require("assert")
- , root = process.env.npm_config_root
- , binroot = process.env.npm_config_binroot
- , name = process.env.npm_package_name
- , version = process.env.npm_package_version
- , prog = path.join(binroot, "prog")
- , progVer = path.join(binroot, "prog@"+version)
- , bin = path.join(root, ".npm", name, version, "package", "bin", "prog.js")
-
-assert.equal(require(bin), require(progVer), "require('"+ bin +"') !== require('"+ progVer +"')")
-assert.equal(require(prog), require(progVer), "require('"+ prog +"') !== require('"+ progVer +"')")
-assert.equal(require(bin), require(prog), "require('"+ bin +"') !== require('"+ prog +"')")
View
13 test/packages/npm-test-bundletest/foo.js
@@ -1,13 +0,0 @@
-var assert = require("assert")
- , path = require("path")
- , pkgdir = path.join(__dirname, "node_modules")
- , fs = require("fs")
- , json = fs.readFileSync(path.join(__dirname, "package.json"),"utf8")
- , pkg = JSON.parse(json)
- , deps = Object.keys(pkg.dependencies)
-
-deps.forEach(function (dep) {
- var d = require.resolve(dep)
- assert.equal(0, d.indexOf(pkgdir)
- ,dep+" not in "+pkgdir+"\nFound at "+d)
-})
View
5 test/packages/npm-test-bundletest/package.json
@@ -1,5 +0,0 @@
-{"name":"npm-test-bundletest"
-,"version":"1.0.0"
-,"main":"./foo"
-,"dependencies":{"express":"1.0.0","oauth":"*","ejs":"0.2.0","npm":"*"}
-,"scripts":{"test":"node foo.js"}}
View
4 test/packages/npm-test-depends-on-connect/package.json
@@ -1,4 +0,0 @@
-{ "name":"npm-test-depends-on-connect"
-, "version" : "1.2.3"
-, "dependencies" : { "connect" : "0.2.4" }
-}
View
5 test/packages/npm-test-depends-on-jsdom/package.json
@@ -1,5 +0,0 @@
-{ "name":"npm-test-depends-on-jsdom"
-, "version" : "1.0.0"
-, "dependencies" : { "jsdom" : "*" }
-, "scripts" : { "test" : "node test.js" }
-}
View
13 test/packages/npm-test-depends-on-jsdom/test.js
@@ -1,13 +0,0 @@
-require.paths.unshift
- ( "./node_modules"
- , "../node_modules"
- , "../../node_modules"
- , "../../../node_modules"
- , "../../../../node_modules"
- , "../../../../../node_modules"
- , "../../../../../../node_modules"
- , "../../../../../../../node_modules"
- , "../../../../../../../../node_modules")
-
-require("jsdom")
-require("htmlparser")
View
5 test/packages/npm-test-depends-on-spark/package.json
@@ -1,5 +0,0 @@
-{"name":"npm-test-depends-on-spark"
-,"version":"1.2.3"
-,"dependencies":{"spark":"*"}
-,"scripts":{"test":"echo $PATH >> which-spark.log; which spark >> which-spark.log"}
-}
View
2 test/packages/npm-test-files-array-npmignore/.npmignore
@@ -1,2 +0,0 @@
-*/bar
-**/asdf
View
1 test/packages/npm-test-files-array-npmignore/foo/bar
@@ -1 +0,0 @@
-bar
View
0 test/packages/npm-test-files-array-npmignore/foo/baz
No changes.
View
0 test/packages/npm-test-files-array-npmignore/foo/foo/asdf
No changes.
View
0 test/packages/npm-test-files-array-npmignore/foo/foo/bar
No changes.
View
0 test/packages/npm-test-files-array-npmignore/foo/foo/baz
No changes.
View
4 test/packages/npm-test-files-array-npmignore/package.json
@@ -1,4 +0,0 @@
-{ "name":"npm-test-files-array-npmignore"
-, "version" : "1.2.3"
-, "files" : ["foo", "test.sh"]
-, "scripts" : {"test":"./test.sh"}}
View
11 test/packages/npm-test-files-array-npmignore/test.sh
@@ -1,11 +0,0 @@
-#!/usr/bin/env bash
-
-set -x
-set -e
-
-if [[ $npm_package_version == "9999.0.0-LINK-"* ]]; then
- echo "link package, skipping test"
- exit 0
-fi
-
-[ -f ./foo/baz ] && ! [ -f ./foo/bar ]
View
1 test/packages/npm-test-files-array-simple/bar
@@ -1 +0,0 @@
-bar
View
1 test/packages/npm-test-files-array-simple/foo
@@ -1 +0,0 @@
-foo
View
4 test/packages/npm-test-files-array-simple/package.json
@@ -1,4 +0,0 @@
-{ "name":"npm-test-files-array-simple"
-, "version" : "1.2.3"
-, "files" : ["foo", "test.sh"]
-, "scripts" : {"test":"./test.sh"}}
View
12 test/packages/npm-test-files-array-simple/test.sh
@@ -1,12 +0,0 @@
-#!/usr/bin/env bash
-
-set -x
-set -e
-
-if [[ $npm_package_version == "9999.0.0-LINK-"* ]]; then
- echo "link package, skipping test"
- exit 0
-fi
-
-# test that there is a foo file, and that there is NOT a bar file
-[ -f ./foo ] && ! [ -f ./bar ]
View
0 test/packages/npm-test-npmignore/.dot-keeper
No changes.
View
0 test/packages/npm-test-npmignore/.dotfile
No changes.
View
0 test/packages/npm-test-npmignore/.dotglob-a
No changes.
View
0 test/packages/npm-test-npmignore/.dotglob-b
No changes.
View
0 test/packages/npm-test-npmignore/.dotglob-c
No changes.
View
3 test/packages/npm-test-npmignore/.npmignore
@@ -1,3 +0,0 @@
-*/bar
-.dotfile
-.dotglob*
View
1 test/packages/npm-test-npmignore/foo/bar
@@ -1 +0,0 @@
-bar
View
0 test/packages/npm-test-npmignore/foo/baz
No changes.
View
4 test/packages/npm-test-npmignore/package.json
@@ -1,4 +0,0 @@
-{ "name" : "npm-test-npmignore"
-, "version" : "1.2.3"
-, "files" : ["foo", "test.sh", ""]
-, "scripts" : {"test":"./test.sh"}}
View
14 test/packages/npm-test-npmignore/test.sh
@@ -1,14 +0,0 @@
-#!/usr/bin/env bash
-
-set -x
-set -e
-
-if [[ $npm_package_version == "9999.0.0-LINK-"* ]]; then
- echo "link package, skipping test"
- exit 0
-fi
-
-[ -f ./foo/baz ] \
- && ! [ -f ./foo/bar ] \
- && [ -f ./.dot-keeper ] \
- && ! [ -f ./.dot-glob-a ]
View
2 test/packages/npm-test-url-dep/package.json
@@ -3,4 +3,4 @@
, "files" : []
, "dependencies" :
{ "express" : "*"
- , "npm" : "http://registry.npmjs.org/npm/-/npm-0.2.13-3.tgz" } }
+ , "npm" : "http://registry.npmjs.org/npm/-/npm-0.3.17.tgz" } }
View
81 test/run.sh
@@ -18,57 +18,41 @@ main () {
npm install $( ls packages | awk '{print "packages/" $1 }' ) || exit 1
(ls packages | while read pkg; do
- npm test "$pkg"@"$(ls -- "$ROOTDIR"/.npm/"$pkg" | grep -v active)"
+ npm test "$pkg"
done) || exit 1
if [ "$FAILURES" == "0" ]; then
npm rm $(ls packages) npm || exit 1
fi
cleanup
- # link
- npm install "$NPMPKG" || exit 1
-
- # used in test later
- npm config set package-config:foo boo || exit 1
- (cd packages/npm-test-bundletest && npm bundle) || exit 1
-
- (ls packages | awk '{print "packages/" $1 }' | while read pkg; do
- npm link "$pkg"
- done) || exit 1
- (ls packages | while read pkg; do
- npm test "$pkg"@"$(ls -- "$ROOTDIR"/.npm/"$pkg" | grep -v active)"
- done) || exit 1
- if [ "$FAILURES" == "0" ]; then
- npm rm $(ls packages) npm || exit 1
- fi
- cleanup
-
- # attempt to publish and unpublish each of them.
- npm install "$NPMPKG" || exit 1
-
- (ls packages | grep -v 'npm-test-private' | while read pkg; do
- if [ "$pkg" != "npm-test-bundletest" ]; then
- (cd packages/$pkg ; npm bundle destroy)
+ if ! [ "$npm_package_config_publishtest" == "true" ]; then
+ echo_err "To test publishing: npm config set npm:publishtest true"
+ else
+ # attempt to publish and unpublish each of them.
+ npm install "$NPMPKG" || exit 1
+
+ (ls packages | grep -v 'npm-test-private' | while read pkg; do
+ npm publish packages/$pkg || exit 1
+ npm install $pkg || exit 1
+ npm unpublish $pkg || exit 1
+ done) || exit 1
+
+ # verify that the private package can't be published
+ # bypass the test-harness npm function.
+ "$NPMCLI" publish packages/npm-test-private && (
+ npm unpublish npm-test-private
+ exit 1000
+ )
+ if [ $? -eq 1000 ]; then
+ fail "Private package shouldn't be publishable" >&2
fi
- npm publish packages/$pkg || exit 1
- npm install $pkg || exit 1
- npm unpublish $pkg || exit 1
- done) || exit 1
- # verify that the private package can't be published
- # bypass the test-harness npm function.
- "$NPMCLI" publish packages/npm-test-private && (
- npm unpublish npm-test-private
- exit 1000
- )
- if [ $? -eq 1000 ]; then
- fail "Private package shouldn't be publishable" >&2
- fi
+ if [ "$FAILURES" == "0" ]; then
+ npm rm $(ls packages) npm || exit 1
+ fi
+ cleanup
- if [ "$FAILURES" == "0" ]; then
- npm rm $(ls packages) npm || exit 1
fi
- cleanup
if [ $FAILURES -eq 0 ]; then
echo_err "ok"
@@ -116,27 +100,20 @@ rm -rf $TMP/npm*
TMP=$TMP/npm-test-$$
echo "Testing in $TMP ..."
ROOTDIR="$TMP/root"
-BINDIR="$TMP/bin"
-MANDIR="$TMP/man"
cleanup () {
if [ "$FAILURES" != "0" ] && [ "$FAILURES" != "" ]; then
return
fi
[ -d "$ROOTDIR" ] && rm -rf -- "$ROOTDIR"
- [ -d "$BINDIR" ] && rm -rf -- "$BINDIR"
- [ -d "$MANDIR" ] && rm -rf -- "$MANDIR"
mkdir -p -- "$ROOTDIR"
- mkdir -p -- "$BINDIR"
- mkdir -p -- "$MANDIR"
}
-export npm_config_root="$ROOTDIR"
-export npm_config_binroot="$BINDIR"
-export npm_config_manroot="$MANDIR"
+export npm_config_prefix="$ROOTDIR"
export npm_config_color="always"
-export PATH="$PATH":"$BINDIR"
-export NODE_PATH="$ROOTDIR"
+export npm_config_global=true
+export PATH="$PATH":"$ROOTDIR/bin":"$ROOTDIR/node_modules/.bin"
+export NODE_PATH="$ROOTDIR/node_modules"
echo_err () {
echo "$@" >&2

0 comments on commit 542578a

Please sign in to comment.