libxml2: convert to new stand-alone test process (#37694)
This commit is contained in:
parent
cb23362b7f
commit
95ca9dea89
@ -4,9 +4,6 @@
|
|||||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import llnl.util.filesystem as fs
|
|
||||||
import llnl.util.tty as tty
|
|
||||||
|
|
||||||
from spack.build_systems import autotools, nmake
|
from spack.build_systems import autotools, nmake
|
||||||
from spack.package import *
|
from spack.package import *
|
||||||
|
|
||||||
@ -101,41 +98,91 @@ def patch(self):
|
|||||||
)
|
)
|
||||||
filter_file("-Wno-long-long -Wno-format-extra-args", "", "configure")
|
filter_file("-Wno-long-long -Wno-format-extra-args", "", "configure")
|
||||||
|
|
||||||
def test(self):
|
def test_import(self):
|
||||||
"""Perform smoke tests on the installed package"""
|
"""import module test"""
|
||||||
# Start with what we already have post-install
|
if "+python" not in self.spec:
|
||||||
tty.msg("test: Performing simple import test")
|
raise SkipTest("Package must be built with +python")
|
||||||
self.builder.import_module_test()
|
|
||||||
|
with working_dir("spack-test", create=True):
|
||||||
|
python("-c", "import libxml2")
|
||||||
|
|
||||||
|
def test_xmlcatalog(self):
|
||||||
|
"""check minimal creation output"""
|
||||||
|
path = self.prefix.bin.xmlcatalog
|
||||||
|
if not os.path.exists(path):
|
||||||
|
raise SkipTest("xmlcatalog is not installed")
|
||||||
|
|
||||||
|
xmlcatalog = which(path)
|
||||||
|
out = xmlcatalog("--create", output=str.split, error=str.split)
|
||||||
|
|
||||||
|
expected = [r"<catalog xmlns", r'catalog"/>']
|
||||||
|
check_outputs(expected, out)
|
||||||
|
|
||||||
|
def test_xml2_config(self):
|
||||||
|
"""check version output"""
|
||||||
|
path = join_path(self.prefix.bin, "xml2-config")
|
||||||
|
if not os.path.exists(path):
|
||||||
|
raise SkipTest("xml2-config is not installed")
|
||||||
|
|
||||||
|
xml2_config = which(path)
|
||||||
|
out = xml2_config("--version", output=str.split, error=str.split)
|
||||||
|
assert str(self.spec.version) in out
|
||||||
|
|
||||||
|
def test_xmllint(self):
|
||||||
|
"""run xmllint generation and validation checks"""
|
||||||
|
path = self.prefix.bin.xmllint
|
||||||
|
if not os.path.exists(path):
|
||||||
|
raise SkipTest("xmllint is not installed")
|
||||||
|
|
||||||
|
test_filename = "test.xml"
|
||||||
|
xmllint = which(path)
|
||||||
|
|
||||||
|
with test_part(self, "test_xmllint_auto", purpose="generate {0}".format(test_filename)):
|
||||||
|
xmllint("--auto", "-o", test_filename)
|
||||||
|
|
||||||
|
with test_part(
|
||||||
|
self,
|
||||||
|
"test_xmllint_validate_no_dtd",
|
||||||
|
purpose="validate {0} without a DTD".format(test_filename),
|
||||||
|
):
|
||||||
|
out = xmllint(
|
||||||
|
"--postvalid",
|
||||||
|
test_filename,
|
||||||
|
output=str.split,
|
||||||
|
error=str.split,
|
||||||
|
fail_on_error=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
expected = [r"validity error", r"no DTD found", r"does not validate"]
|
||||||
|
check_outputs(expected, out)
|
||||||
|
|
||||||
data_dir = self.test_suite.current_test_data_dir
|
data_dir = self.test_suite.current_test_data_dir
|
||||||
|
|
||||||
# Now run defined tests based on expected executables
|
|
||||||
dtd_path = data_dir.join("info.dtd")
|
dtd_path = data_dir.join("info.dtd")
|
||||||
test_filename = "test.xml"
|
|
||||||
exec_checks = {
|
|
||||||
"xml2-config": [("--version", [str(self.spec.version)], 0)],
|
|
||||||
"xmllint": [
|
|
||||||
(["--auto", "-o", test_filename], [], 0),
|
|
||||||
(
|
|
||||||
["--postvalid", test_filename],
|
|
||||||
["validity error", "no DTD found", "does not validate"],
|
|
||||||
3,
|
|
||||||
),
|
|
||||||
(
|
|
||||||
["--dtdvalid", dtd_path, test_filename],
|
|
||||||
["validity error", "does not follow the DTD"],
|
|
||||||
3,
|
|
||||||
),
|
|
||||||
(["--dtdvalid", dtd_path, data_dir.join("info.xml")], [], 0),
|
|
||||||
],
|
|
||||||
"xmlcatalog": [("--create", ["<catalog xmlns", 'catalog"/>'], 0)],
|
|
||||||
}
|
|
||||||
for exe in exec_checks:
|
|
||||||
for options, expected, status in exec_checks[exe]:
|
|
||||||
self.run_test(exe, options, expected, status)
|
|
||||||
|
|
||||||
# Perform some cleanup
|
with test_part(
|
||||||
fs.force_remove(test_filename)
|
self,
|
||||||
|
"test_xmllint_validate_with_dtd",
|
||||||
|
purpose="validate {0} with a DTD".format(test_filename),
|
||||||
|
):
|
||||||
|
out = xmllint(
|
||||||
|
"--dtdvalid",
|
||||||
|
dtd_path,
|
||||||
|
test_filename,
|
||||||
|
output=str.split,
|
||||||
|
error=str.split,
|
||||||
|
fail_on_error=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
expected = [r"validity error", r"does not follow the DTD"]
|
||||||
|
check_outputs(expected, out)
|
||||||
|
|
||||||
|
test_filename = data_dir.join("info.xml")
|
||||||
|
with test_part(
|
||||||
|
self,
|
||||||
|
"test_xmllint_validate_works",
|
||||||
|
purpose="validate {0} with a DTD".format(test_filename),
|
||||||
|
):
|
||||||
|
xmllint("--dtdvalid", dtd_path, data_dir.join("info.xml"))
|
||||||
|
|
||||||
|
|
||||||
class RunAfter(object):
|
class RunAfter(object):
|
||||||
|
Loading…
Reference in New Issue
Block a user