Closed tjanc closed 5 years ago
Generate test coverage when running ctest with the script cmake/unix-coverage.cmake.
cmake/unix-coverage.cmake
gcov coverage files are in build/Testing/CoverageInfo/ after running
gcov
build/Testing/CoverageInfo/
$drafter> ctest -S cmake/unix-coverage.cmake
For example:
-: 0:Source:/home/tj/projects/apiary/drafter/src/refract/dsd/Number.cc -: 0:Graph:/home/tj/projects/apiary/drafter/build/src/CMakeFiles/drafter.dir/refract/dsd/Number.cc.gcno -: 0:Data:/home/tj/projects/apiary/drafter/build/src/CMakeFiles/drafter.dir/refract/dsd/Number.cc.gcda -: 0:Runs:1 -: 0:Programs:1 -: 1:// -: 2:// refract/dsd/Number.cc -: 3:// librefract -: 4:// -: 5:// Created by Thomas Jandecka on 04/09/2017 -: 6:// Copyright (c) 2017 Apiary Inc. All rights reserved. -: 7:// -: 8: -: 9:#include "Number.h" -: 10: -: 11:#include "Traits.h" -: 12:#include "../../utils/log/Trivial.h" -: 13: -: 14:using namespace refract; -: 15:using namespace dsd; -: 16:using namespace drafter::utils::log; -: 17: -: 18:const char* Number::name = "number"; -: 19: -: 20:static_assert(!supports_erase<Number>::value, ""); -: 21:static_assert(!supports_empty<Number>::value, ""); -: 22:static_assert(!supports_insert<Number>::value, ""); -: 23:static_assert(!supports_push_back<Number>::value, ""); -: 24:static_assert(!supports_begin<Number>::value, ""); -: 25:static_assert(!supports_end<Number>::value, ""); -: 26:static_assert(!supports_size<Number>::value, ""); -: 27:static_assert(!supports_erase<Number>::value, ""); -: 28:static_assert(!supports_key<Number>::value, ""); -: 29:static_assert(!supports_value<Number>::value, ""); -: 30:static_assert(!supports_merge<Number>::value, ""); -: 31:static_assert(!is_iterable<Number>::value, ""); -: 32:static_assert(!is_pair<Number>::value, ""); -: 33: 366: 34:Number::Number(std::string v) noexcept : value_(v) {} -: 35: 1856: 36:const std::string& Number::get() const noexcept -: 37:{ 1856: 38: return value_; -: 39:} -: 40: #####: 41:Number::operator std::int64_t() const noexcept -: 42:{ -: 43: std::string::size_type idx; #####: 44: std::int64_t result = std::stoi(value_, &idx); #####: 45: if (idx < value_.size()) #####: 46: LOG(warning) << "dsd::Number to int; dropped trailing `" << value_.substr(idx) << "`"; #####: 47: return result; -: 48:} -: 49: 79: 50:bool dsd::operator==(const Number& lhs, const Number& rhs) noexcept -: 51:{ 79: 52: return lhs.get() == rhs.get(); -: 53:} -: 54: 3: 55:bool dsd::operator!=(const Number& lhs, const Number& rhs) noexcept -: 56:{ 3: 57: return !(lhs == rhs); -: 58:}
Generate test coverage when running ctest with the script
cmake/unix-coverage.cmake
.Notes
gcov
coverage files are inbuild/Testing/CoverageInfo/
after runningFor example: