summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-10-08 13:53:25 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-10-08 13:53:25 (GMT)
commit2ba45f52857dc0a98edb4e392b27276ea927e92c (patch)
treec9fd8c01cf93a3a72ea474429b601c630bb8f455 /Tests
parent5bf71025056465ebacf49b9da6446b8ed7833a95 (diff)
parentd0ec3a01a61f259768d31fc20791780807e1788e (diff)
downloadCMake-2ba45f52857dc0a98edb4e392b27276ea927e92c.zip
CMake-2ba45f52857dc0a98edb4e392b27276ea927e92c.tar.gz
CMake-2ba45f52857dc0a98edb4e392b27276ea927e92c.tar.bz2
Merge topic 'Add-coverage.py-Coverage'
d0ec3a0 Adding support for the Python coverage.py tool.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt19
-rw-r--r--Tests/PythonCoverage/DartConfiguration.tcl.in8
-rw-r--r--Tests/PythonCoverage/coverage.xml.in35
-rw-r--r--Tests/PythonCoverage/coveragetest/foo.py8
-rw-r--r--Tests/PythonCoverage/coveragetest/test_foo.py11
5 files changed, 81 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 2d35b5a..504f4bb 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1960,6 +1960,25 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
PASS_REGULAR_EXPRESSION
"Process file.*XINDEX.m.*Total LOC:.*125.*Percentage Coverage: 85.60.*"
ENVIRONMENT COVFILE=)
+
+ # Adding a test case for Python Coverage
+ configure_file(
+ "${CMake_SOURCE_DIR}/Tests/PythonCoverage/coverage.xml.in"
+ "${CMake_BINARY_DIR}/Testing/PythonCoverage/coverage.xml")
+ configure_file(
+ "${CMake_SOURCE_DIR}/Tests/PythonCoverage/DartConfiguration.tcl.in"
+ "${CMake_BINARY_DIR}/Testing/PythonCoverage/DartConfiguration.tcl")
+ file(COPY "${CMake_SOURCE_DIR}/Tests/PythonCoverage/coveragetest"
+ DESTINATION "${CMake_BINARY_DIR}/Testing/PythonCoverage")
+ add_test(NAME CTestPythonCoverage
+ COMMAND cmake -E chdir
+ ${CMake_BINARY_DIR}/Testing/PythonCoverage
+ $<TARGET_FILE:ctest> -T Coverage --debug)
+ set_tests_properties(CTestPythonCoverage PROPERTIES
+ PASS_REGULAR_EXPRESSION
+ "Process file.*foo.py.*Total LOC:.*13.*Percentage Coverage: 84.62.*"
+ ENVIRONMENT COVFILE=)
+
# Use macro, not function so that build can still be driven by CMake 2.4.
# After 2.6 is required, this could be a function without the extra 'set'
# calls.
diff --git a/Tests/PythonCoverage/DartConfiguration.tcl.in b/Tests/PythonCoverage/DartConfiguration.tcl.in
new file mode 100644
index 0000000..e29cffe
--- /dev/null
+++ b/Tests/PythonCoverage/DartConfiguration.tcl.in
@@ -0,0 +1,8 @@
+# This file is configured by CMake automatically as DartConfiguration.tcl
+# If you choose not to use CMake, this file may be hand configured, by
+# filling in the required variables.
+
+
+# Configuration directories and files
+SourceDirectory: ${CMake_BINARY_DIR}/Testing/PythonCoverage/coveragetest
+BuildDirectory: ${CMake_BINARY_DIR}/Testing/PythonCoverage
diff --git a/Tests/PythonCoverage/coverage.xml.in b/Tests/PythonCoverage/coverage.xml.in
new file mode 100644
index 0000000..fcc1b1c
--- /dev/null
+++ b/Tests/PythonCoverage/coverage.xml.in
@@ -0,0 +1,35 @@
+<?xml version="1.0" ?>
+<!DOCTYPE coverage
+ SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-03.dtd'>
+<coverage branch-rate="0" line-rate="0.8462" timestamp="1380469411433" version="3.6">
+ <!-- Generated by coverage.py: http://nedbatchelder.com/code/coverage -->
+ <packages>
+ <package branch-rate="0" complexity="0" line-rate="0.8462" name="">
+ <classes>
+ <class branch-rate="0" complexity="0" filename="foo.py" line-rate="0.6667" name="foo">
+ <methods/>
+ <lines>
+ <line hits="1" number="2"/>
+ <line hits="1" number="3"/>
+ <line hits="1" number="4"/>
+ <line hits="1" number="6"/>
+ <line hits="0" number="7"/>
+ <line hits="0" number="8"/>
+ </lines>
+ </class>
+ <class branch-rate="0" complexity="0" filename="test_foo.py" line-rate="1" name="test_foo">
+ <methods/>
+ <lines>
+ <line hits="1" number="2"/>
+ <line hits="1" number="3"/>
+ <line hits="1" number="5"/>
+ <line hits="1" number="7"/>
+ <line hits="1" number="8"/>
+ <line hits="1" number="10"/>
+ <line hits="1" number="11"/>
+ </lines>
+ </class>
+ </classes>
+ </package>
+ </packages>
+</coverage>
diff --git a/Tests/PythonCoverage/coveragetest/foo.py b/Tests/PythonCoverage/coveragetest/foo.py
new file mode 100644
index 0000000..97b5a41
--- /dev/null
+++ b/Tests/PythonCoverage/coveragetest/foo.py
@@ -0,0 +1,8 @@
+
+def foo():
+ x = 3 + 3
+ return x
+
+def bar():
+ y = 2 + 2
+ return y
diff --git a/Tests/PythonCoverage/coveragetest/test_foo.py b/Tests/PythonCoverage/coveragetest/test_foo.py
new file mode 100644
index 0000000..51a69d8
--- /dev/null
+++ b/Tests/PythonCoverage/coveragetest/test_foo.py
@@ -0,0 +1,11 @@
+
+import foo
+import unittest
+
+class TestFoo(unittest.TestCase):
+
+ def testFoo(self):
+ self.assertEquals(foo.foo(), 6, 'foo() == 6')
+
+if __name__ == '__main__':
+ unittest.main()