aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-07-13 15:35:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-07-13 15:35:30 +0200
commit1f2a98dec70699905cf1a4c9ba48ad6397448a9a (patch)
tree13069e0c35e95efcb1abeca78b699a4b43ccbb7b
parent2aac6bb4b179a45908cd9d8c6656fef671c24042 (diff)
Add manifest parser stub
-rw-r--r--libbutl/manifest-parser.bash10
-rw-r--r--tests/build/.gitignore3
-rw-r--r--tests/build/bootstrap.build9
-rw-r--r--tests/build/root.build7
-rw-r--r--tests/manifest-parser/buildfile5
-rwxr-xr-xtests/manifest-parser/driver31
l---------tests/manifest-parser/libbutl1
-rw-r--r--tests/manifest-parser/testscript23
8 files changed, 89 insertions, 0 deletions
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