Merge lp:~dobey/unity-scope-click/skip-broken into lp:unity-scope-click/devel

Proposed by dobey
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 412
Merged at revision: 427
Proposed branch: lp:~dobey/unity-scope-click/skip-broken
Merge into: lp:unity-scope-click/devel
Prerequisite: lp:~dobey/unity-scope-click/merge-trunk
Diff against target: 83 lines (+27/-14)
2 files modified
libclickscope/click/interface.cpp (+20/-11)
libclickscope/tests/test_interface.cpp (+7/-3)
To merge this branch: bzr merge lp:~dobey/unity-scope-click/skip-broken
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alejandro J. Cura (community) Approve
Review via email: mp+231267@code.launchpad.net

Commit message

Log corrupt packages and try to continue, rather than throwing for click list.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
410. By dobey

Remove superfluous .data() usage.

411. By dobey

Remove more superfluous data calls.

412. By dobey

Use {} instead of () for the initalizers.

Revision history for this message
Alejandro J. Cura (alecu) wrote :

Works much better.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libclickscope/click/interface.cpp'
--- libclickscope/click/interface.cpp 2014-08-08 08:47:23 +0000
+++ libclickscope/click/interface.cpp 2014-08-26 14:57:24 +0000
@@ -498,13 +498,22 @@
498 PackageSet installed_packages;498 PackageSet installed_packages;
499499
500 while (iss.peek() != EOF) {500 while (iss.peek() != EOF) {
501 Package p;501 std::string line;
502 std::getline(iss, p.name, TAB);502 std::getline(iss, line, NEWLINE);
503 std::getline(iss, p.version, NEWLINE);503
504 if (iss.eof() || p.name.empty() || p.version.empty()) {504 if (!line.empty()) {
505 throw std::runtime_error("Error encountered parsing 'click list' output");505 // Must initialize linestream after line is filled.
506 std::istringstream linestream(line);
507
508 Package p;
509 std::getline(linestream, p.name, TAB);
510 std::getline(linestream, p.version);
511 if (iss.eof() || p.name.empty() || p.version.empty()) {
512 qWarning() << "Error encountered parsing 'click list' output:" << QString::fromStdString(line);
513 } else {
514 installed_packages.insert(p);
515 }
506 }516 }
507 installed_packages.insert(p);
508 }517 }
509518
510 return installed_packages;519 return installed_packages;
@@ -587,8 +596,8 @@
587 static_cast<QProcessFinished>(&QProcess::finished),596 static_cast<QProcessFinished>(&QProcess::finished),
588 [callback, process](int code, QProcess::ExitStatus /*status*/) {597 [callback, process](int code, QProcess::ExitStatus /*status*/) {
589 qDebug() << "command finished with exit code:" << code;598 qDebug() << "command finished with exit code:" << code;
590 auto data = process.data()->readAllStandardOutput().data();599 std::string data{process->readAllStandardOutput().data()};
591 auto errors = process.data()->readAllStandardError().data();600 std::string errors{process->readAllStandardError().data()};
592 callback(code, data, errors);601 callback(code, data, errors);
593 } );602 } );
594603
@@ -596,9 +605,9 @@
596 static_cast<QProcessError>(&QProcess::error),605 static_cast<QProcessError>(&QProcess::error),
597 [callback, process](QProcess::ProcessError error) {606 [callback, process](QProcess::ProcessError error) {
598 qCritical() << "error running command:" << error;607 qCritical() << "error running command:" << error;
599 auto data = process.data()->readAllStandardOutput().data();608 std::string data{process->readAllStandardOutput().data()};
600 auto errors = process.data()->readAllStandardError().data();609 std::string errors{process->readAllStandardError().data()};
601 callback(process.data()->exitCode(), data, errors);610 callback(process->exitCode(), data, errors);
602 } );611 } );
603612
604 process->start(command.c_str());613 process->start(command.c_str());
605614
=== modified file 'libclickscope/tests/test_interface.cpp'
--- libclickscope/tests/test_interface.cpp 2014-08-05 14:16:26 +0000
+++ libclickscope/tests/test_interface.cpp 2014-08-26 14:57:24 +0000
@@ -687,16 +687,20 @@
687TEST_F(ClickInterfaceTest, testGetInstalledPackagesParseError)687TEST_F(ClickInterfaceTest, testGetInstalledPackagesParseError)
688{688{
689 FakeClickInterface iface;689 FakeClickInterface iface;
690 std::string bad_stdout = "INVALID: err\nvalid.package\t1.0\n";
691 PackageSet expected{{"valid.package", "1.0"}};
692
690 EXPECT_CALL(iface, run_process(_, _)).693 EXPECT_CALL(iface, run_process(_, _)).
691 Times(1).694 Times(1).
692 WillOnce(Invoke([&](const std::string&,695 WillOnce(Invoke([&](const std::string&,
693 std::function<void(int, const std::string&,696 std::function<void(int, const std::string&,
694 const std::string&)> callback){697 const std::string&)> callback){
695 callback(0, "valid.package\t1.0\nINVALID LINE", "");698 callback(0, bad_stdout, "");
696 }));699 }));
697 EXPECT_CALL(*this, installed_callback(_, InterfaceError::ParseError));700 EXPECT_CALL(*this, installed_callback(_, InterfaceError::NoError));
698 iface.get_installed_packages([this](PackageSet package_names, InterfaceError error){701 iface.get_installed_packages([this, expected](PackageSet package_names, InterfaceError error){
699 installed_callback(package_names, error);702 installed_callback(package_names, error);
703 ASSERT_EQ(package_names, expected);
700 });704 });
701}705}
702706

Subscribers

People subscribed via source and target branches

to all changes: