This commit is contained in:
Lukas Spieß 2016-02-03 23:20:09 +01:00
Родитель 9682cd4914
Коммит d459732e5d
15 изменённых файлов: 7 добавлений и 780 удалений

Просмотреть файл

@ -765,7 +765,6 @@
1E5954CC15B6F24A00A03429 /* Sources */,
1E5954DB15B6F24A00A03429 /* Frameworks */,
1E59558B15B6FD8800A03429 /* Headers */,
1EE9071A16F6871F003DDE1D /* ShellScript */,
);
buildRules = (
);
@ -861,19 +860,6 @@
shellPath = /bin/sh;
shellScript = "/usr/local/bin/appledoc \\\n --output \"${SOURCE_ROOT}/../documentation\" \\\n --ignore Vendor \\\n --ignore Products \\\n --ignore Support \\\n --ignore .m \\\n --ignore *Private.h \\\n --create-html \\\n --create-docset \\\n --install-docset \\\n --keep-intermediate-files \\\n --project-name \"${MSAI_DOCSET_NAME} ${VERSION_STRING}\" \\\n --project-version \"${VERSION_STRING}\" \\\n --project-company \"Microsoft\" \\\n --company-id \"com.microsoft\" \\\n --docset-bundle-name \"${MSAI_DOCSET_NAME} ${VERSION_STRING}\" \\\n --docset-feed-name \"${MSAI_DOCSET_NAME}\" \\\n --docset-desc \"\" \\\n --docset-platform-family \"iphoneos\" \\\n --index-desc \"${SOURCE_ROOT}/../docs/index.md\" \\\n --include \"${SOURCE_ROOT}/../docs/index.html\" \\\n --include \"${SOURCE_ROOT}/../docs/\" \\\n --merge-categories \\\n --no-repeat-first-par \\\n --warn-undocumented-object \\\n --warn-undocumented-member \\\n --warn-empty-description \\\n --warn-unknown-directive \\\n --warn-invalid-crossref \\\n --warn-missing-arg \\\n --logformat xcode \\\n --exit-threshold 2 \\\n \"${SOURCE_ROOT}/../\"\n";
};
1EE9071A16F6871F003DDE1D /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [ \"${CONFIGURATION}\" = \"CodeCoverage\" ]; then\n \"${SRCROOT}/../Vendor/XcodeCoverage/exportenv.sh\"\nfi";
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */

Просмотреть файл

@ -22,10 +22,10 @@
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "CodeCoverage">
shouldUseLaunchSchemeArgsEnv = "YES">
<PostActions>
<ExecutionAction
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
@ -66,15 +66,18 @@
ReferencedContainer = "container:ApplicationInsights.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
@ -89,10 +92,10 @@
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference

2
Vendor/XcodeCoverage/.gitignore поставляемый
Просмотреть файл

@ -1,2 +0,0 @@
env.sh
lcov-*

44
Vendor/XcodeCoverage/CHANGES.md поставляемый
Просмотреть файл

@ -1,44 +0,0 @@
Version 1.2.2
-------------
_22 Mar 2015_
* Add `getcov` command line parameters, making it easier to use XcodeCoverage in continuous integration. _Thanks to: Tom Aylesworth_
* Add Cobertura XML generation. _Thanks to: Ellen Shapiro_
* Support use as CocoaPod. _Thanks to: Ellen Shapiro_
* Update to lcov 1.11. _Thanks to: Ellen Shapiro_
* Add XcodeCoverage.xcconfig for simple project setup.
Version 1.1.1
-------------
_13 Nov 2014_
* Exclude "Developer/SDKs" instead of "Applications/Xcode.app" so that people can use multiple versions of Xcode. _Thanks to: Cédric Luthi_
* Quote arguments to support built products directory containing spaces. _Thanks to: Cédric Luthi_
* Fix functionality optional post-test dialog in other locales by forcing buttons to be in English.
Version 1.1.0
-------------
_30 Mar 2014_
* Support Xcode 5.1. _Thanks to: Mike Maietta_
* Add optional post-test script `run_code_coverage_post.sh` to prompt whether to generate coverage report. _Thanks to: Matthew Purland_
* Improve function coverage by specifying `--derive-func-data`. _Thanks to: jstevenco_
* Directly include copy of lcov 1.10.
Version 1.0.1
-------------
_09 Mar 2014_
* Fix: Use `CURRENT_ARCH` instead of `NATIVE_ARCH`. _Thanks to: Scott Densmore_
* Improve scripts so they can be run from any working directory.
* Export `OBJROOT` so that customizations can include subprojects.
Version 1.0.0
-------------
_01 Dec 2012_
* Initial release

21
Vendor/XcodeCoverage/LICENSE.txt поставляемый
Просмотреть файл

@ -1,21 +0,0 @@
XcodeCoverage by Jon Reid, http://qualitycoding/about/
Copyright 2015 Jonathan M. Reid
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(MIT License)

94
Vendor/XcodeCoverage/README.md поставляемый
Просмотреть файл

@ -1,94 +0,0 @@
![XcodeCoverage](http://qualitycoding.org/jrwp/wp-content/uploads/2014/03/XcodeCoverage.png)
XcodeCoverage provides a simple way to generate reports of the code coverage of your Xcode project. Generated reports include HTML and Cobertura XML.
Coverage data excludes Apple's SDKs, and the exclusion rules can be customized.
Installation: Standard
======================
Use the standard installation if you want to customize XcodeCoverage to exclude certain files and directories, such as third-party libraries. Otherwise, the CocoaPods installation described below may be more convenient.
1. Fork this repository.
2. Place the XcodeCoverage folder in the same folder as your Xcode project.
3. In your main target, add a Run Script build phase to execute `XcodeCoverage/exportenv.sh`
A few people have been tripped up by the last step: Make sure you add the script to your main target (your app or library), not your test target.
Installation: CocoaPods
=======================
A [CocoaPod](http://cocoapods.org/) has been added for convenient use in simple projects. There are a couple of things you should be aware of if you are using the CocoaPod instead of the standard method:
- There will be no actual files added to your project. Files are only added through `preserve_paths`, so they will be available in your `Pods/XcodeCoverage` path, but you will not see them in Xcode, and they will not be compiled by Xcode.
- You will not be able to modify the scripts without those modifications being potentially overwritten by CocoaPods.
If those caveats are deal-breakers, please use the standard installation method above.
The steps to install via CocoaPods:
1. Add `pod 'XcodeCoverage', '~>1.0'` (or whatever [version specification](http://guides.cocoapods.org/using/the-podfile.html#specifying-pod-versions) you desire) to your Podfile.
2. Run `pod install`. This will download the necessary files.
3. In your main target, add a Run Script build phase to execute
`Pods/XcodeCoverage/exportenv.sh`.
Again, make sure you add the script to your main target (your app or library), not your test target.
Xcode Project Setup
===================
XcodeCoverage comes with an xcconfig file with the build settings required to instrument your code for coverage analysis.
If you already use an xcconfig, include it in the configuration you want to instrument:
* Standard installation: `#include "XcodeCoverage/XcodeCoverage.xcconfig"`
* CocoaPods installation: `#include "Pods/XcodeCoverage/XcodeCoverage.xcconfig"`
If you don't already use an xcconfig, drag XcodeCoverage.xcconfig into your project. Where it prompts "Add to targets," deselect all targets. (Otherwise, it will be included in the bundle.) Then click on your project in Xcode's Navigator pane, and select the Info tab. For the configuration you want to instrument, select XcodeCoverage.
If you'd rather specify the build settings by hand, enable these two settings at the project level:
* Instrument Program Flow
* Generate Test Coverage Files
Make sure not to instrument your AppStore release.
Execution
=========
1. Run your unit tests.
2. In Terminal, execute `getcov` in your project's XcodeCoverage folder.
`getcov` has the following command-line options:
* `--show` or `-s`: Show HTML report.
* `--xml` or `-x`: Generate Cobertura XML.
* `-o output_dir`: Specify output directory.
* `-i info_file`: Specify name of generated lcov info file.
* `-v`: Enable verbose output.
* `-h` or `--help`: Show usage.
If you make changes to your test code without changing the production code and want a clean slate, use the `cleancov` script.
If you make changes to your production code, you should clear out all build artifacts before measuring code coverage again. "Clean Build Folder" by holding down the Option key in Xcode's "Product" menu, or by using the ⌥⇧⌘K key combination.
**Optional:** XcodeCoverage can prompt to run code coverage after running unit tests:
* Edit Xcode scheme -> Test -> Post-actions
* Set "Shell" to: `/bin/bash`
* Set "Provide build settings from" to your main target
* Set script to `source XcodeCoverage/run_code_coverage_post.sh` for standard installation. For CocoaPods installation, use `source Pods/XcodeCoverage/run_code_coverage_post.sh`
Modification
============
If you are using the standard installation, you can modify `exclude_data()` in `getcov` to specify which files to exclude, such as third-party libraries.
Credits
=======
The `lcov` -> Cobertura script is from [https://github.com/eriwen/lcov-to-cobertura-xml/](https://github.com/eriwen/lcov-to-cobertura-xml/) and is bound by [the license of that project](https://github.com/eriwen/lcov-to-cobertura-xml/blob/master/LICENSE.txt).

22
Vendor/XcodeCoverage/XcodeCoverage.podspec поставляемый
Просмотреть файл

@ -1,22 +0,0 @@
Pod::Spec.new do |s|
s.name = 'XcodeCoverage'
s.version = '1.2.2'
s.summary = 'Code coverage for Xcode projects'
s.description = <<-DESC
XcodeCoverage provides a simple way to generate reports of the code coverage
of your Xcode project. Generated reports include HTML and Cobertura XML.
Coverage data excludes Apple's SDKs, and the exclusion rules can be customized.
DESC
s.homepage = 'https://github.com/jonreid/XcodeCoverage'
s.license = 'MIT'
s.author = {'Jon Reid' => 'jon@qualitycoding.org'}
s.social_media_url = 'https://twitter.com/qcoding'
s.ios.deployment_target = '6.0'
s.osx.deployment_target = '10.8'
s.source = {:git => 'https://github.com/jonreid/XcodeCoverage.git', :tag => 'v1.2.2'}
# XcodeCoverage files will be brought into the filesystem, but not added to your .xcodeproj.
s.preserve_paths = '*', '**'
end

5
Vendor/XcodeCoverage/XcodeCoverage.xcconfig поставляемый
Просмотреть файл

@ -1,5 +0,0 @@
// XcodeCoverage by Jon Reid, http://qualitycoding.org/about/
// Source: https://github.com/jonreid/XcodeCoverage
GCC_GENERATE_TEST_COVERAGE_FILES = YES
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES

8
Vendor/XcodeCoverage/cleancov поставляемый
Просмотреть файл

@ -1,8 +0,0 @@
#!/bin/bash
# XcodeCoverage by Jon Reid, http://qualitycoding/about/
# Copyright 2015 Jonathan M. Reid. See LICENSE.txt
scripts="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${scripts}/envcov.sh"
LCOV --zerocounters -d "${OBJ_DIR}"

14
Vendor/XcodeCoverage/envcov.sh поставляемый
Просмотреть файл

@ -1,14 +0,0 @@
#!/bin/bash
# XcodeCoverage by Jon Reid, http://qualitycoding/about/
# Copyright 2015 Jonathan M. Reid. See LICENSE.txt
scripts="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${scripts}/env.sh"
LCOV_PATH="${scripts}/lcov-1.11/bin"
OBJ_DIR="${OBJECT_FILE_DIR_normal}/${CURRENT_ARCH}"
# Fix for the new LLVM-COV that requires gcov to have a -v parameter
LCOV() {
"${LCOV_PATH}/lcov" "$@" --gcov-tool "${scripts}/llvm-cov-wrapper.sh"
}

5
Vendor/XcodeCoverage/exportenv.sh поставляемый
Просмотреть файл

@ -1,5 +0,0 @@
# XcodeCoverage by Jon Reid, http://qualitycoding/about/
# Copyright 2015 Jonathan M. Reid. See LICENSE.txt
scripts="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export | egrep '( BUILT_PRODUCTS_DIR)|(CURRENT_ARCH)|(OBJECT_FILE_DIR_normal)|(SRCROOT)|(OBJROOT)' > "${scripts}/env.sh"

142
Vendor/XcodeCoverage/getcov поставляемый
Просмотреть файл

@ -1,142 +0,0 @@
#!/bin/bash
# XcodeCoverage by Jon Reid, http://qualitycoding/about/
# Copyright 2015 Jonathan M. Reid. See LICENSE.txt
usage() {
echo "usage: getcov [[-s] [-x] [-o output_dir] [-i info_file] [-v]] | [-h]]"
}
main() {
scripts="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "${scripts}/envcov.sh"
LCOV_INFO=Coverage.info
output_dir="${BUILT_PRODUCTS_DIR}"
while [ "$1" != "" ]; do
case $1 in
-s|--show)
show_html=1
echo "Show HTML Report"
;;
-x|--xml)
generate_xml=1
echo "Generate Cobertura XML"
;;
-o)
shift
output_dir=$1
echo "output_dir = ${output_dir}"
;;
-i)
shift
LCOV_INFO=$1
echo "LCOV_INFO = ${LCOV_INFO}"
;;
-v)
verbose=1
echo "Verbose"
;;
-h|--help)
usage
echo "Show Help"
exit
;;
*)
usage
exit 1
esac
shift
done
if [ "$verbose" = "1" ]; then
report_values
fi
remove_old_report
enter_lcov_dir
gather_coverage
exclude_data
if [ "$generate_xml" = "1" ]; then
generate_cobertura_xml
fi
generate_html_report
if [ "$show_html" = "1" ]; then
show_html_report
fi
}
report_values() {
echo "XcodeCoverage: Environment"
echo "scripts : ${scripts}"
echo "output_dir : ${output_dir}"
echo "LCOV_INFO : ${LCOV_INFO}"
echo "BUILD_DIR : ${BUILT_PRODUCTS_DIR}"
echo "SRCROOT : ${SRCROOT}"
echo "OBJ_DIR : ${OBJ_DIR}"
echo "LCOV_PATH : ${LCOV_PATH}"
}
remove_old_report() {
if [ "$verbose" = "1" ]; then
echo "XcodeCoverage: Removing old report"
fi
pushd "${output_dir}"
if [ -e lcov ]; then
rm -r lcov
fi
popd
}
enter_lcov_dir() {
cd "${output_dir}"
mkdir lcov
cd lcov
}
gather_coverage() {
if [ "$verbose" = "1" ]; then
echo "XcodeCoverage: Gathering coverage"
fi
LCOV --capture --derive-func-data -b "${SRCROOT}" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
}
exclude_data() {
if [ "$verbose" = "1" ]; then
echo "XcodeCoverage: Excluding data"
fi
LCOV --remove "${LCOV_INFO}" "Developer/SDKs/*" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
LCOV --remove "${LCOV_INFO}" "main.m" -d "${OBJ_DIR}" -o "${LCOV_INFO}"
# Remove other patterns here...
}
generate_cobertura_xml() {
if [ "$verbose" = "1" ]; then
echo "XcodeCoverage: Generating Cobertura XML"
fi
python "${scripts}/lcov_cobertura.py" ${LCOV_INFO} --base-dir "${SRCROOT}" --output "coverage.xml"
}
generate_html_report() {
if [ "$verbose" = "1" ]; then
echo "XcodeCoverage: Generating HTML report"
fi
"${LCOV_PATH}/genhtml" --output-directory . "${LCOV_INFO}"
}
show_html_report() {
if [ "$verbose" = "1" ]; then
echo "XcodeCoverage: Opening HTML report"
fi
open index.html
}
main "$@"

