diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-04-13 10:47:47 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-04-13 10:47:47 +0200 |
commit | abbb859d9eefa62a5cc774bd08020bf30ad77c26 (patch) | |
tree | ac2b8648dc9d792154680bff38e5c3f1be73264d /tests | |
parent | 714ce38164dbb4b19be8db286182dba3784d471f (diff) |
Implement sendmail process
Diffstat (limited to 'tests')
-rw-r--r-- | tests/buildfile | 3 | ||||
-rw-r--r-- | tests/sendmail/buildfile | 7 | ||||
-rw-r--r-- | tests/sendmail/driver.cxx | 42 | ||||
-rw-r--r-- | tests/sendmail/testscript | 10 |
4 files changed, 61 insertions, 1 deletions
diff --git a/tests/buildfile b/tests/buildfile index 10e73ec..efc54b8 100644 --- a/tests/buildfile +++ b/tests/buildfile @@ -2,4 +2,5 @@ # copyright : Copyright (c) 2014-2017 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -./: */ +./: {*/ -sendmail/} + diff --git a/tests/sendmail/buildfile b/tests/sendmail/buildfile new file mode 100644 index 0000000..ddc8bca --- /dev/null +++ b/tests/sendmail/buildfile @@ -0,0 +1,7 @@ +# file : tests/sendmail/buildfile +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +exe{driver}: cxx{driver} ../../butl/lib{butl} test{testscript} + +include ../../butl/ diff --git a/tests/sendmail/driver.cxx b/tests/sendmail/driver.cxx new file mode 100644 index 0000000..9e1af96 --- /dev/null +++ b/tests/sendmail/driver.cxx @@ -0,0 +1,42 @@ +// file : tests/sendmail/driver.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include <iostream> +#include <system_error> + +#include <butl/path> +#include <butl/utility> // operator<<(ostream, exception) +#include <butl/sendmail> + +using namespace std; +using namespace butl; + +// Usage: argv[0] <to> +// +int +main (int argc, const char* argv[]) +try +{ + assert (argc == 2); + + sendmail sm ([] (const char* c[], std::size_t n) + { + process::print (cerr, c, n); cerr << endl; + }, + 2, + "", + "tests/sendmail/driver", + {argv[1]}); + + sm.out << cin.rdbuf (); + sm.out.close (); + + if (!sm.wait ()) + return 1; // Assume diagnostics has been issued. +} +catch (const system_error& e) +{ + cerr << argv[0] << ": " << e << endl; + return 1; +} diff --git a/tests/sendmail/testscript b/tests/sendmail/testscript new file mode 100644 index 0000000..49776a3 --- /dev/null +++ b/tests/sendmail/testscript @@ -0,0 +1,10 @@ +# file : tests/sendmail/testscript +# copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +# license : MIT; see accompanying LICENSE file + +$* admin@build2.org <<EOI 2>>EOE +Test email to admin@build2.org. +Sent from libbutl/tests/sendmail/testscript. +EOI +sendmail -i -t +EOE |