diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..262951e4 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,34 @@ +name: CI +on: + push: + branches: + - main + - dev + pull_request: {} +env: + JAVA_VERSION: "17" + JAVA_DISTRIBUTION: "temurin" +jobs: + deploy: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + - uses: actions/setup-java@v3 + with: + distribution: "${{ env.JAVA_DISTRIBUTION }}" + java-version: "${{ env.JAVA_VERSION }}" + - name: Run unit tests + run: | + make -C src unit-test + id: unit-tests + - name: Run integration tests + run: | + make -C src smoke-test + id: integration-tests + - name: Run specification tests + run: | + make -C src spec-test + id: spec-tests diff --git a/src/Makefile b/src/Makefile index 5c46f596..71cdcad9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,10 @@ include testing/make_common.mk -# Each subdirectory that has a makefile -dirs:=$(dir $(wildcard ./*/Makefile)) +# Each subdirectory (recursively) that has a makefile +# Makefile wildcard function does not support that, so we use the shell +# function with the find utility and look ever Makefile in a child dir +# relative to this one, but exclude this one to use with the FOREACH macro. +dirs:=$(shell find '.' ! -wholename ./Makefile -name 'Makefile' -printf "%h\n") .PHONY: test test: ## Run all tests diff --git a/src/schema-gen/InspectorXSLT/Makefile b/src/schema-gen/InspectorXSLT/Makefile new file mode 100644 index 00000000..37d4de60 --- /dev/null +++ b/src/schema-gen/InspectorXSLT/Makefile @@ -0,0 +1,28 @@ +include ../../testing/make_common.mk + +module_path:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) +output_folder:=$(module_path)/test_output +xspec_script=$(realpath $(module_path)/../../../support/xspec-dev/mvn-saxon-xspec-batch.sh) + +.PHONY: test +test: unit-test smoke-test ## Run all tests + +.PHONY: unit-test +unit-test: ## Run all unit-tests + LOGFILE="$(output_folder)/unit-tests.log" $(xspec_script) \ + "baseURI=file:$(xspec_script)" \ + "folder=$(module_path)/testing/tests/inspector-functional-xspec" \ + "report-to=$(output_folder)/unit-tests_report.html" \ + "recurse=yes" + +.PHONY: smoke-test +smoke-test: ## Run all smoke-tests + LOGFILE="$(output_folder)/integration-tests.log" $(xspec_script) \ + "baseURI=file:$(xspec_script)" \ + "folder=$(module_path)/testing/tests/inspector-generation-xspec" \ + "report-to=$(output_folder)/integration-tests_report.html" \ + "recurse=yes" + +.PHONY: clean +clean: ## Remove test output + rm -fr $(output_folder)/* \ No newline at end of file diff --git a/src/schema-gen/InspectorXSLT/testing/tests/inspector-functional-xspec/xspec-patterns.xspec b/src/schema-gen/InspectorXSLT/testing/tests/inspector-functional-xspec/xspec-patterns.xspec index 01fd6ed6..98ebd6e7 100644 --- a/src/schema-gen/InspectorXSLT/testing/tests/inspector-functional-xspec/xspec-patterns.xspec +++ b/src/schema-gen/InspectorXSLT/testing/tests/inspector-functional-xspec/xspec-patterns.xspec @@ -55,7 +55,7 @@ Modes to test: - + diff --git a/src/testing/make_common.mk b/src/testing/make_common.mk index a7a5bdd1..99ca0c91 100644 --- a/src/testing/make_common.mk +++ b/src/testing/make_common.mk @@ -53,5 +53,5 @@ endef # Run a Makefile target for each directory, skipping directories whose Makefile does not contain a rule define FOREACH_MAKE_OPTIONAL @echo Running makefile target \'$1\' on all subdirectory makefiles that contain the rule - @$(call FOREACH,dir,$2,$(MAKE) -C $$dir -n $1 &> /dev/null && $(MAKE) -C $$dir $1 || echo "Makefile target '$1' does not exist in "$$dir". Continuing...") + @$(call FOREACH,dir,$2,$(MAKE) -C $$dir -n $1 &> /dev/null && $(MAKE) -C $$dir $1 || echo "Makefile target '$1' failed or does not exist in "$$dir". Continuing...") endef diff --git a/support/xspec-dev/mvn-saxon-xspec-batch.sh b/support/xspec-dev/mvn-saxon-xspec-batch.sh old mode 100644 new mode 100755 index 24548edb..b614cff0 --- a/support/xspec-dev/mvn-saxon-xspec-batch.sh +++ b/support/xspec-dev/mvn-saxon-xspec-batch.sh @@ -1,11 +1,14 @@ #!/usr/bin/env bash +set -o pipefail + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=../common/subcommand_common.bash source "$SCRIPT_DIR/../../src/common/subcommand_common.bash" XSLT_FILE="${SCRIPT_DIR}/XSPEC-BATCH.xsl" +LOGFILE=${LOGFILE:-"xspec_$(date +"%Y%m%d%H%M").log.txt"} usage() { cat </dev/null to drop all runtime messages / progress reports instead of logging # the process should error out only if stop-on-error=yes, otherwise it will do its best to complete -invoke_saxon "${SAXON_ARGS}" 2>${LOGFILE} || echo_on_error "Errors encountered running XSpec - check log file" +invoke_saxon "${SAXON_ARGS}" 2>&1 | tee ${LOGFILE} diff --git a/support/xspec-dev/mvn-saxon-xspec-html.sh b/support/xspec-dev/mvn-saxon-xspec-html.sh old mode 100644 new mode 100755 diff --git a/support/xspec-dev/mvn-xproc-xspec-html.sh b/support/xspec-dev/mvn-xproc-xspec-html.sh old mode 100644 new mode 100755