summaryrefslogtreecommitdiff
path: root/cli/tests/node_compat/test/parallel/test-stream-readable-hwm-0-no-flow-data.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-stream-readable-hwm-0-no-flow-data.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-stream-readable-hwm-0-no-flow-data.js')
-rw-r--r--cli/tests/node_compat/test/parallel/test-stream-readable-hwm-0-no-flow-data.js111
1 files changed, 0 insertions, 111 deletions
diff --git a/cli/tests/node_compat/test/parallel/test-stream-readable-hwm-0-no-flow-data.js b/cli/tests/node_compat/test/parallel/test-stream-readable-hwm-0-no-flow-data.js
deleted file mode 100644
index 3d9c0507a..000000000
--- a/cli/tests/node_compat/test/parallel/test-stream-readable-hwm-0-no-flow-data.js
+++ /dev/null
@@ -1,111 +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');
-
-// Ensure that subscribing the 'data' event will not make the stream flow.
-// The 'data' event will require calling read() by hand.
-//
-// The test is written for the (somewhat rare) highWaterMark: 0 streams to
-// specifically catch any regressions that might occur with these streams.
-
-const assert = require('assert');
-const { Readable } = require('stream');
-
-const streamData = [ 'a', null ];
-
-// Track the calls so we can assert their order later.
-const calls = [];
-const r = new Readable({
- read: common.mustCall(() => {
- calls.push('_read:' + streamData[0]);
- process.nextTick(() => {
- calls.push('push:' + streamData[0]);
- r.push(streamData.shift());
- });
- }, streamData.length),
- highWaterMark: 0,
-
- // Object mode is used here just for testing convenience. It really
- // shouldn't affect the order of events. Just the data and its format.
- objectMode: true,
-});
-
-assert.strictEqual(r.readableFlowing, null);
-r.on('readable', common.mustCall(() => {
- calls.push('readable');
-}, 2));
-assert.strictEqual(r.readableFlowing, false);
-r.on('data', common.mustCall((data) => {
- calls.push('data:' + data);
-}, 1));
-r.on('end', common.mustCall(() => {
- calls.push('end');
-}));
-assert.strictEqual(r.readableFlowing, false);
-
-// The stream emits the events asynchronously but that's not guaranteed to
-// happen on the next tick (especially since the _read implementation above
-// uses process.nextTick).
-//
-// We use setImmediate here to give the stream enough time to emit all the
-// events it's about to emit.
-setImmediate(() => {
-
- // Only the _read, push, readable calls have happened. No data must be
- // emitted yet.
- assert.deepStrictEqual(calls, ['_read:a', 'push:a', 'readable']);
-
- // Calling 'r.read()' should trigger the data event.
- assert.strictEqual(r.read(), 'a');
- assert.deepStrictEqual(
- calls,
- ['_read:a', 'push:a', 'readable', 'data:a']);
-
- // The next 'read()' will return null because hwm: 0 does not buffer any
- // data and the _read implementation above does the push() asynchronously.
- //
- // Note: This 'null' signals "no data available". It isn't the end-of-stream
- // null value as the stream doesn't know yet that it is about to reach the
- // end.
- //
- // Using setImmediate again to give the stream enough time to emit all the
- // events it wants to emit.
- assert.strictEqual(r.read(), null);
- setImmediate(() => {
-
- // There's a new 'readable' event after the data has been pushed.
- // The 'end' event will be emitted only after a 'read()'.
- //
- // This is somewhat special for the case where the '_read' implementation
- // calls 'push' asynchronously. If 'push' was synchronous, the 'end' event
- // would be emitted here _before_ we call read().
- assert.deepStrictEqual(
- calls,
- ['_read:a', 'push:a', 'readable', 'data:a',
- '_read:null', 'push:null', 'readable']);
-
- assert.strictEqual(r.read(), null);
-
- // While it isn't really specified whether the 'end' event should happen
- // synchronously with read() or not, we'll assert the current behavior
- // ('end' event happening on the next tick after read()) so any changes
- // to it are noted and acknowledged in the future.
- assert.deepStrictEqual(
- calls,
- ['_read:a', 'push:a', 'readable', 'data:a',
- '_read:null', 'push:null', 'readable']);
- process.nextTick(() => {
- assert.deepStrictEqual(
- calls,
- ['_read:a', 'push:a', 'readable', 'data:a',
- '_read:null', 'push:null', 'readable', 'end']);
- });
- });
-});