From 1f2a98dec70699905cf1a4c9ba48ad6397448a9a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 13 Jul 2018 15:35:30 +0200 Subject: Add manifest parser stub --- libbutl/manifest-parser.bash | 10 ++++++++++ tests/build/.gitignore | 3 +++ tests/build/bootstrap.build | 9 +++++++++ tests/build/root.build | 7 +++++++ tests/manifest-parser/buildfile | 5 +++++ tests/manifest-parser/driver | 31 +++++++++++++++++++++++++++++++ tests/manifest-parser/libbutl | 1 + tests/manifest-parser/testscript | 23 +++++++++++++++++++++++ 8 files changed, 89 insertions(+) create mode 100644 tests/build/.gitignore create mode 100644 tests/build/bootstrap.build create mode 100644 tests/build/root.build create mode 100644 tests/manifest-parser/buildfile create mode 100755 tests/manifest-parser/driver create mode 120000 tests/manifest-parser/libbutl create mode 100644 tests/manifest-parser/testscript diff --git a/libbutl/manifest-parser.bash b/libbutl/manifest-parser.bash index 4de96a6..5fa53ce 100644 --- a/libbutl/manifest-parser.bash +++ b/libbutl/manifest-parser.bash @@ -1,3 +1,13 @@ # file : libbutl/manifest-parser.bash # copyright : Copyright (c) 2014-2018 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file + +function parse_manifest () +{ + printf ": 1\0" + printf "name: foo\0" + printf "version: 1.2.3\0" + printf "description: foo\nexecutable\0" + printf "depends: libfoo\0" + printf "depends: libbar\0" +} diff --git a/tests/build/.gitignore b/tests/build/.gitignore new file mode 100644 index 0000000..4a730a3 --- /dev/null +++ b/tests/build/.gitignore @@ -0,0 +1,3 @@ +config.build +root/ +bootstrap/ diff --git a/tests/build/bootstrap.build b/tests/build/bootstrap.build new file mode 100644 index 0000000..91bc3e9 --- /dev/null +++ b/tests/build/bootstrap.build @@ -0,0 +1,9 @@ +# file : tests/build/bootstrap.build +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +project = # Unnamed subproject. + +using config +using dist +using test diff --git a/tests/build/root.build b/tests/build/root.build new file mode 100644 index 0000000..1f267eb --- /dev/null +++ b/tests/build/root.build @@ -0,0 +1,7 @@ +# file : tests/build/root.build +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +# Every exe{} in this subproject is by default a test. +# +exe{*}: test = true diff --git a/tests/manifest-parser/buildfile b/tests/manifest-parser/buildfile new file mode 100644 index 0000000..1dfe0d3 --- /dev/null +++ b/tests/manifest-parser/buildfile @@ -0,0 +1,5 @@ +# file : tests/manifest-parser/buildfile +# copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +exe{driver}: testscript diff --git a/tests/manifest-parser/driver b/tests/manifest-parser/driver new file mode 100755 index 0000000..4cbea3e --- /dev/null +++ b/tests/manifest-parser/driver @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +function import () +{ + # Here we don't assume the errors are trapped. If all goes well, our exit + # code is that of source (which fails if the file is not found). + # + local e; if ! e="$(realpath ${BASH_SOURCE[0]})"; then return 1; fi + local d; if ! d="$(dirname "$e")"; then return 1; fi + source "$d/$1.bash" +} + +trap "{ exit 1; }" ERR +set -o errtrace # Trap ERR in functions. + +import libbutl/manifest-parser + +# @@ parse_manifest failure ignored +# +# @@ what would be equivalent serialization interface? Just serialize one +# name/value in manifest format (so explicit version). +# +while IFS=': ' read -r -d '' n v; do + if [ -z "$n" ]; then + echo "$v" + else + echo # Extra newline after first pair. + echo "$n" + echo "$v" + fi +done < <(parse_manifest) diff --git a/tests/manifest-parser/libbutl b/tests/manifest-parser/libbutl new file mode 120000 index 0000000..6d1c4c0 --- /dev/null +++ b/tests/manifest-parser/libbutl @@ -0,0 +1 @@ +../../libbutl \ No newline at end of file diff --git a/tests/manifest-parser/testscript b/tests/manifest-parser/testscript new file mode 100644 index 0000000..6a95286 --- /dev/null +++ b/tests/manifest-parser/testscript @@ -0,0 +1,23 @@ +# file : tests/manifest-parser/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 +EOO -- cgit v1.1