diff options
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | testsuite/Testschema/test_schema.py | 11 | ||||
-rwxr-xr-x | testsuite/install.sh | 20 |
3 files changed, 30 insertions, 3 deletions
diff --git a/.travis.yml b/.travis.yml index 4f96bc5b8..c8f0c4c71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,5 +42,7 @@ addons: cache: directories: - $HOME/.cache/pip + - $HOME/.cache/xml before_cache: - rm -f $HOME/.cache/pip/log/debug.log + - rm -f $HOME/.cache/xml/catalog.xml diff --git a/testsuite/Testschema/test_schema.py b/testsuite/Testschema/test_schema.py index cd9b74cdf..138468a91 100644 --- a/testsuite/Testschema/test_schema.py +++ b/testsuite/Testschema/test_schema.py @@ -34,13 +34,18 @@ NSMAP = dict(xs=XS) class TestSchemas(Bcfg2TestCase): schema_url = "http://www.w3.org/2001/XMLSchema.xsd" + catalog_file = os.path.expanduser("~/.cache/xml/catalog.xml") @skipUnless(HAS_XMLLINT, "xmllint not installed") def test_valid(self): + env = os.environ.copy() + if os.path.exists(self.catalog_file): + print('Using cached schema files.') + env["SGML_CATALOG_FILES"] = self.catalog_file schemas = [s for s in glob.glob(os.path.join(srcpath, '*.xsd'))] - xmllint = Popen(['xmllint', '--xinclude', '--noout', '--schema', - self.schema_url] + schemas, - stdout=PIPE, stderr=STDOUT) + xmllint = Popen(['xmllint', '--xinclude', '--noout', '--catalogs', + '--schema', self.schema_url] + schemas, + stdout=PIPE, stderr=STDOUT, env=env) print(xmllint.communicate()[0].decode()) self.assertEqual(xmllint.wait(), 0) diff --git a/testsuite/install.sh b/testsuite/install.sh index 6f182bc0a..1c9cc36b9 100755 --- a/testsuite/install.sh +++ b/testsuite/install.sh @@ -23,3 +23,23 @@ if [[ "$WITH_OPTIONAL_DEPS" == "yes" ]]; then fi fi fi + +# Setup the local xml schema cache +download_schema() { + if [[ ! -e "$1" ]]; then + wget -O "$1" "$2" + fi +} + +mkdir -p "$HOME/.cache/xml/" +download_schema "$HOME/.cache/xml/XMLSchema.xsd" "http://www.w3.org/2001/XMLSchema.xsd" +download_schema "$HOME/.cache/xml/xml.xsd" "http://www.w3.org/2001/xml.xsd" + +cat > "$HOME/.cache/xml/catalog.xml" <<EOF +<?xml version="1.0"?> +<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> + <system systemId="http://www.w3.org/2001/XMLSchema.xsd" uri="$HOME/.cache/xml/XMLSchema.xsd" /> + <system systemId="http://www.w3.org/2001/xml.xsd" uri="$HOME/.cache/xml/xml.xsd" /> + <nextCatalog catalog="/etc/xml/catalog.xml" /> +</catalog> +EOF |