2020-08-24 05:25:18 +00:00
|
|
|
#undef NDEBUG
|
|
|
|
|
#include<Boss/Main.hpp>
|
|
|
|
|
#include<Ev/Io.hpp>
|
|
|
|
|
#include<Ev/start.hpp>
|
2020-09-07 21:50:38 +08:00
|
|
|
#include<Net/Fd.hpp>
|
2020-08-24 05:25:18 +00:00
|
|
|
#include<assert.h>
|
|
|
|
|
#include<sstream>
|
2020-09-07 21:50:38 +08:00
|
|
|
#include<stdexcept>
|
2020-08-24 05:25:18 +00:00
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
# include"config.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Test that --version causes Boss::Main to exit immediately
|
|
|
|
|
* after printing the version. */
|
|
|
|
|
int main() {
|
|
|
|
|
auto argv = std::vector<std::string>{ "clboss", "--version" };
|
|
|
|
|
|
|
|
|
|
auto cin = std::stringstream("dummy");
|
|
|
|
|
auto cout = std::stringstream("");
|
|
|
|
|
auto cerr = std::stringstream("");
|
|
|
|
|
|
2020-09-07 21:50:38 +08:00
|
|
|
auto dummy_open_rpc_socket = []( std::string const& lightning_dir
|
|
|
|
|
, std::string const& rpc_file
|
|
|
|
|
){
|
|
|
|
|
throw std::runtime_error("Should not be called");
|
|
|
|
|
return Net::Fd();
|
|
|
|
|
};
|
|
|
|
|
auto main = Boss::Main( argv, cin, cout, cerr
|
|
|
|
|
, dummy_open_rpc_socket
|
|
|
|
|
);
|
2020-08-24 05:25:18 +00:00
|
|
|
|
2020-09-07 11:33:35 +08:00
|
|
|
auto ec = Ev::start(main.run().then([](int ec) {
|
|
|
|
|
return Ev::lift(ec);
|
2020-08-24 05:25:18 +00:00
|
|
|
}));
|
|
|
|
|
assert(ec == 0);
|
|
|
|
|
/* No input should be consumed. */
|
|
|
|
|
assert(cin.str() == "dummy");
|
|
|
|
|
/* Should just print this. */
|
|
|
|
|
assert(cout.str() == (PACKAGE_STRING "\n"));
|
|
|
|
|
/* No error should have been printed. */
|
|
|
|
|
assert(cerr.str() == "");
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|