forked from HariSekhon/DevOps-Python-tools
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_xml_to_json.sh
More file actions
executable file
·38 lines (33 loc) · 958 Bytes
/
test_xml_to_json.sh
File metadata and controls
executable file
·38 lines (33 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
# vim:ts=4:sts=4:sw=4:et
#
# Author: Hari Sekhon
# Date: 2016-08-29 18:18:39 +0100 (Mon, 29 Aug 2016)
#
# https://github.com/harisekhon/devops-python-tools
#
# License: see accompanying Hari Sekhon LICENSE file
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
#
# https://www.linkedin.com/in/harisekhon
#
set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
srcdir="$(cd "$(dirname "$0")" && pwd)"
cd "$srcdir";
. utils.sh
. ../bash-tools/utils.sh
section "XML => JSON"
for x in simple.xml plant_catalog.xml; do
tmpfile="$(mktemp xml_to_json_test.XXXXX.xml)"
trap "rm -f $tmpfile" $TRAP_SIGNALS
echo "running xml_to_json.py on $x":
../xml_to_json.py "data/$x" > "$tmpfile"
echo
echo "now validating generated json":
../validate_json.py "$tmpfile"
echo
rm -f "$tmpfile"
echo "========="
done