diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2017-01-15 00:04:16 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2017-01-24 00:10:15 +0300 |
commit | 22fe6dd12a36fd8369966a9b042eb53dfa85c1eb (patch) | |
tree | 7bcaabc74fa479a158ae935f5865dda6a2722cde /tests/manifest/driver.cxx | |
parent | c8128e524255d15ae2c3fc80a89b7c05362427d9 (diff) |
Move manifest parsing/serializing tests to testscript
Diffstat (limited to 'tests/manifest/driver.cxx')
-rw-r--r-- | tests/manifest/driver.cxx | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/tests/manifest/driver.cxx b/tests/manifest/driver.cxx index 380bd04..8f3ffef 100644 --- a/tests/manifest/driver.cxx +++ b/tests/manifest/driver.cxx @@ -2,11 +2,11 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file +#include <ios> // ios_base::failbit, ios_base::badbit +#include <string> #include <cassert> #include <iostream> -#include <butl/utility> // operator<<(ostream, exception) -#include <butl/fdstream> #include <butl/manifest-parser> #include <butl/manifest-serializer> @@ -19,32 +19,35 @@ using namespace bpkg; int main (int argc, char* argv[]) { - if (argc != 2) - { - cerr << "usage: " << argv[0] << " <file>" << endl; - return 1; - } - - try - { - ifdstream ifs (argv[1]); - manifest_parser p (ifs, argv[1]); - -#ifdef TEST_PACKAGES - package_manifests ms (p); -#elif TEST_REPOSITORIES - repository_manifests ms (p); -#else - signature_manifest ms (p); -#endif - - stdout_fdmode (fdstream_mode::binary); // Write in binary mode. - manifest_serializer s (cout, "stdout"); - ms.serialize (s); - } - catch (const exception& e) - { - cerr << e << endl; - return 1; - } + // Usage: driver (-p|-r|-s) + // + // Read and parse manifest from STDIN and serialize it to STDOUT. The + // following options specify the manifest type. + // + // -p + // Parse package manifest list. + // + // -r + // Parse repository manifest list. + // + // -s + // Parse signature manifest. + // + assert (argc == 2); + string opt (argv[1]); + + cin.exceptions (ios_base::failbit | ios_base::badbit); + cout.exceptions (ios_base::failbit | ios_base::badbit); + + manifest_parser p (cin, "stdin"); + manifest_serializer s (cout, "stdout"); + + if (opt == "-p") + package_manifests (p).serialize (s); + else if (opt == "-r") + repository_manifests (p).serialize (s); + else if (opt == "-s") + signature_manifest (p).serialize (s); + else + assert (false); } |