377
Vendor/XcodeCoverage/lcov_cobertura.py поставляемый
Просмотреть файл

@ -1,377 +0,0 @@
#!/usr/bin/env python
# Copyright 2011-2012 Eric Wendelin
#
# This is free software, licensed under the Apache License, Version 2.0,
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Converts lcov line coverage output to Cobertura-compatible XML for CI
"""
import re
import sys
import os
import time
from xml.dom import minidom
from optparse import OptionParser
VERSION = '1.5'
__all__ = ['LcovCobertura']
class LcovCobertura(object):
"""
Converts code coverage report files in lcov format to Cobertura's XML
report format so that CI servers like Jenkins can aggregate results and
determine build stability etc.
>>> from lcov_cobertura import LcovCobertura
>>> LCOV_INPUT = 'your lcov input'
>>> converter = LcovCobertura(LCOV_INPUT)
>>> cobertura_xml = converter.convert()
>>> print cobertura_xml
"""
def __init__(self, lcov_data, base_dir='.', excludes=None):
"""
Create a new :class:`LcovCobertura` object using the given `lcov_data`
and `options`.
:param lcov_data: Path to LCOV data file
:type lcov_data: string
:param base_dir: Path upon which to base all sources
:type base_dir: string
:param excludes: list of regexes to packages as excluded
:type excludes: [string]
"""
if not excludes:
excludes = []
self.lcov_data = lcov_data
self.base_dir = base_dir
self.excludes = excludes
def convert(self):
"""
Convert lcov file to cobertura XML using options from this instance.
"""
coverage_data = self.parse()
return self.generate_cobertura_xml(coverage_data)
def parse(self):
"""
Generate a data structure representing it that can be serialized in any
logical format.
"""
coverage_data = {
'packages': {},
'summary': {'lines-total': 0, 'lines-covered': 0,
'branches-total': 0, 'branches-covered': 0},
'timestamp': str(int(time.time()))
}
package = None
current_file = None
file_lines_total = 0
file_lines_covered = 0
file_lines = {}
file_methods = {}
file_branches_total = 0
file_branches_covered = 0
for line in self.lcov_data.split('\n'):
if line.strip() == 'end_of_record':
if current_file is not None:
package_dict = coverage_data['packages'][package]
package_dict['lines-total'] += file_lines_total
package_dict['lines-covered'] += file_lines_covered
package_dict['branches-total'] += file_branches_total
package_dict['branches-covered'] += file_branches_covered
file_dict = package_dict['classes'][current_file]
file_dict['lines-total'] = file_lines_total
file_dict['lines-covered'] = file_lines_covered
file_dict['lines'] = dict(file_lines)
file_dict['methods'] = dict(file_methods)
file_dict['branches-total'] = file_branches_total
file_dict['branches-covered'] = file_branches_covered
coverage_data['summary']['lines-total'] += file_lines_total
coverage_data['summary']['lines-covered'] += file_lines_covered
coverage_data['summary']['branches-total'] += file_branches_total
coverage_data['summary']['branches-covered'] += file_branches_covered
line_parts = line.split(':', 1)
input_type = line_parts[0]
if input_type == 'SF':
# Get file name
file_name = line_parts[-1].strip()
relative_file_name = os.path.relpath(file_name, self.base_dir)
package = '.'.join(relative_file_name.split(os.path.sep)[0:-1])
class_name = file_name.split(os.path.sep)[-1]
if package not in coverage_data['packages']:
coverage_data['packages'][package] = {
'classes': {}, 'lines-total': 0, 'lines-covered': 0,
'branches-total': 0, 'branches-covered': 0
}
coverage_data['packages'][package]['classes'][
relative_file_name] = {
'name': class_name, 'lines': {}, 'lines-total': 0,
'lines-covered': 0, 'branches-total': 0,
'branches-covered': 0
}
package = package
current_file = relative_file_name
file_lines_total = 0
file_lines_covered = 0
file_lines.clear()
file_methods.clear()
file_branches_total = 0
file_branches_covered = 0
elif input_type == 'DA':
# DA:2,0
(line_number, line_hits) = line_parts[-1].strip().split(',')
line_number = int(line_number)
if line_number not in file_lines:
file_lines[line_number] = {
'branch': 'false', 'branches-total': 0,
'branches-covered': 0
}
file_lines[line_number]['hits'] = line_hits
# Increment lines total/covered for class and package
try:
if int(line_hits) > 0:
file_lines_covered += 1
except:
pass
file_lines_total += 1
elif input_type == 'BRDA':
# BRDA:1,1,2,0
(line_number, block_number, branch_number, branch_hits) = line_parts[-1].strip().split(',')
line_number = int(line_number)
if line_number not in file_lines:
file_lines[line_number] = {
'branch': 'true', 'branches-total': 0,
'branches-covered': 0, 'hits': 0
}
file_lines[line_number]['branch'] = 'true'
file_lines[line_number]['branches-total'] += 1
file_branches_total += 1
if branch_hits != '-' and int(branch_hits) > 0:
file_lines[line_number]['branches-covered'] += 1
file_branches_covered += 1
elif input_type == 'BRF':
file_branches_total = int(line_parts[1])
elif input_type == 'BRH':
file_branches_covered = int(line_parts[1])
elif input_type == 'FN':
# FN:5,(anonymous_1)
function_name = line_parts[-1].strip().split(',')[1]
file_methods[function_name] = '0'
elif input_type == 'FNDA':
# FNDA:0,(anonymous_1)
(function_hits, function_name) = line_parts[-1].strip().split(',')
file_methods[function_name] = function_hits
# Exclude packages
excluded = [x for x in coverage_data['packages'] for e in self.excludes
if re.match(e, x)]
for package in excluded:
del coverage_data['packages'][package]
# Compute line coverage rates
for package_data in list(coverage_data['packages'].values()):
package_data['line-rate'] = self._percent(
package_data['lines-total'],
package_data['lines-covered'])
package_data['branch-rate'] = self._percent(
package_data['branches-total'],
package_data['branches-covered'])
return coverage_data
def generate_cobertura_xml(self, coverage_data):
"""
Given parsed coverage data, return a String cobertura XML representation.
:param coverage_data: Nested dict representing coverage information.
:type coverage_data: dict
"""
dom_impl = minidom.getDOMImplementation()
doctype = dom_impl.createDocumentType("coverage", None,
"http://cobertura.sourceforge.net/xml/coverage-03.dtd")
document = dom_impl.createDocument(None, "coverage", doctype)
root = document.documentElement
summary = coverage_data['summary']
self._attrs(root, {
'branch-rate': self._percent(summary['branches-total'],
summary['branches-covered']),
'branches-covered': str(summary['branches-covered']),
'branches-valid': str(summary['branches-total']),
'complexity': '0',
'line-rate': self._percent(summary['lines-total'],
summary['lines-covered']),
'lines-valid': str(summary['lines-total']),
'timestamp': coverage_data['timestamp'],
'version': '1.9'
})
sources = self._el(document, 'sources', {})
source = self._el(document, 'source', {})
source.appendChild(document.createTextNode(self.base_dir))
sources.appendChild(source)
root.appendChild(sources)
packages_el = self._el(document, 'packages', {})
packages = coverage_data['packages']
for package_name, package_data in list(packages.items()):
package_el = self._el(document, 'package', {
'line-rate': package_data['line-rate'],
'branch-rate': package_data['branch-rate'],
'name': package_name
})
classes_el = self._el(document, 'classes', {})
for class_name, class_data in list(package_data['classes'].items()):
class_el = self._el(document, 'class', {
'branch-rate': self._percent(class_data['branches-total'],
class_data['branches-covered']),
'complexity': '0',
'filename': class_name,
'line-rate': self._percent(class_data['lines-total'],
class_data['lines-covered']),
'name': class_data['name']
})
# Process methods
methods_el = self._el(document, 'methods', {})
for method_name, hits in list(class_data['methods'].items()):
method_el = self._el(document, 'method', {
'name': method_name,
'signature': '',
'hits': hits
})
methods_el.appendChild(method_el)
# Process lines
lines_el = self._el(document, 'lines', {})
lines = list(class_data['lines'].keys())
lines.sort()
for line_number in lines:
line_el = self._el(document, 'line', {
'branch': class_data['lines'][line_number]['branch'],
'hits': str(class_data['lines'][line_number]['hits']),
'number': str(line_number)
})
if class_data['lines'][line_number]['branch'] == 'true':
total = int(class_data['lines'][line_number]['branches-total'])
covered = int(class_data['lines'][line_number]['branches-covered'])
percentage = int((covered * 100.0) / total)
line_el.setAttribute('condition-coverage',
'{0}% ({1}/{2})'.format(
percentage, covered, total))
lines_el.appendChild(line_el)
class_el.appendChild(methods_el)
class_el.appendChild(lines_el)
classes_el.appendChild(class_el)
package_el.appendChild(classes_el)
packages_el.appendChild(package_el)
root.appendChild(packages_el)
return document.toprettyxml()
def _el(self, document, name, attrs):
"""
Create an element within document with given name and attributes.
:param document: Document element
:type document: Document
:param name: Element name
:type name: string
:param attrs: Attributes for element
:type attrs: dict
"""
return self._attrs(document.createElement(name), attrs)
def _attrs(self, element, attrs):
"""
Set attributes on given element.
:param element: DOM Element
:type element: Element
:param attrs: Attributes for element
:type attrs: dict
"""
for attr, val in list(attrs.items()):
element.setAttribute(attr, val)
return element
def _percent(self, lines_total, lines_covered):
"""
Get the percentage of lines covered in the total, with formatting.
:param lines_total: Total number of lines in given module
:type lines_total: number
:param lines_covered: Number of lines covered by tests in module
:type lines_covered: number
"""
if lines_total == 0:
return '0.0'
return str(float(float(lines_covered) / float(lines_total)))
if __name__ == '__main__':
def main(argv):
"""
Converts LCOV coverage data to Cobertura-compatible XML for reporting.
Usage:
lcov_cobertura.py lcov-file.dat
lcov_cobertura.py lcov-file.dat -b src/dir -e test.lib -o path/out.xml
By default, XML output will be written to ./coverage.xml
"""
parser = OptionParser()
parser.usage = 'lcov_cobertura.py lcov-file.dat [-b source/dir] [-e <exclude packages regex>] [-o output.xml]'
parser.description = 'Converts lcov output to cobertura-compatible XML'
parser.add_option('-b', '--base-dir', action='store',
help='Directory where source files are located',
dest='base_dir', default='.')
parser.add_option('-e', '--excludes',
help='Comma-separated list of regexes of packages to exclude',
action='append', dest='excludes', default=[])
parser.add_option('-o', '--output',
help='Path to store cobertura xml file',
action='store', dest='output', default='coverage.xml')
(options, args) = parser.parse_args(args=argv)
if len(args) != 2:
print((main.__doc__))
sys.exit(1)
try:
with open(args[1], 'r') as lcov_file:
lcov_data = lcov_file.read()
lcov_cobertura = LcovCobertura(lcov_data, options.base_dir, options.excludes)
cobertura_xml = lcov_cobertura.convert()
with open(options.output, mode='wt') as output_file:
output_file.write(cobertura_xml)
except IOError:
sys.stderr.write("Unable to convert %s to Cobertura XML" % args[1])
main(sys.argv)

10
Vendor/XcodeCoverage/llvm-cov-wrapper.sh поставляемый
Просмотреть файл

@ -1,10 +0,0 @@
#!/bin/bash
# XcodeCoverage by Jon Reid, http://qualitycoding/about/
# Copyright 2015 Jonathan M. Reid. See LICENSE.txt
if [ "$1" = "-v" ]; then
echo "llvm-cov-wrapper 4.2.1"
exit 0
else
/usr/bin/gcov "$@"
fi

Просмотреть файл

@ -1,18 +0,0 @@
#!/bin/bash
# XcodeCoverage by Jon Reid, http://qualitycoding/about/
# Copyright 2015 Jonathan M. Reid. See LICENSE.txt
button=`/usr/bin/osascript <<EOT
tell application "Finder"
activate
set dialogText to "Generate code coverage report?"
set cancelText to "Cancel"
set okText to "OK"
set myReply to button returned of (display dialog dialogText buttons {cancelText, okText} cancel button cancelText default button okText)
end tell
EOT`
if [[ "${button}" = "OK" ]]; then
scripts="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
"${scripts}/getcov" --show
fi