Skip to content

Commit

Permalink
tests: modernize linecount
Browse files Browse the repository at this point in the history
Use app_template::run() instead of run_deprecated(), and wait for
the continuation chain to complete.  This fixes the application terminating
before it has the chance to print anything.
  • Loading branch information
avikivity committed Jan 11, 2016
1 parent 4cf22fb commit 191bfd6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/linecount.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,23 @@ int main(int ac, char** av) {
app.add_positional_options({
{ "file", bpo::value<std::string>(), "File to process", 1 },
});
app.run_deprecated(ac, av, [&app] {
return app.run(ac, av, [&app] {
auto fname = app.configuration()["file"].as<std::string>();
open_file_dma(fname, open_flags::ro).then([] (file f) {
return open_file_dma(fname, open_flags::ro).then([] (file f) {
auto r = make_shared<reader>(std::move(f));
r->is.consume(*r).then([r] {
return r->is.consume(*r).then([r] {
print("%d lines\n", r->count);
});
}).then_wrapped([] (future<> f) {
}).then_wrapped([] (future<> f) -> future<int> {
try {
f.get();
engine().exit(0);
return make_ready_future<int>(0);
} catch (std::exception& ex) {
std::cout << ex.what() << "\n";
engine().exit(1);
return make_ready_future<int>(1);
} catch (...) {
std::cout << "unknown exception\n";
engine().exit(0);
return make_ready_future<int>(1);
}
});
});
Expand Down

0 comments on commit 191bfd6

Please sign in to comment.