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
1=== modified file 'libclickscope/click/interface.cpp'
2--- libclickscope/click/interface.cpp 2014-08-08 08:47:23 +0000
3+++ libclickscope/click/interface.cpp 2014-08-26 14:57:24 +0000
4@@ -498,13 +498,22 @@
5 PackageSet installed_packages;
6
7 while (iss.peek() != EOF) {
8- Package p;
9- std::getline(iss, p.name, TAB);
10- std::getline(iss, p.version, NEWLINE);
11- if (iss.eof() || p.name.empty() || p.version.empty()) {
12- throw std::runtime_error("Error encountered parsing 'click list' output");
13+ std::string line;
14+ std::getline(iss, line, NEWLINE);
15+
16+ if (!line.empty()) {
17+ // Must initialize linestream after line is filled.
18+ std::istringstream linestream(line);
19+
20+ Package p;
21+ std::getline(linestream, p.name, TAB);
22+ std::getline(linestream, p.version);
23+ if (iss.eof() || p.name.empty() || p.version.empty()) {
24+ qWarning() << "Error encountered parsing 'click list' output:" << QString::fromStdString(line);
25+ } else {
26+ installed_packages.insert(p);
27+ }
28 }
29- installed_packages.insert(p);
30 }
31
32 return installed_packages;
33@@ -587,8 +596,8 @@
34 static_cast<QProcessFinished>(&QProcess::finished),
35 [callback, process](int code, QProcess::ExitStatus /*status*/) {
36 qDebug() << "command finished with exit code:" << code;
37- auto data = process.data()->readAllStandardOutput().data();
38- auto errors = process.data()->readAllStandardError().data();
39+ std::string data{process->readAllStandardOutput().data()};
40+ std::string errors{process->readAllStandardError().data()};
41 callback(code, data, errors);
42 } );
43
44@@ -596,9 +605,9 @@
45 static_cast<QProcessError>(&QProcess::error),
46 [callback, process](QProcess::ProcessError error) {
47 qCritical() << "error running command:" << error;
48- auto data = process.data()->readAllStandardOutput().data();
49- auto errors = process.data()->readAllStandardError().data();
50- callback(process.data()->exitCode(), data, errors);
51+ std::string data{process->readAllStandardOutput().data()};
52+ std::string errors{process->readAllStandardError().data()};
53+ callback(process->exitCode(), data, errors);
54 } );
55
56 process->start(command.c_str());
57
58=== modified file 'libclickscope/tests/test_interface.cpp'
59--- libclickscope/tests/test_interface.cpp 2014-08-05 14:16:26 +0000
60+++ libclickscope/tests/test_interface.cpp 2014-08-26 14:57:24 +0000
61@@ -687,16 +687,20 @@
62 TEST_F(ClickInterfaceTest, testGetInstalledPackagesParseError)
63 {
64 FakeClickInterface iface;
65+ std::string bad_stdout = "INVALID: err\nvalid.package\t1.0\n";
66+ PackageSet expected{{"valid.package", "1.0"}};
67+
68 EXPECT_CALL(iface, run_process(_, _)).
69 Times(1).
70 WillOnce(Invoke([&](const std::string&,
71 std::function<void(int, const std::string&,
72 const std::string&)> callback){
73- callback(0, "valid.package\t1.0\nINVALID LINE", "");
74+ callback(0, bad_stdout, "");
75 }));
76- EXPECT_CALL(*this, installed_callback(_, InterfaceError::ParseError));
77- iface.get_installed_packages([this](PackageSet package_names, InterfaceError error){
78+ EXPECT_CALL(*this, installed_callback(_, InterfaceError::NoError));
79+ iface.get_installed_packages([this, expected](PackageSet package_names, InterfaceError error){
80 installed_callback(package_names, error);
81+ ASSERT_EQ(package_names, expected);
82 });
83 }
84

Subscribers

People subscribed via source and target branches

to all changes: