mirror of
https://github.com/denoland/deno.git
synced 2024-12-18 13:22:55 -05:00
fb24fd37c9
This PR enables node compat test cases found passing by using the tool added in #27122 The percentage of passing test case increases from 16.16% to 30.43% by this change.
59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
// deno-fmt-ignore-file
|
|
// deno-lint-ignore-file
|
|
|
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
|
// Taken from Node 20.11.1
|
|
// This file is automatically generated by `tests/node_compat/runner/setup.ts`. Do not modify this file manually.
|
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { setTimeout } = require('timers/promises');
|
|
|
|
if (common.isIBMi)
|
|
common.skip('IBMi does not support `fs.watch()`');
|
|
|
|
// fs-watch on folders have limited capability in AIX.
|
|
// The testcase makes use of folder watching, and causes
|
|
// hang. This behavior is documented. Skip this for AIX.
|
|
|
|
if (common.isAIX)
|
|
common.skip('folder watch capability is limited in AIX.');
|
|
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
const { pathToFileURL } = require('url');
|
|
|
|
const tmpdir = require('../common/tmpdir');
|
|
const testDir = tmpdir.path;
|
|
tmpdir.refresh();
|
|
|
|
(async () => {
|
|
// Add a file to already watching folder, and use URL as the path
|
|
|
|
const rootDirectory = fs.mkdtempSync(testDir + path.sep);
|
|
const testDirectory = path.join(rootDirectory, 'test-5');
|
|
fs.mkdirSync(testDirectory);
|
|
|
|
const filePath = path.join(testDirectory, 'file-8.txt');
|
|
const url = pathToFileURL(testDirectory);
|
|
|
|
const watcher = fs.watch(url, { recursive: true });
|
|
let watcherClosed = false;
|
|
watcher.on('change', function(event, filename) {
|
|
assert.strictEqual(event, 'rename');
|
|
|
|
if (filename === path.basename(filePath)) {
|
|
watcher.close();
|
|
watcherClosed = true;
|
|
}
|
|
});
|
|
|
|
await setTimeout(common.platformTimeout(100));
|
|
fs.writeFileSync(filePath, 'world');
|
|
|
|
process.on('exit', function() {
|
|
assert(watcherClosed, 'watcher Object was not closed');
|
|
});
|
|
})().then(common.mustCall());
|