From 6db35e80794d1a4401db3cbc23e0c286b3cd20d2 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 15 Jun 2017 13:29:30 +0200 Subject: [PATCH 1/6] test: check zlib version for createDeflateRaw We are currenly builing Node with --shared-zlib which happens to be version 1.2.8. The test for zlib.createDeflateRaw is expected to fail but does not when using version 1.2.8. As far as I can tell the fix referred to in the comments was introduced in version 1.2.9: - Reject a window size of 256 bytes if not using the zlib wrapper This commit suggests adding a check for the version and skipping this assert if the version is less than 1.2.9. Refs: http://zlib.net/ChangeLog.txt --- test/parallel/test-zlib-failed-init.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-zlib-failed-init.js b/test/parallel/test-zlib-failed-init.js index 3b6da1d4fb840f..4ec8218a67c2f8 100644 --- a/test/parallel/test-zlib-failed-init.js +++ b/test/parallel/test-zlib-failed-init.js @@ -8,9 +8,11 @@ const zlib = require('zlib'); // For raw deflate encoding, requests for 256-byte windows are rejected as // invalid by zlib. // (http://zlib.net/manual.html#Advanced) -assert.throws(() => { - zlib.createDeflateRaw({ windowBits: 8 }); -}, /^Error: Init error$/); +if (process.versions.zlib.match(/^\d+\.\d+\.[9]|\d{2,}$/)) { + assert.throws(() => { + zlib.createDeflateRaw({ windowBits: 8 }); + }, /^Error: Init error$/); +} // Regression tests for bugs in the validation logic. From 7e61bcfabbacd78d4e9b2535eee255b535a9fdfb Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 15 Jun 2017 20:16:07 +0200 Subject: [PATCH 2/6] add comment about the version check --- test/parallel/test-zlib-failed-init.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-zlib-failed-init.js b/test/parallel/test-zlib-failed-init.js index 4ec8218a67c2f8..e962d614ebd5f5 100644 --- a/test/parallel/test-zlib-failed-init.js +++ b/test/parallel/test-zlib-failed-init.js @@ -6,8 +6,10 @@ const assert = require('assert'); const zlib = require('zlib'); // For raw deflate encoding, requests for 256-byte windows are rejected as -// invalid by zlib. -// (http://zlib.net/manual.html#Advanced) +// invalid by zlib (http://zlib.net/manual.html#Advanced). +// This check was introduced in vesion 1.2.9 and prior to that there was +// no such rejection which is the reason for the version check below +// (http://zlib.net/ChangeLog.txt). if (process.versions.zlib.match(/^\d+\.\d+\.[9]|\d{2,}$/)) { assert.throws(() => { zlib.createDeflateRaw({ windowBits: 8 }); From a6365bf5984f7ac70872596f1f700f8d86621d12 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 15 Jun 2017 20:39:30 +0200 Subject: [PATCH 3/6] use test() instead of match() --- test/parallel/test-zlib-failed-init.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-zlib-failed-init.js b/test/parallel/test-zlib-failed-init.js index e962d614ebd5f5..615ca76708df34 100644 --- a/test/parallel/test-zlib-failed-init.js +++ b/test/parallel/test-zlib-failed-init.js @@ -10,7 +10,7 @@ const zlib = require('zlib'); // This check was introduced in vesion 1.2.9 and prior to that there was // no such rejection which is the reason for the version check below // (http://zlib.net/ChangeLog.txt). -if (process.versions.zlib.match(/^\d+\.\d+\.[9]|\d{2,}$/)) { +if (/^\d+\.\d+\.[9]|\d{2,}$/.test(process.versions.zlib)) { assert.throws(() => { zlib.createDeflateRaw({ windowBits: 8 }); }, /^Error: Init error$/); From b9833a1da110a44ddd3bbe9cfcee8002d7bb7ae9 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 16 Jun 2017 05:44:54 +0200 Subject: [PATCH 4/6] update regex to check for invalid version --- test/parallel/test-zlib-failed-init.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-zlib-failed-init.js b/test/parallel/test-zlib-failed-init.js index 615ca76708df34..da30e83c64be7f 100644 --- a/test/parallel/test-zlib-failed-init.js +++ b/test/parallel/test-zlib-failed-init.js @@ -10,7 +10,7 @@ const zlib = require('zlib'); // This check was introduced in vesion 1.2.9 and prior to that there was // no such rejection which is the reason for the version check below // (http://zlib.net/ChangeLog.txt). -if (/^\d+\.\d+\.[9]|\d{2,}$/.test(process.versions.zlib)) { +if ((/^(?!1\.2\.[0-8]$)/.test(process.versions.zlib))) { assert.throws(() => { zlib.createDeflateRaw({ windowBits: 8 }); }, /^Error: Init error$/); From aa525e422c25f4ce5fc082dd9ae1fe8ba7238337 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Sun, 18 Jun 2017 11:32:03 +0200 Subject: [PATCH 5/6] simplify regex --- test/parallel/test-zlib-failed-init.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-zlib-failed-init.js b/test/parallel/test-zlib-failed-init.js index da30e83c64be7f..6d51776e8f2afe 100644 --- a/test/parallel/test-zlib-failed-init.js +++ b/test/parallel/test-zlib-failed-init.js @@ -10,7 +10,7 @@ const zlib = require('zlib'); // This check was introduced in vesion 1.2.9 and prior to that there was // no such rejection which is the reason for the version check below // (http://zlib.net/ChangeLog.txt). -if ((/^(?!1\.2\.[0-8]$)/.test(process.versions.zlib))) { +if (!/^1\.2\.[0-8]$/.test(process.versions.zlib)) { assert.throws(() => { zlib.createDeflateRaw({ windowBits: 8 }); }, /^Error: Init error$/); From 1441b2175fc404e697ef1a2ae585286b38889535 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Sun, 18 Jun 2017 11:50:42 +0200 Subject: [PATCH 6/6] fix spelling of version --- test/parallel/test-zlib-failed-init.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-zlib-failed-init.js b/test/parallel/test-zlib-failed-init.js index 6d51776e8f2afe..4f224ecd616ec7 100644 --- a/test/parallel/test-zlib-failed-init.js +++ b/test/parallel/test-zlib-failed-init.js @@ -7,7 +7,7 @@ const zlib = require('zlib'); // For raw deflate encoding, requests for 256-byte windows are rejected as // invalid by zlib (http://zlib.net/manual.html#Advanced). -// This check was introduced in vesion 1.2.9 and prior to that there was +// This check was introduced in version 1.2.9 and prior to that there was // no such rejection which is the reason for the version check below // (http://zlib.net/ChangeLog.txt). if (!/^1\.2\.[0-8]$/.test(process.versions.zlib)) {