generated from usnistgov/opensource-repo
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some XSpec for testing CI/CD #9
Merged
Merged
Changes from 21 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f20161f
Mods to markdown XSLT; demo XSpec providing a pattern
wendellpiez 78ec245
Making tests slightly more transparent / refining approaches
wendellpiez 3146214
Pushing the capability boundary by including some iXML (not yet suppo…
wendellpiez 540ae10
Excluding the bad XSpec from Maven 'run-xspec/test' XSpec run, pendin…
wendellpiez 7aaee89
Readme improvements
wendellpiez cca704b
Corrected glitch in ixml demo
wendellpiez 252a534
Adding XSpec-dev pipeline and scripting support for XSpec
wendellpiez 3a3fc7c
Added scripting and 'make' infrastructure; XProc3 folder w/ Morgana a…
wendellpiez c870dd6
Adding the submodule directory now
wendellpiez 8c41469
Updated readme.md
wendellpiez 948f57e
Restoring 'target' exclusion to XSpec (we need it)
wendellpiez 1cdeabe
Trying adjusted pom.xml
wendellpiez e82d800
Placating a jealous (and zealous) robot
wendellpiez eb11252
More integration/testing and cleanup
wendellpiez 4cedf9b
demo Makefile in random-util showing an XSpec runtime
wendellpiez 0a50d8d
Adjustment to draft CI/CD logic (not yet in place)
wendellpiez f17abc2
Pegging XSpec submodule to 9cdf371 - v2.3.2
wendellpiez ca78883
Moving submodule, with updated paths
wendellpiez d82180d
Some Makefile demonstration
wendellpiez cb21ea4
Mostly editorial corrections and cleanup
wendellpiez 3120554
Some restoration work on scripts in directory-manifest, with demo run…
wendellpiez 80fd48a
Adding exclusion rule for CI/CD testing
wendellpiez 3b0ee9d
New Makefile logic bypasses bash scripting for resource management (w…
wendellpiez 5175b3b
oops, deleted the wrong stuff there!
wendellpiez 8257a47
Tightening testing and TESTING.md, with better demos
wendellpiez 2ab78c7
Further editorial adjustments
wendellpiez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "support/xspec"] | ||
path = lib/xspec | ||
url = https://github.com/xspec/xspec.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
include common/make_common.mk | ||
|
||
# We'd like to descend to 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 examine each Makefile in a child dir | ||
# relative to this one, excluding this one to use with the FOREACH macro. | ||
dirs:=$(shell find '.' ! -wholename ./Makefile -name 'Makefile' -printf "%h\n") | ||
|
||
# This enables project-level configuration. Each project's own Makefile | ||
# can arrange its own testing accordingly, while making it easy to expose new tests to | ||
# the CI/CD runtime, by using any of the targets provided for here. | ||
|
||
# Make logic modeled after an example provided by NW: we are still learning | ||
|
||
module_path:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) | ||
output_folder:=$(module_path)/test_output | ||
|
||
# $folder can be passed in as folder=[folder] | ||
folder?=. | ||
|
||
|
||
# See Makefile configuration in project files for examples of how to set up calls to 'make' | ||
# including wiring XSpec tests and wiring XSpec tests to these (top-level) targets | ||
|
||
|
||
.PHONY: test | ||
test: ## Run all tests | ||
$(call FOREACH_MAKE,$@,$(dirs)) | ||
|
||
|
||
.PHONY: pre-checks | ||
pre-checks: ## Run all "pre checks", enforcing validation contracts across input artifacts | ||
$(call FOREACH_MAKE_OPTIONAL,$@,$(dirs)) | ||
|
||
|
||
.PHONY: smoke-test | ||
smoke-test: ## Run all "smoke tests", establishing a baseline of sanity across the project | ||
$(call FOREACH_MAKE_OPTIONAL,$@,$(dirs)) | ||
|
||
|
||
.PHONY: spec-test | ||
spec-test: ## Run all "specification tests", validating an implementation against a spec | ||
$(call FOREACH_MAKE_OPTIONAL,$@,$(dirs)) | ||
|
||
|
||
.PHONY: unit-test | ||
unit-test: ## Run all unit tests (ci/cd) | ||
$(call FOREACH_MAKE_OPTIONAL,$@,$(dirs)) | ||
|
||
|
||
.PHONY: clean | ||
clean: ## Remove any generated test or build artifacts | ||
rm -fr $(output_folder)/* | ||
$(call FOREACH_MAKE_OPTIONAL,$@,$(dirs)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Common makefile utilities for the metaschema-xslt project | ||
# Note: any makefile including this file will have the following side-effects: | ||
# 1. The SHELL will be set to bash. | ||
# 2. A "help" target will be added. If the include statement is at the top the | ||
# default target will become "help" unless overridden with .DEFAULT_GOAL. | ||
# 3. The environment will be populated with the variables seen below | ||
|
||
# Gratefully adapted from an original by NW | ||
|
||
SHELL:=/usr/bin/env bash | ||
|
||
.PHONY: help | ||
# Run "make" or "make help" to get a list of user targets | ||
# Adapted from https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html | ||
# To include a target in the help text, follow the following format: | ||
# <target(s)>: [dependencies] ## Comment | ||
help: ## Show this help message | ||
@grep --no-filename -E '^[a-zA-Z_-]+:.*?##.*$$' $(MAKEFILE_LIST) | awk 'BEGIN { \ | ||
FS = ":.*?## "; \ | ||
printf "\033[1m%-30s\033[0m %s\n", "TARGET", "DESCRIPTION" \ | ||
} \ | ||
{ printf "\033[32m%-30s\033[0m %s\n", $$1, $$2 }' | ||
|
||
# The path to the Maven POM to use | ||
pom_path:=./pom.xml | ||
|
||
define EXEC_MAVEN | ||
mvn --quiet -f "${pom_path}" exec:java \ | ||
-Dexec.mainClass="$1" \ | ||
-Dexec.args="$2" | ||
endef | ||
|
||
# XML Calabash helper macro | ||
define EXEC_CALABASH | ||
$(call EXEC_MAVEN,com.xmlcalabash.drivers.Main,$1) | ||
endef | ||
|
||
# Saxon helper macro | ||
define EXEC_SAXON | ||
$(call EXEC_MAVEN,net.sf.saxon.Transform,$1) | ||
endef | ||
|
||
define FOREACH | ||
for $1 in $2; do {\ | ||
$3 ;\ | ||
} done | ||
endef | ||
|
||
# Run a Makefile target for each directory, requiring each directory to have a given target | ||
define FOREACH_MAKE | ||
@echo Running makefile target \'$1\' on all subdirectory makefiles | ||
@$(call FOREACH,dir,$2,$(MAKE) -C $$dir $1) | ||
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' failed or does not exist in "$$dir". Continuing...") | ||
endef |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Provides common functions for subcommands | ||
|
||
set -Eeuo pipefail | ||
|
||
# Each subcommand will require Maven to invoke calabash or saxon | ||
if ! [ -x "$(command -v mvn)" ]; then | ||
echo 'Error: Maven (mvn) is not in the PATH, is it installed?' >&2 | ||
exit 1 | ||
fi | ||
|
||
_SUBCOMMAND_COMMON_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
POM_FILE="${_SUBCOMMAND_COMMON_DIR}/pom.xml" | ||
|
||
function exec_maven() { | ||
mvn --quiet \ | ||
-f "$POM_FILE" \ | ||
exec:java \ | ||
-Dexec.mainClass="$1" \ | ||
-Dexec.args="$2" | ||
} | ||
|
||
CALABASH_MAIN_CLASS="com.xmlcalabash.drivers.Main" | ||
|
||
function invoke_calabash() { | ||
exec_maven "$CALABASH_MAIN_CLASS" "$@" | ||
} | ||
|
||
SAXON_MAIN_CLASS="net.sf.saxon.Transform" | ||
|
||
function invoke_saxon() { | ||
exec_maven "$SAXON_MAIN_CLASS" "$@" | ||
} | ||
|
||
# Clean up unneeded targets | ||
unset -f _SUBCOMMAND_COMMON_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<x:description xmlns="http://www.w3.org/1999/xhtml" xmlns:x3f="http://csrc.nist.gov/ns/xslt3-functions" | ||
xmlns:x="http://www.jenitennison.com/xslt/xspec" xmlns:xs="http://www.w3.org/2001/XMLSchema" | ||
stylesheet="html-to-markdown.xsl" xslt-version="3.0"> | ||
|
||
<!-- | ||
Purpose: A very basic XSpec to demonstrate principles and a pattern for testing | ||
HTML to Markdown conversion and mapping. | ||
|
||
Comprehensive coverage even of current functionality is not yet attempted. | ||
|
||
--> | ||
<x:scenario label="directory manifest - HTML to Markdown conversion"> | ||
<x:scenario label="Page structure"> | ||
<x:context> | ||
<html> | ||
<head> | ||
<title>A page</title> | ||
<style type="text/css">/* some style */</style> | ||
</head> | ||
<body> | ||
<h1>Frankenstein</h1> | ||
<h2>Or, the Modern Prometheus</h2> | ||
</body> | ||
</html> | ||
</x:context> | ||
<x:expect label="lets its contents through" xml:space="preserve"> | ||
|
||
# Frankenstein | ||
|
||
## Or, the Modern Prometheus</x:expect> | ||
</x:scenario> | ||
|
||
<x:scenario label="Basic p"> | ||
<x:context> | ||
<p>Four score and seven years ago --</p> | ||
</x:context> | ||
<x:expect label="comes through with line feeds" xml:space="preserve"> | ||
|
||
Four score and seven years ago --</x:expect> | ||
</x:scenario> | ||
|
||
<x:scenario label="Basic inlines"> | ||
<x:context>our fathers brought forth, on this continent, a <em>new nation</em>, conceived in <strong>Liberty</strong> and dedicated</x:context> | ||
<x:expect label="are mapped">our fathers brought forth, on this continent, a *new nation*, conceived in **Liberty** and dedicated</x:expect> | ||
</x:scenario> | ||
|
||
<x:scenario label="Code scrub"> | ||
<x:scenario label="A comment"> | ||
<x:variable name="x3f:a-comment"><!--comment--></x:variable> | ||
<x:context select="$x3f:a-comment"/> | ||
<x:expect label="is dropped" select="()"/> | ||
</x:scenario> | ||
<x:scenario label="A Processing instruction"> | ||
<x:context><?pi type="sample" href="file.css"?></x:context> | ||
<x:expect label="is dropped" select="()"/> | ||
</x:scenario> | ||
</x:scenario> | ||
</x:scenario> | ||
|
||
</x:description> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
support
should now saylib
, unlesssupport/
will still exist for other things. And "XSpec support in development" is at the top level now, isn't it?