Skip to content

Commit

Permalink
Test in GHA CI, use make for InspectorXSLT for #72
Browse files Browse the repository at this point in the history
This change integrates the Makefile-based testing harness for each of
the submodules.

For the InspectorXSLT submodule in the schema-gen directory, integrate
the shell script that orchestrates Maven's installation of dependencies
and execution of XML Calabash to run XProc files. The XProc pipeline
files will run the XSpec tests in batch mode.
  • Loading branch information
aj-stein-nist committed Feb 2, 2024
1 parent 93e1cda commit e675ca9
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 7 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 5 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
28 changes: 28 additions & 0 deletions src/schema-gen/InspectorXSLT/Makefile
Original file line number Diff line number Diff line change
@@ -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)/*
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Modes to test:
</x:scenario>

<x:scenario label="[B] A simple but valid document (element) copies through">
<x:variable name="valid-file" select="document('../../../computer-valid/valid1.xml')"/>
<x:variable name="valid-file" href="../../computer-valid/valid1.xml"/>
<x:scenario label="[B.1] - A 'computer' document">
<!-- selecting '/' passes the root of the tree in as wanted, instead of the element alone. -->
<x:context select="/">
Expand Down
2 changes: 1 addition & 1 deletion src/testing/make_common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 4 additions & 3 deletions support/xspec-dev/mvn-saxon-xspec-batch.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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 <<EOF
Expand Down Expand Up @@ -66,12 +69,10 @@ ADDITIONAL_ARGS=$(echo "${*// /\\ }")
SAXON_ARGS="-it:go -xsl:\"${XSLT_FILE}\" -init:org.nineml.coffeesacks.RegisterCoffeeSacks \
stop-on-error=yes $ADDITIONAL_ARGS"

LOGFILE=xspec_$(date +"%Y%m%d%H%M").log.txt

echo "XSpec testing - logging to ${LOGFILE}"

# echo "${SAXON_ARGS}"

# set 2>/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}
Empty file modified support/xspec-dev/mvn-saxon-xspec-html.sh
100644 → 100755
Empty file.
Empty file modified support/xspec-dev/mvn-xproc-xspec-html.sh
100644 → 100755
Empty file.

0 comments on commit e675ca9

Please sign in to comment.