]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/registry.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / registry.js
1 // Run all the tests in the `npm-registry-couchapp` suite
2 // This verifies that the server-side stuff still works.
3
4 var common = require("../common-tap")
5 var test = require("tap").test
6
7 var npmExec = require.resolve("../../bin/npm-cli.js")
8 var path = require("path")
9 var ca = path.resolve(__dirname, "../../node_modules/npm-registry-couchapp")
10
11 var which = require("which")
12
13 var v = process.versions.node.split(".").map(function (n) { return parseInt(n, 10) })
14 if (v[0] === 0 && v[1] < 10) {
15   console.error(
16     "WARNING: need a recent Node for npm-registry-couchapp tests to run, have",
17     process.versions.node
18   )
19 }
20 else {
21   which("couchdb", function (er) {
22     if (er) {
23       console.error("WARNING: need couch to run test: " + er.message)
24     }
25     else {
26       runTests()
27     }
28   })
29 }
30
31
32 function runTests () {
33   var env = { TAP: 1 }
34   for (var i in process.env) env[i] = process.env[i]
35   env.npm = npmExec
36
37   var opts = {
38     cwd: ca,
39     stdio: "inherit"
40   }
41   common.npm(["install"], opts, function (err, code, stdout, stderr) {
42     if (err) { throw err }
43     if (code) {
44       return test("need install to work", function (t) {
45         t.fail(
46           "install failed with: " + code +
47           '\nstdout: ' + stdout +
48           '\nstderr: ' + stderr)
49         t.end()
50       })
51
52     } else {
53       opts = {
54         cwd: ca,
55         env: env,
56         stdio: "inherit"
57       }
58       common.npm(
59         [
60           "test", "--", "-Rtap"
61         ],
62         opts,
63         function (err, code, stdout, stderr) {
64           if (err) { throw err }
65           if (code) {
66             return test("need test to work", function (t) {
67               t.fail(
68                 "test failed with: " + code +
69                 '\nstdout: ' + stdout +
70                 '\nstderr: ' + stderr)
71                 t.end()
72               })
73             }
74             opts = {
75               cwd: ca,
76               env: env,
77               stdio: "inherit"
78             }
79             common.npm(["prune", "--production"], opts, function (err, code) {
80               if (err) { throw err }
81               process.exit(code || 0)
82             })
83           })
84         }
85   })
86 }