Skip to content
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

More testing #122

Merged
merged 6 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/compose/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
include ../testing/make_common.mk

# INCLUDES:
# unit-test - unit testing - XSLT production templates for InspectorXSLT
# spec-test - specification conformance testing - functional runtime tests of the generated XSLT
# xspec - run XSpec tests in designated folder
# clean - clean up designated output folder

# for smoke testing see ../Makefile

# tbd - 'field testing' applying result JSON Schema to known 'working and broken' instances

module_path:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
output_folder:=$(module_path)/test_output
xspec_script=$(realpath $(module_path)/../../support/xslt3-functions/xspec-dev/mvn-saxon-xspec-batch-quiet.sh)
xspec_ci_script=$(realpath $(module_path)/../../support/xslt3-functions/xspec-dev/mvn-saxon-xspec-batch.sh)
folder=.

.PHONY: test
test: unit-test ## Run all tests

# just unit-test for now ...

.PHONY: unit-test
unit-test: ## Run all *.xspec in testing folder (and subfolders)
LOGFILE="$(output_folder)/composition-xspec.log" $(xspec_ci_script) \
"folder=$(module_path)/testing" \
"report-to=$(output_folder)/composition-xspec_report.html" \
"junit-to=$(output_folder)/composition-xspec_junit-report.xml" \
"stop-on-error=yes" \
"recurse=yes"

.PHONY: xspec
xspec: ## Run all *.xspec in a designated folder, quietly - use folder=[folder]
LOGFILE="$(output_folder)/xspec-tests.log" $(xspec_script) \
"baseURI=file:$(module_path)/" \
"folder=$(folder)" \
"report-to=$(output_folder)" \
"stop-on-error=no" \
"recurse=yes"

