From 9d40aef73605f1af275807666fba67348653a359 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Sat, 28 Jan 2023 18:50:07 +0100 Subject: [PATCH] test: s390x zlib test case fixes This is similar to https://github.com/nodejs/node/pull/44117 and addresses the indeterminate nature of the hardware accelerated compression. PR-URL: https://github.com/nodejs/node/pull/46367 Reviewed-By: Luigi Pinca Reviewed-By: Michael Dawson --- .../test-whatwg-webstreams-compression.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-whatwg-webstreams-compression.js b/test/parallel/test-whatwg-webstreams-compression.js index 6d3d6253bd1b86..859df4e07bed88 100644 --- a/test/parallel/test-whatwg-webstreams-compression.js +++ b/test/parallel/test-whatwg-webstreams-compression.js @@ -20,11 +20,19 @@ async function test(format) { const reader = gunzip.readable.getReader(); const writer = gzip.writable.getWriter(); + const compressed_data = []; + const reader_function = ({ value, done }) => { + if (value) + compressed_data.push(value); + if (!done) + return reader.read().then(reader_function); + assert.strictEqual(dec.decode(Buffer.concat(compressed_data)), 'hello'); + }; + const reader_promise = reader.read().then(reader_function); + await Promise.all([ - reader.read().then(({ value, done }) => { - assert.strictEqual(dec.decode(value), 'hello'); - }), - reader.read().then(({ done }) => assert(done)), + reader_promise, + reader_promise.then(() => reader.read().then(({ done }) => assert(done))), writer.write('hello'), writer.close(), ]);