From 258835fb4cd7338f9a0f9a758860cf1a368987dc Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 21 Jul 2018 22:15:29 +0300 Subject: Implement manifest parsing/serialization --- tests/manifest-parser/testscript | 107 +++++++++++++++++++++++++++++----- tests/manifest-serializer/driver.in | 2 - tests/manifest-serializer/testscript | 108 +++++++++++++++++++++++++++-------- 3 files changed, 177 insertions(+), 40 deletions(-) (limited to 'tests') diff --git a/tests/manifest-parser/testscript b/tests/manifest-parser/testscript index 154b107..78f4160 100644 --- a/tests/manifest-parser/testscript +++ b/tests/manifest-parser/testscript @@ -2,24 +2,101 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -$* >>EOO -1 +: stdin +: +{ + $* <>EOO + : 1 + name: foo + version: 1.2.3 + description: \ + foo + executable + \ + depends: libfoo + depends: libbar + EOI + 1 -name -foo + name + foo -version -1.2.3 + version + 1.2.3 -description -foo -executable + description + foo + executable -depends -libfoo + depends + libfoo -depends -libbar -EOO + depends + libbar + EOO +} -#@@ TODO: test reading from file instead of stdin. +: file +: +{ + cat <=file; + : 1 + name: foo + version: 1.2.3 + EOI + + $* file >>EOO + 1 + + name + foo + + version + 1.2.3 + EOO +} + +: list +: +{ + $* <>EOO + : 1 + name: foo + : + version: 1.2.3 + EOI + 1 + + name + foo + 1 + + version + 1.2.3 + EOO +} + +: version +: +{ + : absent + : + $* <'stdin:1:1: error: format version pair expected' != 0 + name: foo + EOI + + : unsupported + : + $* <- 2>'stdin:3:3: error: unsupported format version 2' != 0 + : 1 + name: foo + : 2 + version: 1.2.3 + EOI +} + +: empty +: +{ + $* <:'' >:'' +} diff --git a/tests/manifest-serializer/driver.in b/tests/manifest-serializer/driver.in index 9e619e5..4ee31a7 100644 --- a/tests/manifest-serializer/driver.in +++ b/tests/manifest-serializer/driver.in @@ -14,7 +14,6 @@ butl_manifest_serializer_start "$@" fd="$butl_manifest_serializer_ifd" while read -r n; do - printf "%s:" "$n" >&"$fd" f=true @@ -31,7 +30,6 @@ while read -r n; do printf "%s" "$v" >&"$fd" fi done - done butl_manifest_serializer_finish diff --git a/tests/manifest-serializer/testscript b/tests/manifest-serializer/testscript index af96cc0..f305342 100644 --- a/tests/manifest-serializer/testscript +++ b/tests/manifest-serializer/testscript @@ -2,34 +2,96 @@ # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -$* <>EOO +: stdout +{ + $* <>EOO -1 + 1 -name -foo + name + foo -version -1.2.3 + version + 1.2.3 -description -foo -executable + description + foo + executable -depends -libfoo + depends + libfoo -depends -libbar + depends + libbar -EOI -: 1 -name: foo -version: 1.2.3 -description: foo -executable -depends: libfoo -depends: libbar -EOO + EOI + : 1 + name: foo + version: 1.2.3 + description: \ + foo + executable + \ + depends: libfoo + depends: libbar + EOO +} -#@@ TODO: test writing to file instead of stdout. +: file +{ + $* <=file; + + 1 + + name + foo + + version + 1.2.3 + EOI + + cat file >>EOE + : 1 + name: foo + version: 1.2.3 + EOE +} + +: list +{ + $* <>EOO + + 1 + + name + foo + + + 1 + + version + 1.2.3 + EOI + : 1 + name: foo + : + version: 1.2.3 + EOO +} + +: version +: +{ + : absent + : + $* <'stdout: error: format version pair expected' != 0 + name + foo + EOI +} + +: empty +: +{ + $* <:'' >:'' +} -- cgit v1.1