Skip to content
Prev Previous commit
Next Next commit
fixup! test: windows fanned test failed
  • Loading branch information
legendecas committed May 19, 2021
commit 0112fba04111e4218045b3e47c5dc95fe5150429
21 changes: 15 additions & 6 deletions test/report/test-report-uv-handles.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
// Testcase to check reporting of uv handles.
const common = require('../common');
const tmpdir = require('../common/tmpdir');
Comment thread
richardlau marked this conversation as resolved.
const path = require('path');
if (common.isIBMi)
common.skip('IBMi does not support fs.watch()');

function pipeName(windowsExtended) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is only called with windowsExtended set to true so the parameter is superfluous?

Copy link
Copy Markdown
Member Author

@legendecas legendecas May 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated common.PIPE to use '\\?\' prefix. Most likely there should not be any difference regarding the pipe API. However my local windows VM doesn't behave well and lots of unrelated test cases were falling for unknown reasons. So just pushed the updates and let's see what the CI says.

const localRelative = path.relative(process.cwd(), `${tmpdir.path}/`);
const pipePrefix = common.isWindows ? `\\\\${windowsExtended ? '?' : '.'}\\pipe\\` : localRelative;
const filename = `node-test.${process.pid}.sock`;
return path.join(pipePrefix, filename);
}

function createFsHandle(childData) {
const fs = require('fs');
// Watching files should result in fs_event/fs_poll uv handles.
Expand Down Expand Up @@ -90,7 +98,7 @@ function createUdpHandle(childData) {

function createNamedPipeHandle(childData) {
const net = require('net');
const sockPath = `${common.PIPE}-listen-path-test-report-uv-handles`;
const sockPath = `${pipeName(true)}-listen-path-test-report-uv-handles`;
return new Promise((resolve) => {
const server = net.createServer((socket) => {
childData.pipe_sock_path = server.address();
Expand Down Expand Up @@ -202,15 +210,16 @@ if (process.argv[2] === 'child') {
// 1. The server's listening pipe.
// 2. The inbound pipe making the request.
// 3. The outbound pipe sending the response.
//
// There is no way to distinguish inbound and outbound in a cross
// platform manner, so we just check inbound here.
const sockPath = child_data.pipe_sock_path;
if (handle.localEndpoint === sockPath) {
if (handle.writable === false) {
found_named_pipe.push('listening');
} else {
found_named_pipe.push('inbound');
}
} else if (handle.remoteEndpoint === sockPath) {
found_named_pipe.push('outbound');
found_named_pipe.push('inbound');
}
}),
process: common.mustCall(function process_validator(handle) {
Expand Down Expand Up @@ -251,7 +260,7 @@ if (process.argv[2] === 'child') {
assert(handle.is_referenced);
}, 2),
};
console.log(report.libuv);

for (const entry of report.libuv) {
if (validators[entry.type]) validators[entry.type](entry);
}
Expand All @@ -261,7 +270,7 @@ if (process.argv[2] === 'child') {
for (const socket of ['connected', 'unconnected']) {
assert(found_udp.includes(socket), `${socket} UDP socket was not found`);
}
for (const socket of ['listening', 'inbound', 'outbound']) {
for (const socket of ['listening', 'inbound']) {
assert(found_named_pipe.includes(socket), `${socket} named pipe socket was not found`);
}

Expand Down