From 03ff256dc44228c9465cd2040593a72b2d084d1e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 21 Jul 2018 12:30:38 +0200 Subject: Add manifest serializer module --- tests/manifest-serializer/buildfile | 7 +++++++ tests/manifest-serializer/driver.in | 37 ++++++++++++++++++++++++++++++++++++ tests/manifest-serializer/testscript | 35 ++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 tests/manifest-serializer/buildfile create mode 100644 tests/manifest-serializer/driver.in create mode 100644 tests/manifest-serializer/testscript (limited to 'tests/manifest-serializer') diff --git a/tests/manifest-serializer/buildfile b/tests/manifest-serializer/buildfile new file mode 100644 index 0000000..f881ee9 --- /dev/null +++ b/tests/manifest-serializer/buildfile @@ -0,0 +1,7 @@ +# file : tests/manifest-serializer/buildfile +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +import mods = libbutl.bash%bash{manifest-serializer} + +exe{driver}: in{driver} $mods testscript diff --git a/tests/manifest-serializer/driver.in b/tests/manifest-serializer/driver.in new file mode 100644 index 0000000..9e619e5 --- /dev/null +++ b/tests/manifest-serializer/driver.in @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# file : tests/manifest-serializer/driver.in +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +trap "{ exit 1; }" ERR +set -o errtrace # Trap ERR in functions. + +@import libbutl/manifest-serializer@ + +butl_manifest_serializer_start "$@" + +fd="$butl_manifest_serializer_ifd" + +while read -r n; do + + printf "%s:" "$n" >&"$fd" + + f=true + while read -r v; do + if [ -z "$v" ]; then + printf "\0" >&"$fd" + break + else + if [ "$f" ]; then + f= + else + printf "\n" >&"$fd" + fi + printf "%s" "$v" >&"$fd" + fi + done + +done + +butl_manifest_serializer_finish diff --git a/tests/manifest-serializer/testscript b/tests/manifest-serializer/testscript new file mode 100644 index 0000000..af96cc0 --- /dev/null +++ b/tests/manifest-serializer/testscript @@ -0,0 +1,35 @@ +# file : tests/manifest-serializer/testscript +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +$* <>EOO + +1 + +name +foo + +version +1.2.3 + +description +foo +executable + +depends +libfoo + +depends +libbar + +EOI +: 1 +name: foo +version: 1.2.3 +description: foo +executable +depends: libfoo +depends: libbar +EOO + +#@@ TODO: test writing to file instead of stdout. -- cgit v1.1