From: Dmitry Volyntsev Date: Thu, 30 Nov 2023 02:43:37 +0000 (-0800) Subject: Tests: detection when "xml" module is disabled. X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=0a325322c4a965e6672381390cf4ef50bd5718e4;p=njs.git Tests: detection when "xml" module is disabled. --- diff --git a/test/harness/compatXml.js b/test/harness/compatXml.js index 465d95ea..cf3642c2 100644 --- a/test/harness/compatXml.js +++ b/test/harness/compatXml.js @@ -4,5 +4,14 @@ if (typeof require == 'function' && typeof njs == 'object' && typeof njs.version == 'string') { - xml = require('xml'); + try { + xml = require('xml'); + + } catch (e) { + // ignore + } +} + +function has_xml() { + return xml; } diff --git a/test/xml/external_entity_ignored.t.js b/test/xml/external_entity_ignored.t.js index 26ee2403..57c91e7f 100644 --- a/test/xml/external_entity_ignored.t.js +++ b/test/xml/external_entity_ignored.t.js @@ -11,8 +11,7 @@ let data = ` &c; `; -if (has_njs()) { - const xml = require('xml'); +if (has_njs() && has_xml()) { let doc = xml.parse(data); assert.sameValue(doc.$root.$text, ""); } diff --git a/test/xml/saml_verify.t.js b/test/xml/saml_verify.t.js index ec15c513..be6bae82 100644 --- a/test/xml/saml_verify.t.js +++ b/test/xml/saml_verify.t.js @@ -280,7 +280,7 @@ function p(args, default_opts) { let saml_verify_tsuite = { name: "SAML verify", - skip: () => (!has_njs() || !has_fs() || !has_webcrypto()), + skip: () => (!has_njs() || !has_fs() || !has_webcrypto() || !has_xml()), T: verify, prepare_args: p, opts: {