11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst fs = require('fs'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ci// Run in a child process because 'out' is opened twice, blocking the tmpdir 81cb0ef41Sopenharmony_ci// and preventing cleanup. 91cb0ef41Sopenharmony_ciif (process.argv[2] !== 'child') { 101cb0ef41Sopenharmony_ci // Parent 111cb0ef41Sopenharmony_ci const assert = require('assert'); 121cb0ef41Sopenharmony_ci const { fork } = require('child_process'); 131cb0ef41Sopenharmony_ci tmpdir.refresh(); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci // Run test 161cb0ef41Sopenharmony_ci const child = fork(__filename, ['child'], { stdio: 'inherit' }); 171cb0ef41Sopenharmony_ci child.on('exit', common.mustCall(function(code) { 181cb0ef41Sopenharmony_ci assert.strictEqual(code, 0); 191cb0ef41Sopenharmony_ci })); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ci return; 221cb0ef41Sopenharmony_ci} 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci// Child 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_cicommon.expectWarning( 271cb0ef41Sopenharmony_ci 'DeprecationWarning', 281cb0ef41Sopenharmony_ci 'WriteStream.prototype.open() is deprecated', 'DEP0135'); 291cb0ef41Sopenharmony_ciconst s = fs.createWriteStream(`${tmpdir.path}/out`); 301cb0ef41Sopenharmony_cis.open(); 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ciprocess.nextTick(() => { 331cb0ef41Sopenharmony_ci // Allow overriding open(). 341cb0ef41Sopenharmony_ci fs.WriteStream.prototype.open = common.mustCall(); 351cb0ef41Sopenharmony_ci fs.createWriteStream('asd'); 361cb0ef41Sopenharmony_ci}); 37