From 22fe6dd12a36fd8369966a9b042eb53dfa85c1eb Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sun, 15 Jan 2017 00:04:16 +0300 Subject: Move manifest parsing/serializing tests to testscript --- tests/manifest/driver.cxx | 63 +++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 30 deletions(-) (limited to 'tests/manifest/driver.cxx') 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_base::failbit, ios_base::badbit +#include #include #include -#include // operator<<(ostream, exception) -#include #include #include @@ -19,32 +19,35 @@ using namespace bpkg; int main (int argc, char* argv[]) { - if (argc != 2) - { - cerr << "usage: " << argv[0] << " " << 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); } -- cgit v1.1