From bab0fc3bc784c1a25049ee89efcf80979c57f047 Mon Sep 17 00:00:00 2001 From: dbs Date: Wed, 14 Nov 2007 16:18:20 +0000 Subject: [PATCH 1/1] Add a basic 'make test' root Makefile target. The initial test suite validates the example XML files where a schema is available or checks files for well-formedness where a schema is not available. git-svn-id: svn://svn.open-ils.org/ILS/trunk@8061 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Makefile | 3 +++ Open-ILS/examples/Makefile | 48 ++++++++++++++++++++++++++++++++++++++ install.sh | 13 +++++++++-- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 Open-ILS/examples/Makefile diff --git a/Makefile b/Makefile index 2996d44e15..57c2c848d3 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ #!/bin/bash +# vim:noet:ts=4 # -------------------------------------------------------------------- # Copyright (C) 2005 Georgia Public Library Service # Bill Erickson @@ -39,3 +40,5 @@ install: clean: @./install.sh clean +test: + @./install.sh test diff --git a/Open-ILS/examples/Makefile b/Open-ILS/examples/Makefile new file mode 100644 index 0000000000..607184b5ee --- /dev/null +++ b/Open-ILS/examples/Makefile @@ -0,0 +1,48 @@ +# vim:noet:ts=4 +# +# This is a simple implementation of a test suite for XML validity +# (where possible) or well-formedness (if no schema is available) +# to ensure that our sample XML configuration files are reasonably +# clean. + +TESTIDL := $(shell xmllint --noout --schema fm_IDL.xsd fm_IDL.xml 2>&1 | wc -l) +TESTOSRF := $(shell xmllint --noout opensrf.xml 2>&1 | wc -l) +TESTOSRFCORE := $(shell xmllint --noout opensrf_core.xml 2>&1 | wc -l) + +test_idl: +TOTAL := $(TOTAL). +ifeq ($(TESTIDL), 1) +SUCCESS := $(SUCCESS). +else +$(warning fm_IDL.xml does not validate) +endif + +test_osrf: +TOTAL := $(TOTAL). +ifeq ($(TESTOSRF), 1) +SUCCESS := $(SUCCESS). +else +$(warning opensrf.xml is not well-formed) +endif + +test_osrf_core: +TOTAL := $(TOTAL). +ifeq ($(TESTOSRFCORE), 1) +SUCCESS := $(SUCCESS). +else +$(warning opensrf_core.xml is not well-formed) +endif + +test: test_idl test_osrf test_osrf_core +# First we count the number of characters returned +SUCCESSES ?= $(shell echo $(SUCCESS) | wc -m ) +FAILED ?= $(shell echo $(FAILURE) | wc -m ) +TOTALED ?= $(shell echo $(TOTAL) | wc -m ) +# Then we subtract one from the count to make it accurate +SUCCESSTESTS ?= $(shell echo $(SUCCESSES) - 1 | bc ) +FAILEDTESTS ?= $(shell echo $(FAILED) -1 | bc ) +TOTALTESTS ?= $(shell echo $(TOTALED) -1 | bc ) +$(info Succesful tests: $(SUCCESSTESTS)/$(TOTALTESTS)) +$(info Failed tests: $(FAILEDTESTS)/$(TOTALTESTS)) + + diff --git a/install.sh b/install.sh index 290496a5cf..8b57a24a1e 100755 --- a/install.sh +++ b/install.sh @@ -1,4 +1,5 @@ #!/bin/bash +# vim:noet:ts=4 # -------------------------------------------------------------------- # Copyright (C) 2005 Georgia Public Library Service # Bill Erickson @@ -82,6 +83,10 @@ function building { return 0; } +function testing { + if [ -z "$TESTING" ]; then return 1; fi; + return 0; +} # -------------------------------------------------------------------- @@ -129,6 +134,7 @@ function runInstall { "openils_all" ) if building; then $MAKE -C "$OPENILSDIR" all; fi; + if testing; then $MAKE -C "$OPENILSDIR/../examples" test; fi; if installing; then $MAKE -C "$OPENILSDIR" install; fi; ;; @@ -212,6 +218,7 @@ function runInstall { # clean - cleans all build files # build - builds the specified sources # install - installs the specified sources +# test - tests the specified sources # -------------------------------------------------------------------- function checkParams { @@ -235,6 +242,9 @@ function checkParams { "verbose") verbose="";; + "test") + TESTING="1";; + *) fail "Unknown option => $arg"; esac done @@ -257,6 +267,7 @@ function usage { checkParams "$@"; if building; then echo "Building..."; fi; +if testing; then echo "Testing..."; fi; if installing; then echo "Installing..."; fi; @@ -267,5 +278,3 @@ loadConfig; mkInstallDirs; runInstall; - - -- 2.43.2