aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-06-11 18:12:09 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-06-11 18:12:09 +0200
commitc552070230c4ad9c92b516c28658b5c74c57e46b (patch)
treebc78a4c9c5c9bfb21539e3e65f713a7f0daa766b /tests
parent294f8e8d3abebaaa976c7d21248a1a205c869b02 (diff)
Outline of parsing and serialization for manifest object model
Diffstat (limited to 'tests')
-rw-r--r--tests/buildfile2
-rw-r--r--tests/manifest-parser/driver.cxx2
-rw-r--r--tests/manifest-roundtrip/driver.cxx4
-rw-r--r--tests/manifest/buildfile11
-rw-r--r--tests/manifest/driver.cxx46
-rw-r--r--tests/manifest/manifest4
6 files changed, 65 insertions, 4 deletions
diff --git a/tests/buildfile b/tests/buildfile
index d7b8b7f..1f70dd5 100644
--- a/tests/buildfile
+++ b/tests/buildfile
@@ -2,6 +2,6 @@
# copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
-d = manifest-parser/ manifest-serializer/ manifest-roundtrip/
+d = manifest-parser/ manifest-serializer/ manifest-roundtrip/ manifest/
.: $d
include $d
diff --git a/tests/manifest-parser/driver.cxx b/tests/manifest-parser/driver.cxx
index 309106f..c54e2f0 100644
--- a/tests/manifest-parser/driver.cxx
+++ b/tests/manifest-parser/driver.cxx
@@ -157,7 +157,7 @@ parse (const char* m)
for (bool eom (true), eos (false); !eos; )
{
- auto nv (p.next ());
+ manifest_name_value nv (p.next ());
if (nv.empty ()) // End pair.
{
diff --git a/tests/manifest-roundtrip/driver.cxx b/tests/manifest-roundtrip/driver.cxx
index 45abc67..f8a95bd 100644
--- a/tests/manifest-roundtrip/driver.cxx
+++ b/tests/manifest-roundtrip/driver.cxx
@@ -26,12 +26,12 @@ main (int argc, char* argv[])
ifs.exceptions (ifstream::badbit | ifstream::failbit);
ifs.open (argv[1], ifstream::in | ifstream::binary);
- manifest_parser p (ifs, "");
+ manifest_parser p (ifs, argv[1]);
manifest_serializer s (cout, "stdout");
for (bool eom (true), eos (false); !eos; )
{
- auto nv (p.next ());
+ manifest_name_value nv (p.next ());
if (nv.empty ()) // End pair.
{
diff --git a/tests/manifest/buildfile b/tests/manifest/buildfile
new file mode 100644
index 0000000..ee23ca9
--- /dev/null
+++ b/tests/manifest/buildfile
@@ -0,0 +1,11 @@
+# file : tests/manifest/buildfile
+# copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
+# license : MIT; see accompanying LICENSE file
+
+import libs += libbutl #@@ hack to get -I
+
+exe{driver}: cxx{driver} ../../bpkg/lib{bpkg} $libs
+
+include ../../bpkg/
+
+# test: ./driver manifest | diff -u manifest -
diff --git a/tests/manifest/driver.cxx b/tests/manifest/driver.cxx
new file mode 100644
index 0000000..ff6005c
--- /dev/null
+++ b/tests/manifest/driver.cxx
@@ -0,0 +1,46 @@
+// file : tests/manifest/driver.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#include <fstream>
+#include <iostream>
+
+#include <bpkg/manifest>
+#include <bpkg/manifest-parser>
+#include <bpkg/manifest-serializer>
+
+using namespace std;
+using namespace bpkg;
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " <file>" << endl;
+ return 1;
+ }
+
+ try
+ {
+ ifstream ifs;
+ ifs.exceptions (ifstream::badbit | ifstream::failbit);
+ ifs.open (argv[1], ifstream::in | ifstream::binary);
+
+ manifest_parser p (ifs, argv[1]);
+ manifests ms (p);
+
+ manifest_serializer s (cout, "stdout");
+ ms.serialize (s);
+ }
+ catch (const ios_base::failure&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+ catch (const std::exception& e)
+ {
+ cerr << e.what () << endl;
+ return 1;
+ }
+}
diff --git a/tests/manifest/manifest b/tests/manifest/manifest
new file mode 100644
index 0000000..25491ef
--- /dev/null
+++ b/tests/manifest/manifest
@@ -0,0 +1,4 @@
+: 1
+name: libfoo
+:
+name: libbar