File: issue121-test.js

package info (click to toggle)
node-tmp 0.2.2%2Bdfsg%2B~0.2.3-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 796 kB
  • sloc: javascript: 1,562; sh: 18; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 1,009 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* eslint-disable no-octal */
// vim: expandtab:ts=2:sw=2

process.exit(0);

const
  assertions = require('./assertions'),
  childProcess = require('./child-process').childProcess,
  os = require('os'),
  testCases = [
    'SIGINT',
    'SIGTERM'
  ];

// skip tests on win32
const isWindows = os.platform() === 'win32';
const tfunc = isWindows ? xit : it;

describe('tmp', function () {
  describe('issue121 - clean up on terminating signals', function () {
    for (let tc of testCases) {
      tfunc('for signal ' + tc, function (done) {
        // increase timeout so that the child process may terminate in time
        this.timeout(5000);
        issue121Tests(tc)(done);
      });
    }
  });
});

function issue121Tests(signal) {
  return function (done) {
    childProcess(this, 'issue121.json', function (err, stderr, stdout) {
      if (err) return done(err);
      else if (stderr) return done(new Error(stderr));

      assertions.assertDoesNotExist(stdout);
      done();
    }, signal);
  };
}