Richard W.M. Jones wrote:
The four examples are from some guests I have running locally. They
all validate against the RELAX NG schema, according to xmllint.
...
Subject: [PATCH 2/2] inspector: Add tests for RELAX NG schema.
...
diff --git a/inspector/Makefile.am b/inspector/Makefile.am
index c8ebaf7..25f5e3c 100644
--- a/inspector/Makefile.am
+++ b/inspector/Makefile.am
@@ -17,12 +17,17 @@
EXTRA_DIST = \
run-inspector-locally \
- virt-inspector
+ virt-inspector \
+ virt-inspector.rng \
+ example1.xml example2.xml example3.xml example4.xml
There's no need to add these in EXTRA_DIST, since...
if HAVE_INSPECTOR
bin_SCRIPTS = virt-inspector
man_MANS = virt-inspector.1
+dist_doc_DATA = \
+ virt-inspector.rng \
+ example1.xml example2.xml example3.xml example4.xml
...adding them in dist_doc_DATA already ensures they're
distributed (the "dist_" prefix).
noinst_DATA = $(top_builddir)/html/virt-inspector.1.html
@@ -42,4 +47,11 @@ $(top_builddir)/html/virt-inspector.1.html: virt-inspector
--outfile html/virt-inspector.1.html \
inspector/$<
+if HAVE_XMLLINT
+
+TESTS = example1.xml example2.xml example3.xml example4.xml
+TESTS_ENVIRONMENT = $(XMLLINT) --noout --relaxng virt-inspector.rng
This is a cute trick, and is fine if you're confident
this is the only type of test there will ever be in this
subdirectory. Otherwise, you might want to change it
to generate tiny scripts to accomplish the same task in a
way that will accommodate non-xml-related tests.
E.g., something like this:
-----------------------------------------------------------------------------
xml = example1.xml example2.xml example3.xml example4.xml
xml_sh = $(subst .xml,.sh,$(xml))
TESTS = $(xml_sh)
DISTCLEANFILES = $(xml_sh)
z = $(subst .sh,.xml,$@)
$(xml_sh): Makefile
( printf '%s\n' '#!/bin/sh' \
'exec $(XMLLINT) --noout --relaxng virt-inspector.rng $(z)'; \
) > $@-t && chmod a+x $@-t && mv $@-t $@
-----------------------------------------------------------------------------
Regarding conditional tests, how about
running them unconditionally, but making them
skip with a diagnostic when xmllint is not available, e.g.,
insert two more lines into each generated script:
( xmllint --version > /dev/null 2>&1 ) \
|| { echo "$0: skipping this test: xmllint is not available" exit 77; }
Then even if xmllint is not around at configure-time,
but is later installed, the tests *will* be run.
If you do this, you can drop the configure-time test, of course.