xaizek / uncov (License: AGPLv3+) (since 2018-12-07)
Uncov(er) is a tool that collects and processes code coverage reports.
Commit 989d00159074b9a1f6c5069cc51acf0f85fdf151

Extract GcovImporter::parseGcovJson() method
Author: xaizek
Author date (UTC): 2022-04-08 10:27
Committer name: xaizek
Committer date (UTC): 2022-04-08 10:27
Parent(s): 3746004b29c8ae4b82463ddb69fc069695f87e81
Signing key: 99DC5E4DB05F6BE2
Tree: b988191f8e55f83f09fb57b36122f74422f821ad
File Lines added Lines deleted
src/GcovImporter.cpp 9 3
src/GcovImporter.hpp 7 0
File src/GcovImporter.cpp changed (mode: 100644) (index 4052ebc..2437084)
30 30 #include <istream> #include <istream>
31 31 #include <regex> #include <regex>
32 32 #include <set> #include <set>
33 #include <sstream>
33 34 #include <stdexcept> #include <stdexcept>
34 35 #include <string> #include <string>
35 36 #include <tuple> #include <tuple>
 
44 45 #include "integration.hpp" #include "integration.hpp"
45 46
46 47 namespace fs = boost::filesystem; namespace fs = boost::filesystem;
48 namespace pt = boost::property_tree;
47 49
48 50 // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89961 for information about // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89961 for information about
49 51 // what's wrong with some versions of `gcov` and why binning is needed. // what's wrong with some versions of `gcov` and why binning is needed.
 
... ... void
324 326 GcovImporter::parseGcovJsonGz(const std::string &path) GcovImporter::parseGcovJsonGz(const std::string &path)
325 327 { {
326 328 namespace io = boost::iostreams; namespace io = boost::iostreams;
327 namespace pt = boost::property_tree;
328 329
329 330 std::ifstream file(path, std::ios_base::in | std::ios_base::binary); std::ifstream file(path, std::ios_base::in | std::ios_base::binary);
330 331
 
... ... GcovImporter::parseGcovJsonGz(const std::string &path)
332 333 in.push(io::gzip_decompressor()); in.push(io::gzip_decompressor());
333 334 in.push(file); in.push(file);
334 335
335 std::basic_istream<char> is(&in);
336 std::istream is(&in);
337 parseGcovJson(is);
338 }
336 339
340 void
341 GcovImporter::parseGcovJson(std::istream &stream)
342 {
337 343 pt::ptree props; pt::ptree props;
338 pt::read_json(is, props);
344 pt::read_json(stream, props);
339 345
340 346 const std::string cwd = props.get<std::string>("current_working_directory"); const std::string cwd = props.get<std::string>("current_working_directory");
341 347
File src/GcovImporter.hpp changed (mode: 100644) (index 7991260..c65e352)
20 20 #include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
21 21
22 22 #include <functional> #include <functional>
23 #include <iosfwd>
23 24 #include <set> #include <set>
24 25 #include <string> #include <string>
25 26 #include <unordered_map> #include <unordered_map>
 
... ... private:
136 137 * @param path Path of the file. * @param path Path of the file.
137 138 */ */
138 139 void parseGcovJsonGz(const std::string &path); void parseGcovJsonGz(const std::string &path);
140 /**
141 * @brief Parses single JSON dictionary produced by `gcov`.
142 *
143 * @param stream Stream with JSON data.
144 */
145 void parseGcovJson(std::istream &stream);
139 146 /** /**
140 147 * @brief Parses single `*.gcov` file. * @brief Parses single `*.gcov` file.
141 148 * *
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/uncov

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/uncov

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master