1'use strict';
2const common = require('../common');
3const fs = require('fs');
4
5const tmpdir = require('../common/tmpdir');
6
7// Run in a child process because 'out' is opened twice, blocking the tmpdir
8// and preventing cleanup.
9if (process.argv[2] !== 'child') {
10  // Parent
11  const assert = require('assert');
12  const { fork } = require('child_process');
13  tmpdir.refresh();
14
15  // Run test
16  const child = fork(__filename, ['child'], { stdio: 'inherit' });
17  child.on('exit', common.mustCall(function(code) {
18    assert.strictEqual(code, 0);
19  }));
20
21  return;
22}
23
24// Child
25
26common.expectWarning(
27  'DeprecationWarning',
28  'WriteStream.prototype.open() is deprecated', 'DEP0135');
29const s = fs.createWriteStream(`${tmpdir.path}/out`);
30s.open();
31
32process.nextTick(() => {
33  // Allow overriding open().
34  fs.WriteStream.prototype.open = common.mustCall();
35  fs.createWriteStream('asd');
36});
37