summaryrefslogtreecommitdiff
path: root/test/async-hooks/test-graph.statwatcher.js
blob: 96376926a67450c30f7c059d505f08458f7e3a7f (plain)
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
'use strict';

require('../common');
const commonPath = require.resolve('../common');
const initHooks = require('./init-hooks');
const verifyGraph = require('./verify-graph');
const fs = require('fs');

const hooks = initHooks();
hooks.enable();

function onchange() { }
// Install first file watcher
fs.watchFile(__filename, onchange);

// Install second file watcher
fs.watchFile(commonPath, onchange);

// Remove first file watcher
fs.unwatchFile(__filename);

// Remove second file watcher
fs.unwatchFile(commonPath);

process.on('exit', onexit);

function onexit() {
  hooks.disable();
  verifyGraph(
    hooks,
    [ { type: 'STATWATCHER', id: 'statwatcher:1', triggerAsyncId: null },
      { type: 'STATWATCHER', id: 'statwatcher:2', triggerAsyncId: null } ]
  );
}