summaryrefslogtreecommitdiff
path: root/cli/tests/node_compat/test/parallel/test-fs-read-stream-inherit.js
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2024-02-10 13:22:13 -0700
committerGitHub <noreply@github.com>2024-02-10 20:22:13 +0000
commitf5e46c9bf2f50d66a953fa133161fc829cecff06 (patch)
tree8faf2f5831c1c7b11d842cd9908d141082c869a5 /cli/tests/node_compat/test/parallel/test-fs-read-stream-inherit.js
parentd2477f780630a812bfd65e3987b70c0d309385bb (diff)
chore: move cli/tests/ -> tests/ (#22369)
This looks like a massive PR, but it's only a move from cli/tests -> tests, and updates of relative paths for files. This is the first step towards aggregate all of the integration test files under tests/, which will lead to a set of integration tests that can run without the CLI binary being built. While we could leave these tests under `cli`, it would require us to keep a more complex directory structure for the various test runners. In addition, we have a lot of complexity to ignore various test files in the `cli` project itself (cargo publish exclusion rules, autotests = false, etc). And finally, the `tests/` folder will eventually house the `test_ffi`, `test_napi` and other testing code, reducing the size of the root repo directory. For easier review, the extremely large and noisy "move" is in the first commit (with no changes -- just a move), while the remainder of the changes to actual files is in the second commit.
Diffstat (limited to 'cli/tests/node_compat/test/parallel/test-fs-read-stream-inherit.js')
-rw-r--r--cli/tests/node_compat/test/parallel/test-fs-read-stream-inherit.js212
1 files changed, 0 insertions, 212 deletions
diff --git a/cli/tests/node_compat/test/parallel/test-fs-read-stream-inherit.js b/cli/tests/node_compat/test/parallel/test-fs-read-stream-inherit.js
deleted file mode 100644
index 2de42ffb5..000000000
--- a/cli/tests/node_compat/test/parallel/test-fs-read-stream-inherit.js
+++ /dev/null
@@ -1,212 +0,0 @@
-// deno-fmt-ignore-file
-// deno-lint-ignore-file
-
-// Copyright Joyent and Node contributors. All rights reserved. MIT license.
-// Taken from Node 18.12.1
-// This file is automatically generated by `tools/node_compat/setup.ts`. Do not modify this file manually.
-
-'use strict';
-
-const common = require('../common');
-
-const assert = require('assert');
-const fs = require('fs');
-const fixtures = require('../common/fixtures');
-
-const fn = fixtures.path('elipses.txt');
-const rangeFile = fixtures.path('x.txt');
-
-{
- let paused = false;
-
- const file = fs.ReadStream(fn);
-
- file.on('open', common.mustCall(function(fd) {
- file.length = 0;
- assert.strictEqual(typeof fd, 'number');
- assert.ok(file.readable);
-
- // GH-535
- file.pause();
- file.resume();
- file.pause();
- file.resume();
- }));
-
- file.on('data', common.mustCallAtLeast(function(data) {
- assert.ok(data instanceof Buffer);
- assert.ok(!paused);
- file.length += data.length;
-
- paused = true;
- file.pause();
-
- setTimeout(function() {
- paused = false;
- file.resume();
- }, 10);
- }));
-
-
- file.on('end', common.mustCall());
-
-
- file.on('close', common.mustCall(function() {
- assert.strictEqual(file.length, 30000);
- }));
-}
-
-{
- const file = fs.createReadStream(fn, Object.create({ encoding: 'utf8' }));
- file.length = 0;
- file.on('data', function(data) {
- assert.strictEqual(typeof data, 'string');
- file.length += data.length;
-
- for (let i = 0; i < data.length; i++) {
- // http://www.fileformat.info/info/unicode/char/2026/index.htm
- assert.strictEqual(data[i], '\u2026');
- }
- });
-
- file.on('close', common.mustCall(function() {
- assert.strictEqual(file.length, 10000);
- }));
-}
-
-{
- const options = Object.create({ bufferSize: 1, start: 1, end: 2 });
- const file = fs.createReadStream(rangeFile, options);
- assert.strictEqual(file.start, 1);
- assert.strictEqual(file.end, 2);
- let contentRead = '';
- file.on('data', function(data) {
- contentRead += data.toString('utf-8');
- });
- file.on('end', common.mustCall(function() {
- assert.strictEqual(contentRead, 'yz');
- }));
-}
-
-{
- const options = Object.create({ bufferSize: 1, start: 1 });
- const file = fs.createReadStream(rangeFile, options);
- assert.strictEqual(file.start, 1);
- file.data = '';
- file.on('data', function(data) {
- file.data += data.toString('utf-8');
- });
- file.on('end', common.mustCall(function() {
- assert.strictEqual(file.data, 'yz\n');
- }));
-}
-
-// https://github.com/joyent/node/issues/2320
-{
- const options = Object.create({ bufferSize: 1.23, start: 1 });
- const file = fs.createReadStream(rangeFile, options);
- assert.strictEqual(file.start, 1);
- file.data = '';
- file.on('data', function(data) {
- file.data += data.toString('utf-8');
- });
- file.on('end', common.mustCall(function() {
- assert.strictEqual(file.data, 'yz\n');
- }));
-}
-
-{
- const message =
- 'The value of "start" is out of range. It must be <= "end" (here: 2).' +
- ' Received 10';
-
- assert.throws(
- () => {
- fs.createReadStream(rangeFile, Object.create({ start: 10, end: 2 }));
- },
- {
- code: 'ERR_OUT_OF_RANGE',
- message,
- name: 'RangeError'
- });
-}
-
-{
- const options = Object.create({ start: 0, end: 0 });
- const stream = fs.createReadStream(rangeFile, options);
- assert.strictEqual(stream.start, 0);
- assert.strictEqual(stream.end, 0);
- stream.data = '';
-
- stream.on('data', function(chunk) {
- stream.data += chunk;
- });
-
- stream.on('end', common.mustCall(function() {
- assert.strictEqual(stream.data, 'x');
- }));
-}
-
-// Pause and then resume immediately.
-{
- const pauseRes = fs.createReadStream(rangeFile);
- pauseRes.pause();
- pauseRes.resume();
-}
-
-{
- let data = '';
- let file =
- fs.createReadStream(rangeFile, Object.create({ autoClose: false }));
- assert.strictEqual(file.autoClose, false);
- file.on('data', (chunk) => { data += chunk; });
- file.on('end', common.mustCall(function() {
- process.nextTick(common.mustCall(function() {
- assert(!file.closed);
- assert(!file.destroyed);
- assert.strictEqual(data, 'xyz\n');
- fileNext();
- }));
- }));
-
- function fileNext() {
- // This will tell us if the fd is usable again or not.
- file = fs.createReadStream(null, Object.create({ fd: file.fd, start: 0 }));
- file.data = '';
- file.on('data', function(data) {
- file.data += data;
- });
- file.on('end', common.mustCall(function() {
- assert.strictEqual(file.data, 'xyz\n');
- }));
- }
- process.on('exit', function() {
- assert(file.closed);
- assert(file.destroyed);
- });
-}
-
-// Just to make sure autoClose won't close the stream because of error.
-{
- const options = Object.create({ fd: 13337, autoClose: false });
- const file = fs.createReadStream(null, options);
- file.on('data', common.mustNotCall());
- file.on('error', common.mustCall());
- process.on('exit', function() {
- assert(!file.closed);
- assert(!file.destroyed);
- assert(file.fd);
- });
-}
-
-// Make sure stream is destroyed when file does not exist.
-{
- const file = fs.createReadStream('/path/to/file/that/does/not/exist');
- file.on('data', common.mustNotCall());
- file.on('error', common.mustCall());
-
- process.on('exit', function() {
- assert(file.closed);
- assert(file.destroyed);
- });
-}