]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/lifecycle-signal.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / lifecycle-signal.js
1 var fs = require('graceful-fs')
2 var path = require('path')
3 var spawn = require('child_process').spawn
4
5 var mkdirp = require('mkdirp')
6 var osenv = require('osenv')
7 var rimraf = require('rimraf')
8 var test = require('tap').test
9
10 var node = process.execPath
11 var npm = require.resolve('../../bin/npm-cli.js')
12
13 var pkg = path.resolve(__dirname, 'lifecycle-signal')
14
15 var json = {
16   name: 'lifecycle-signal',
17   version: '1.2.5',
18   scripts: {
19     preinstall: 'node -e "process.kill(process.pid,\'SIGSEGV\')"'
20   }
21 }
22
23 test('setup', function (t) {
24   cleanup()
25   mkdirp.sync(pkg)
26   fs.writeFileSync(
27     path.join(pkg, 'package.json'),
28     JSON.stringify(json, null, 2)
29   )
30
31   process.chdir(pkg)
32   t.end()
33 })
34
35 test('lifecycle signal abort', function (t) {
36   // windows does not use lifecycle signals, abort
37   if (process.platform === 'win32' || process.env.TRAVIS) return t.end()
38
39   var child = spawn(node, [npm, 'install'], {
40     cwd: pkg
41   })
42   child.on('close', function (code, signal) {
43     t.equal(code, null)
44     t.equal(signal, 'SIGSEGV')
45     t.end()
46   })
47 })
48
49 test('cleanup', function (t) {
50   cleanup()
51   t.end()
52 })
53
54 function cleanup () {
55   process.chdir(osenv.tmpdir())
56   rimraf.sync(pkg)
57 }