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

[WIP] Test the Pruning of Unused Definitions for Its Updated Phase in Metaschema Composition Pipeline #10

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<METASCHEMA xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
module="pruning001">
<define-assembly name="box">
<formal-name>BOX</formal-name>
<description>Just a box, no relationship to anything else.</description>
<root-name>BOX</root-name>
</define-assembly>
</METASCHEMA>
16 changes: 16 additions & 0 deletions toolchains/xslt-M4/compose/testing/4_pruning/input/pruning002.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<METASCHEMA xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
module="pruning002">
<define-assembly name="box">
<formal-name>BOX</formal-name>
<description>Just a box, no relationship to anything else.</description>
<root-name>BOX</root-name>
<model>
<assembly ref="folder"/>
</model>
</define-assembly>
<define-assembly name="folder">
<formal-name>Folder</formal-name>
<description>One or more folders belong in a box.</description>
</define-assembly>
</METASCHEMA>
14 changes: 14 additions & 0 deletions toolchains/xslt-M4/compose/testing/4_pruning/input/pruning003.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<METASCHEMA xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
module="pruning003">
<define-assembly name="box">
<formal-name>BOX</formal-name>
<description>Just a box, no relationship to anything else.</description>
<root-name>BOX</root-name>
<model/>
</define-assembly>
<define-assembly name="folder">
<formal-name>Folder</formal-name>
<description>One or more folders belong in a box.</description>
</define-assembly>
</METASCHEMA>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:m="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0"
stylesheet="../../metaschema-prune-unused-definitions.xsl"
run-as="external">
<x:scenario label="During Metaschema composition">
<x:scenario label="during the pruning phase">
<x:scenario label="a single root assembly with no references">
<x:context href="./input/pruning001.xml"/>
<x:expect label="should not throw an exception"
test="$x:result//m:EXCEPTION => empty()"/>
</x:scenario>
<x:scenario label="top-level definitions with correct references.">
<x:context href="./input/pruning002.xml"/>
<x:expect label="should not throw an exception"
test="$x:result//m:EXCEPTION => empty()"/>
</x:scenario>
<x:scenario label="top-level definitions with unused.">
<x:context href="./input/pruning003.xml"/>
<x:expect label="throws only exception for an unused definition."
test="count($x:result//m:EXCEPTION) eq 1"/>
<x:expect label="and should be of type unused-definition with the proper message."
test="$x:result//m:EXCEPTION[@problem-type = 'unused-definition'] => exists()"/>
<x:expect label="and the error message indicates the specific definition that's unused."
test="$x:result//m:EXCEPTION[@problem-type='unused-definition'] = 'REMOVING unused assembly definition for ''folder'' from pruning003'"/>
</x:scenario>
</x:scenario>
</x:scenario>
</x:description>