.PHONY: clean
clean: ## Remove test output
rm -fr $(output_folder)/*
2 changes: 1 addition & 1 deletion src/compose/testing/1_collected/collect.xspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<x:description xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
xmlns:opr="http://csrc.nist.gov/ns/oscal/profile-resolution" xmlns:x="http://www.jenitennison.com/xslt/xspec"
stylesheet="../../metaschema-collect.xsl">

<!-- metaschema-collect.xsl does two things:
- merges modular metaschemas into a single tree of metaschemas
(intelligently refusing to revisit the same URI twice)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@
</define-flag>
<METASCHEMA abstract="yes"
module="oscal-test-m1"
_base-uri="file:/C:/Users/wap1/Documents/usnistgov/metaschema/toolchains/xslt-M4/compose/testing/module_metaschema.xml">
_base-uri="...">
<schema-name>OSCAL TEST Format Module</schema-name>
<schema-version>0.0</schema-version>
<short-name>oscal-test-m1</short-name>
<namespace>http://csrc.nist.gov/ns/metaschema/test</namespace>
<define-assembly scope="global"
name="module-assembly"
module="oscal-test-m1"
_base-uri="file:/C:/Users/wap1/Documents/usnistgov/metaschema/toolchains/xslt-M4/compose/testing/module_metaschema.xml"
_base-uri="..."
_key-name="oscal-test-m1:module-assembly">
<formal-name>Assembly defined in a module</formal-name>
<description>XXX</description>
Expand Down Expand Up @@ -115,7 +115,7 @@
scope="global"
name="global-field"
module="oscal-test-m1"
_base-uri="file:/C:/Users/wap1/Documents/usnistgov/metaschema/toolchains/xslt-M4/compose/testing/module_metaschema.xml"
_base-uri="..."
_key-name="oscal-test-m1:global-field">
<formal-name>Field, defined in module 'oscal-test-m1' (global by default)</formal-name>
<description>XXX</description>
Expand All @@ -125,7 +125,7 @@
scope="local"
name="local-field"
module="oscal-test-m1"
_base-uri="file:/C:/Users/wap1/Documents/usnistgov/metaschema/toolchains/xslt-M4/compose/testing/module_metaschema.xml"
_base-uri="..."
_key-name="oscal-test-m1:local-field">
<formal-name>Field, defined in module 'oscal-test-m1' as local</formal-name>
<description>ZZZ</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<EXCEPTION problem-type="unused-definition">REMOVING unused assembly definition for 'unused-assembly' from nestedmessy.</EXCEPTION>
<define-assembly name="BOX" module="nestedmessy" _key-name="nestedmessy:BOX">
<formal-name>BOX</formal-name>
<description>An empty box</description>
<description>An empty box, the root of the model, should be copied</description>
<root-name>BOX</root-name>
<model/>
</define-assembly>
Expand Down
14 changes: 14 additions & 0 deletions src/metapath/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,17 @@ Provides for processing Metapath syntax and operations dependent on processing s
Modules here including `metapath-jsonize.xsl` and `docs-metapath.xsl` may be included or called into pipelines elsewhere in this library.

Provided XSpec tests along with inline code help to document the interfaces.

## Note to developers

This implementation was first built out of necessity, and includes functionality untested before its development, as well as machine-generated code whose ongoing reproduction may be problematic.

At the same time, since its inception, new capabilities in the XML stack, notably [Invisible XML](https://invisiblexml.org), provide a strong foundation for further work.

See also the related project repository hosting iXML support, the [iXML Breadboard](https://github.com/usnistgov/ixml-breadboard)

Accordingly, next steps might include a near-term migration onto an iXML-based implementation providing the same service.

For an iXML grammar, until a normative Metapath grammar is published, the alignment target is [the Metapath grammar](https://github.com/usnistgov/metaschema-java/blob/main/core/src/main/antlr4/metapath10.g4) supported in the metaschema-java project.

---
2 changes: 2 additions & 0 deletions src/testing/tinydata/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TinyData artifacts include schemas and conversion scripts to be refreshed by scripting
current/*
58 changes: 58 additions & 0 deletions src/testing/tinydata/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
include ../../testing/make_common.mk

module_path:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
metaschema_validate_xsd_script=$(realpath $(module_path)/../../validate/mvn-metaschema-xsd-validate-xpl.sh)
metaschema_validate_schematron_script=$(realpath $(module_path)/../../validate/mvn-composition-validate-xpl.sh)
pom_path:=../../../support/pom.xml

# Logic for TinyData testing

# Validate tiny_metaschema.xml


.PHONY: test
test: pre-checks ## Run pre-checks

# .PHONY: smoke-test
# smoke-test: pre-checks ## For this directory, run pre-checks for other processes


.PHONY: pre-checks
pre-checks: ## Validate tiny_metaschema.xml against Metaschema XSD and Schematron
$(metaschema_validate_xsd_script) tiny_metaschema.xml
$(metaschema_validate_schematron_script) tiny_metaschema.xml

.PHONY: refresh-tiny
refresh-tiny: refresh-tiny-schemas refresh-tiny-converters ## Refresh TinyData schemas and converter scripts

.PHONY: refresh-tiny-schemas
refresh-tiny-schemas: ## Refresh XSD and JSON Schemas for TinyData, in 'current'
$(realpath $(module_path)/refresh-tiny-schemas.sh)


.PHONY: refresh-tiny-converters
refresh-tiny-converters: ## Refresh XML-JSON converter XSLTs for TinyData, in 'current'
$(realpath $(module_path)/refresh-tiny-converters.sh)


# Generate schemas (call refresh-tiny-schemas.sh)
# including Composed metaschema, XSD, JSON Schema and InspectorXSLT
# place current/* into .gitignore
# Generate converters (call refresh-tiny-converters.sh)

.PHONY: tiny-css
tiny-css: ## Create boilerplate CSS for Tiny metaschema - also in 'current'
$(call EXEC_SAXON,-xsl:../../util/make-plain-CSS.xsl -s:tiny_metaschema.xml -o:current/tiny-boilerplate.css)


# Batch validation
# XSD, JSON Schema, Inspector

# Batch conversion - tiny-xsd-validate-set.sh

# Round trip conversion test
# Batch convert valid samples using current/*-converter.xsl
# XSpec this

# Which of all this go under CI/CD? allocate to smoke-test, unit-test etc.

13 changes: 4 additions & 9 deletions src/testing/tinydata/TINYDATA-MAKE-JSON.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,18 @@
<!-- Output: For each input file, an equivalent JSON in place with the same name. -->
<!-- Purpose: Batch-convert XML to JSON to support testing -->



<!-- &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& &&& -->
<!-- Ports -->

<p:input port="parameters" kind="parameter"/>


<p:input port="samples" sequence="true">

<p:document href="tiny-data/bigbadtiny.xml"/>
<p:document href="tiny-data/tiny1.xml"/>
</p:input>
<p:import href="tinydata-samples.xpl"/>

<metaschema:tinydata-samples name="getting-samples"/>

<p:for-each>
<p:iteration-source>
<p:pipe port="samples" step="TINYDATA-MAKE-JSON"/>
<p:pipe port="tinydata" step="getting-samples"/>
</p:iteration-source>
<p:variable name="base" select="base-uri(.)"/>

Expand Down
18 changes: 11 additions & 7 deletions src/testing/tinydata/TINYDATA-XSD-VALIDATE.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@

-->

<p:input port="samples" sequence="true">
<!-- for the XML, invalid documents are marked with a PI <?ERROR ?> to show an expectation of INVALID -->
<!--<p:input port="samples" sequence="true">
<!-\- for the XML, invalid documents are marked with a PI <?ERROR ?> to show an expectation of INVALID -\->
<p:document href="tiny-data/tiny1.xml"/>
<p:document href="tiny-data/bigbadtiny.xml"/>

<p:document href="tiny-data/terms-of-art.xml"/>
</p:input>

<p:input port="tinydata-xsd">
-->
<p:input port="tinydata-xsd" primary="false">
<p:document href="current/tiny_schema.xsd"/>
</p:input>

Expand All @@ -59,9 +59,13 @@
<p:pipe port="result" step="plaintext"/>
</p:output>

<p:import href="tinydata-samples.xpl"/>

<metaschema:tinydata-samples name="getting-samples"/>

<p:for-each>
<p:iteration-source>
<p:pipe port="samples" step="XSD-VALIDATE-CHOICES"/>
<p:pipe port="tinydata" step="getting-samples"/>
</p:iteration-source>
<p:variable name="base" select="base-uri(.)"/>

Expand Down Expand Up @@ -133,7 +137,7 @@
select="child::NOMINALLY-VALID/document[@VALIDATION-STATUS='XSD-INVALID'] |
child::NOMINALLY-INVALID/document[not(@VALIDATION-STATUS='XSD-INVALID')]"/>
<REPORT>
<progress>Checking { count(*/*) }{ if (count(*/*) eq 1) then ' document' else ' documents' } against a 'choices' XSD ...</progress>
<progress>Checking { count(*/*) }{ if (count(*/*) eq 1) then ' document' else ' documents' } against the current tinydata XSD ...</progress>
<xsl:apply-templates select="child::*/document"/>

<xsl:if test="empty($anomalies)">
Expand Down
Loading
Loading