File tests/TestUtils.cpp changed (mode: 100644) (index 23ac1e6..c7b7032) |
17 |
17 |
#include "TestUtils.hpp" |
#include "TestUtils.hpp" |
18 |
18 |
|
|
19 |
19 |
#include <boost/filesystem/operations.hpp> |
#include <boost/filesystem/operations.hpp> |
|
20 |
|
#include <boost/iostreams/filter/gzip.hpp> |
|
21 |
|
#include <boost/iostreams/filtering_streambuf.hpp> |
20 |
22 |
#include <boost/range.hpp> |
#include <boost/range.hpp> |
21 |
23 |
|
|
|
24 |
|
#include <fstream> |
|
25 |
|
#include <ostream> |
|
26 |
|
|
22 |
27 |
#include "Settings.hpp" |
#include "Settings.hpp" |
23 |
28 |
|
|
24 |
29 |
namespace fs = boost::filesystem; |
namespace fs = boost::filesystem; |
|
... |
... |
getSettings() |
78 |
83 |
static TestSettings settings; |
static TestSettings settings; |
79 |
84 |
return settings; |
return settings; |
80 |
85 |
} |
} |
|
86 |
|
|
|
87 |
|
void |
|
88 |
|
makeGz(const std::string &path, const std::string &contents) |
|
89 |
|
{ |
|
90 |
|
std::ofstream file(path, std::ios_base::out | std::ios_base::binary); |
|
91 |
|
|
|
92 |
|
boost::iostreams::filtering_ostreambuf out; |
|
93 |
|
out.push(boost::iostreams::gzip_compressor()); |
|
94 |
|
out.push(file); |
|
95 |
|
|
|
96 |
|
std::basic_ostream<char>(&out) << contents; |
|
97 |
|
} |
File tests/sub_commands.cpp changed (mode: 100644) (index 0727a8b..04b0165) |
18 |
18 |
|
|
19 |
19 |
#include <boost/algorithm/string/predicate.hpp> |
#include <boost/algorithm/string/predicate.hpp> |
20 |
20 |
#include <boost/filesystem/operations.hpp> |
#include <boost/filesystem/operations.hpp> |
21 |
|
#include <boost/iostreams/filter/gzip.hpp> |
|
22 |
|
#include <boost/iostreams/filtering_streambuf.hpp> |
|
23 |
21 |
#include <boost/optional.hpp> |
#include <boost/optional.hpp> |
24 |
22 |
#include <boost/scope_exit.hpp> |
#include <boost/scope_exit.hpp> |
25 |
23 |
|
|
|
27 |
25 |
|
|
28 |
26 |
#include <fstream> |
#include <fstream> |
29 |
27 |
#include <iostream> |
#include <iostream> |
30 |
|
#include <ostream> |
|
31 |
28 |
#include <stdexcept> |
#include <stdexcept> |
32 |
29 |
#include <string> |
#include <string> |
33 |
30 |
|
|
|
... |
... |
private: |
104 |
101 |
}; |
}; |
105 |
102 |
|
|
106 |
103 |
static SubCommand * getCmd(const std::string &name); |
static SubCommand * getCmd(const std::string &name); |
107 |
|
static void makeGcovJsonGz(const std::string &path, |
|
108 |
|
const std::string &contents); |
|
109 |
104 |
|
|
110 |
105 |
const std::string build3info = |
const std::string build3info = |
111 |
106 |
R"(Id: #3 |
R"(Id: #3 |
|
... |
... |
TEST_CASE("Gcov file is found and parsed", |
1225 |
1220 |
const std::string &dir) { |
const std::string &dir) { |
1226 |
1221 |
GcovInfo gcovInfo; |
GcovInfo gcovInfo; |
1227 |
1222 |
if (gcovInfo.hasJsonFormat()) { |
if (gcovInfo.hasJsonFormat()) { |
1228 |
|
makeGcovJsonGz(dir + "/test-file1.gcno.gcov.json.gz", R"({ |
|
|
1223 |
|
makeGz(dir + "/test-file1.gcno.gcov.json.gz", R"({ |
1229 |
1224 |
"files": [{ |
"files": [{ |
1230 |
1225 |
"file": "test-file1.cpp", |
"file": "test-file1.cpp", |
1231 |
1226 |
"lines": [ |
"lines": [ |
|
... |
... |
TEST_CASE("Gcov file with broken format causes an exception", |
1267 |
1262 |
const std::string &dir) { |
const std::string &dir) { |
1268 |
1263 |
GcovInfo gcovInfo; |
GcovInfo gcovInfo; |
1269 |
1264 |
if (gcovInfo.hasJsonFormat()) { |
if (gcovInfo.hasJsonFormat()) { |
1270 |
|
makeGcovJsonGz(dir + "/test-file1.gcno.gcov.json.gz", R"({ |
|
|
1265 |
|
makeGz(dir + "/test-file1.gcno.gcov.json.gz", R"({ |
1271 |
1266 |
"files": [{ |
"files": [{ |
1272 |
1267 |
"file": "test-file1.cpp", |
"file": "test-file1.cpp", |
1273 |
1268 |
"lines": [ { "line_number": 2, "count": 0 }, ] |
"lines": [ { "line_number": 2, "count": 0 }, ] |
|
... |
... |
getCmd(const std::string &name) |
1599 |
1594 |
} |
} |
1600 |
1595 |
throw std::invalid_argument("No such command: " + name); |
throw std::invalid_argument("No such command: " + name); |
1601 |
1596 |
} |
} |
1602 |
|
|
|
1603 |
|
static void |
|
1604 |
|
makeGcovJsonGz(const std::string &path, const std::string &contents) |
|
1605 |
|
{ |
|
1606 |
|
std::ofstream file(path, std::ios_base::out | std::ios_base::binary); |
|
1607 |
|
|
|
1608 |
|
boost::iostreams::filtering_ostreambuf out; |
|
1609 |
|
out.push(boost::iostreams::gzip_compressor()); |
|
1610 |
|
out.push(file); |
|
1611 |
|
|
|
1612 |
|
std::basic_ostream<char>(&out) << contents; |
|
1613 |
|
} |
|