]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/legacy-test-package.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / legacy-test-package.js
1 'use strict'
2 var test = require('tap').test
3 var common = require('../common-tap.js')
4 var path = require('path')
5 var rimraf = require('rimraf')
6 var mkdirp = require('mkdirp')
7 var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
8 var fixturepath = path.resolve(basepath, 'npm-test-test-package')
9 var modulepath = path.resolve(basepath, 'node_modules')
10 var installedpath = path.resolve(modulepath, 'npm-test-test-package')
11 var Tacks = require('tacks')
12 var File = Tacks.File
13 var Dir = Tacks.Dir
14
15 var fixture = new Tacks(
16   Dir({
17     README: File(
18       'just an npm test\n'
19     ),
20     'package.json': File({
21       name: 'npm-test-test-package',
22       author: 'Testy McMock',
23       version: '1.2.3-99-b',
24       description: "This is a test package used for debugging. It has some random data and that's all."
25     })
26   })
27 )
28
29 test('setup', function (t) {
30   setup()
31   t.done()
32 })
33
34 test('test-package', function (t) {
35   common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
36
37   function installCheckAndTest (err, code, stdout, stderr) {
38     if (err) throw err
39     console.error(stderr)
40     console.log(stdout)
41     t.is(code, 0, 'install went ok')
42     common.npm(['test'], {cwd: installedpath}, testCheckAndRemove)
43   }
44
45   function testCheckAndRemove (err, code, stdout, stderr) {
46     if (err) throw err
47     console.error(stderr)
48     console.log(stdout)
49     t.is(code, 0, 'npm test w/o test is ok')
50     common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone)
51   }
52
53   function removeCheckAndDone (err, code, stdout, stderr) {
54     if (err) throw err
55     console.error(stderr)
56     console.log(stdout)
57     t.is(code, 0, 'remove went ok')
58     t.done()
59   }
60 })
61
62 test('cleanup', function (t) {
63   cleanup()
64   t.done()
65 })
66
67 function setup () {
68   cleanup()
69   fixture.create(fixturepath)
70   mkdirp.sync(modulepath)
71 }
72
73 function cleanup () {
74   fixture.remove(fixturepath)
75   rimraf.sync(basepath)
76 }