Compare commits

...

2 Commits

Author SHA1 Message Date
Jarred Sumner
6fe762a1f4 Delete some failing ones 2025-06-15 20:45:10 +02:00
Jarred Sumner
caa1ff0cbc Add passingnode.js tests 2025-06-15 20:10:42 +02:00
3 changed files with 128 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const { Readable, pipeline } = require('stream');
const http2 = require('http2');
{
const server = http2.createServer((req, res) => {
pipeline(req, res, common.mustCall());
});
server.listen(0, () => {
const url = `http://localhost:${server.address().port}`;
const client = http2.connect(url);
const req = client.request({ ':method': 'POST' });
const rs = new Readable({
read() {
rs.push('hello');
}
});
pipeline(rs, req, common.mustCall((err) => {
server.close();
client.close();
}));
let cnt = 10;
req.on('data', (data) => {
cnt--;
if (cnt === 0) rs.destroy();
});
});
}

View File

@@ -0,0 +1,48 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const tls = require('tls');
const net = require('net');
const { fork } = require('child_process');
const tmpdir = require('../common/tmpdir');
// Run in a child process because the PIPE file descriptor stays open until
// Node.js completes, blocking the tmpdir and preventing cleanup.
if (process.argv[2] !== 'child') {
// Parent
tmpdir.refresh();
// Run test
const child = fork(__filename, ['child'], { stdio: 'inherit' });
child.on('exit', common.mustCall(function(code) {
assert.strictEqual(code, 0);
}));
return;
}
// Child
const server = net.createServer((c) => {
c.end();
}).listen(common.PIPE, common.mustCall(() => {
let errored = false;
tls.connect({ path: common.PIPE })
.once('error', common.mustCall((e) => {
assert.strictEqual(e.code, 'ECONNRESET');
assert.strictEqual(e.path, common.PIPE);
assert.strictEqual(e.port, undefined);
assert.strictEqual(e.host, undefined);
assert.strictEqual(e.localAddress, undefined);
server.close();
errored = true;
}))
.on('close', common.mustCall(() => {
assert.strictEqual(errored, true);
}));
}));

View File

@@ -0,0 +1,44 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
'use strict';
require('../common');
const assert = require('assert');
const vm = require('vm');
const spawn = require('child_process').spawn;
if (process.argv[2] === 'child') {
const code = 'while(true);';
const ctx = vm.createContext();
vm.runInContext(code, ctx, { timeout: 1 });
} else {
const proc = spawn(process.execPath, process.argv.slice(1).concat('child'));
let err = '';
proc.stderr.on('data', function(data) {
err += data;
});
process.on('exit', function() {
assert.match(err, /Script execution timed out after 1ms/);
});
}