forked from usnistgov/metaschema-xslt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integrated schema generation unit tests with new build scripting
- Loading branch information
1 parent
c7b886f
commit e2388bf
Showing
3 changed files
with
126 additions
and
110 deletions.
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
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,52 @@ | ||
#!/bin/bash | ||
|
||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)/init-validate-content.sh" | ||
|
||
generate_schema() { | ||
|
||
local format="$1"; shift | ||
local metaschema="$1"; shift | ||
local schema_file="$1"; shift | ||
|
||
result=$("generate_${format}_schema" "$metaschema" "$schema_file") | ||
cmd_exitcode=$? | ||
echo -ne "${result}" | ||
if [ $cmd_exitcode -eq 0 ]; then | ||
if [ "$VERBOSE" = "true" ]; then | ||
echo -e "${P_OK}Generation of ${format^^} schema passed for '${P_END}${metaschema}${P_OK}'.${P_END}" | ||
fi | ||
fi | ||
return $cmd_exitcode; | ||
} | ||
|
||
validate_schema() { | ||
local format="$1"; shift | ||
local schema_file="$1"; shift | ||
|
||
# validate generated schema | ||
case ${format} in | ||
xml) | ||
result=$(validate_xml "${METASCHEMA_SCRIPT_DIR}/../support/schema/XMLSchema.xsd" "$schema_file") | ||
cmd_exitcode=$? | ||
;; | ||
json) | ||
result=$(validate_json "${METASCHEMA_SCRIPT_DIR}/../support/schema/json-schema-schema.json" "$schema_file") | ||
cmd_exitcode=$? | ||
;; | ||
*) | ||
echo -e "${P_WARN}${format^^} schema validation not supported for '${P_END}${schema_file}${P_WARN}'.${P_END}" | ||
cmd_exitcode=0 | ||
;; | ||
esac | ||
|
||
if [ $cmd_exitcode -ne 0 ]; then | ||
echo -e "${P_ERROR}${result}${P_END}" | ||
exitcode=1 | ||
else | ||
if [ "$VERBOSE" == "true" ]; then | ||
echo -e "${P_OK}Schema validation passed for '${P_END}${GENERATED_SCHEMA}${P_OK}'.${P_END}" | ||
fi | ||
fi | ||
|
||
return $cmd_exitcode; | ||
} |
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