summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-10-29 15:31:10 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2014-10-29 15:31:10 (GMT)
commite51cd32de34d9a2376594f80a6f31b4fb09c4e13 (patch)
treed762d0015e2c7f0d4785fcef2cd3bd29b5085b0c /Tests
parent0d6cdce5b5542250c067d846f037dfeca1bcc8e4 (diff)
parent220e81345b68ed3ad15ef294f6de653fcd1a874c (diff)
downloadCMake-e51cd32de34d9a2376594f80a6f31b4fb09c4e13.zip
CMake-e51cd32de34d9a2376594f80a6f31b4fb09c4e13.tar.gz
CMake-e51cd32de34d9a2376594f80a6f31b4fb09c4e13.tar.bz2
Merge topic 'add_javascript_coverage_parser'
220e8134 CTest: Add Javascript coverage parser
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt19
-rw-r--r--Tests/JavascriptCoverage/DartConfiguration.tcl.in8
-rw-r--r--Tests/JavascriptCoverage/output.json.in448
-rw-r--r--Tests/JavascriptCoverage/test.js53
-rw-r--r--Tests/JavascriptCoverage/test3.js37
5 files changed, 565 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index e1e90a1..586f983 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -2339,6 +2339,25 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"Process file.*CoverageTest.java.*Total LOC:.*17.*Percentage Coverage: 76.47*"
ENVIRONMENT COVFILE=)
+ # Adding a test case for Javascript Coverage
+ configure_file(
+ "${CMake_SOURCE_DIR}/Tests/JavascriptCoverage/DartConfiguration.tcl.in"
+ "${CMake_BINARY_DIR}/Testing/JavascriptCoverage/DartConfiguration.tcl")
+ configure_file(
+ "${CMake_SOURCE_DIR}/Tests/JavascriptCoverage/output.json.in"
+ "${CMake_BINARY_DIR}/Testing/JavascriptCoverage/output.json")
+ file(COPY "${CMake_SOURCE_DIR}/Tests/JavascriptCoverage/"
+ DESTINATION "${CMake_BINARY_DIR}/Testing/JavascriptCoverage"
+ FILES_MATCHING PATTERN "*.js")
+ add_test(NAME CTestJavascriptCoverage
+ COMMAND cmake -E chdir
+ ${CMake_BINARY_DIR}/Testing/JavascriptCoverage
+ $<TARGET_FILE:ctest> -T Coverage --debug)
+ set_tests_properties(CTestJavascriptCoverage PROPERTIES
+ PASS_REGULAR_EXPRESSION
+ "Process file.*test3.js.*Total LOC:.*49.*Percentage Coverage: 79.59*"
+ ENVIRONMENT COVFILE=)
+
# test coverage for Delphi-code-Coverage
configure_file(
"${CMake_SOURCE_DIR}/Tests/DelphiCoverage/DartConfiguration.tcl.in"
diff --git a/Tests/JavascriptCoverage/DartConfiguration.tcl.in b/Tests/JavascriptCoverage/DartConfiguration.tcl.in
new file mode 100644
index 0000000..f94d988
--- /dev/null
+++ b/Tests/JavascriptCoverage/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/JavascriptCoverage
+BuildDirectory: ${CMake_BINARY_DIR}/Testing/JavascriptCoverage
diff --git a/Tests/JavascriptCoverage/output.json.in b/Tests/JavascriptCoverage/output.json.in
new file mode 100644
index 0000000..717cffe
--- /dev/null
+++ b/Tests/JavascriptCoverage/output.json.in
@@ -0,0 +1,448 @@
+{
+ "instrumentation": "node-jscoverage",
+ "sloc": 29,
+ "hits": 28,
+ "misses": 1,
+ "coverage": 96.55172413793103,
+ "files": [
+ {
+ "filename": "${CMake_BINARY_DIR}/Testing/JavascriptCoverage/test.js",
+ "coverage": 96.55172413793103,
+ "hits": 28,
+ "misses": 1,
+ "sloc": 29,
+ "source": {
+ "1": {
+ "source": "var assert = require(\"assert\")",
+ "coverage": 1
+ },
+ "2": {
+ "source": "var test = {",
+ "coverage": 1
+ },
+ "3": {
+ "source": " version: \"1.0.0\"",
+ "coverage": ""
+ },
+ "4": {
+ "source": "}",
+ "coverage": ""
+ },
+ "5": {
+ "source": "function covTest(p1,p2) {",
+ "coverage": 1
+ },
+ "6": {
+ "source": " if (p1 > 3) {",
+ "coverage": 2
+ },
+ "7": {
+ "source": " return 1;",
+ "coverage": 1
+ },
+ "8": {
+ "source": " }",
+ "coverage": ""
+ },
+ "9": {
+ "source": " else {",
+ "coverage": ""
+ },
+ "10": {
+ "source": " return p1 + p2;",
+ "coverage": 1
+ },
+ "11": {
+ "source": " }",
+ "coverage": ""
+ },
+ "12": {
+ "source": "}",
+ "coverage": ""
+ },
+ "13": {
+ "source": "",
+ "coverage": ""
+ },
+ "14": {
+ "source": "function covTest2(p1,p2) {",
+ "coverage": 1
+ },
+ "15": {
+ "source": " return 0;",
+ "coverage": 0
+ },
+ "16": {
+ "source": "}",
+ "coverage": ""
+ },
+ "17": {
+ "source": "",
+ "coverage": ""
+ },
+ "18": {
+ "source": "function covTest3(p1) {",
+ "coverage": 1
+ },
+ "19": {
+ "source": " for(i=0;i < p1;i++){",
+ "coverage": 1
+ },
+ "20": {
+ "source": " }",
+ "coverage": ""
+ },
+ "21": {
+ "source": " return i;",
+ "coverage": 1
+ },
+ "22": {
+ "source": "}",
+ "coverage": ""
+ },
+ "23": {
+ "source": "function covTest4(p1) {",
+ "coverage": 1
+ },
+ "24": {
+ "source": " i=0;",
+ "coverage": 1
+ },
+ "25": {
+ "source": " while(i < p1){",
+ "coverage": 1
+ },
+ "26": {
+ "source": " i++;",
+ "coverage": 5
+ },
+ "27": {
+ "source": " }",
+ "coverage": ""
+ },
+ "28": {
+ "source": " return i;",
+ "coverage": 1
+ },
+ "29": {
+ "source": "}",
+ "coverage": ""
+ },
+ "30": {
+ "source": "",
+ "coverage": ""
+ },
+ "31": {
+ "source": "describe('Array', function(){",
+ "coverage": 1
+ },
+ "32": {
+ "source": " describe('CovTest', function(){",
+ "coverage": 1
+ },
+ "33": {
+ "source": " it('should return when the value is not present', function(){",
+ "coverage": 1
+ },
+ "34": {
+ "source": " assert.equal(4,covTest(2,2));",
+ "coverage": 1
+ },
+ "35": {
+ "source": " })",
+ "coverage": ""
+ },
+ "36": {
+ "source": " })",
+ "coverage": ""
+ },
+ "37": {
+ "source": " ",
+ "coverage": ""
+ },
+ "38": {
+ "source": " describe('CovTest>3', function(){",
+ "coverage": 1
+ },
+ "39": {
+ "source": " it('should return when the value is not present', function(){",
+ "coverage": 1
+ },
+ "40": {
+ "source": " assert.equal(1,covTest(4,2));",
+ "coverage": 1
+ },
+ "41": {
+ "source": " })",
+ "coverage": ""
+ },
+ "42": {
+ "source": " })",
+ "coverage": ""
+ },
+ "43": {
+ "source": " describe('covTest4', function(){",
+ "coverage": 1
+ },
+ "44": {
+ "source": " it('should return when the value is not present', function(){",
+ "coverage": 1
+ },
+ "45": {
+ "source": " assert.equal(5,covTest4(5));",
+ "coverage": 1
+ },
+ "46": {
+ "source": " })",
+ "coverage": ""
+ },
+ "47": {
+ "source": " })",
+ "coverage": ""
+ },
+ "48": {
+ "source": " describe('covTest3', function(){",
+ "coverage": 1
+ },
+ "49": {
+ "source": " it('should return when the value is not present', function(){",
+ "coverage": 1
+ },
+ "50": {
+ "source": " assert.equal(5,covTest3(5));",
+ "coverage": 1
+ },
+ "51": {
+ "source": " })",
+ "coverage": ""
+ },
+ "52": {
+ "source": " })",
+ "coverage": ""
+ },
+ "53": {
+ "source": "})",
+ "coverage": ""
+ },
+ "54": {
+ "source": "",
+ "coverage": ""
+ }
+ }
+ "filename": "${CMake_BINARY_DIR}/Testing/JavascriptCoverage/test3.js",
+ "coverage": 55.00000000000001,
+ "hits": 11,
+ "misses": 9,
+ "sloc": 20,
+ "source": {
+ "1": {
+ "source": "var assert = require(\"assert\")",
+ "coverage": 1
+ },
+ "2": {
+ "source": "var test = {",
+ "coverage": 1
+ },
+ "3": {
+ "source": " version: \"1.0.0\"",
+ "coverage": ""
+ },
+ "4": {
+ "source": "}",
+ "coverage": ""
+ },
+ "5": {
+ "source": "function covTest(p1,p2) {",
+ "coverage": 1
+ },
+ "6": {
+ "source": " if (p1 > 3) {",
+ "coverage": 0
+ },
+ "7": {
+ "source": " return 1;",
+ "coverage": 0
+ },
+ "8": {
+ "source": " }",
+ "coverage": ""
+ },
+ "9": {
+ "source": " else {",
+ "coverage": ""
+ },
+ "10": {
+ "source": " return p1 + p2;",
+ "coverage": 0
+ },
+ "11": {
+ "source": " }",
+ "coverage": ""
+ },
+ "12": {
+ "source": "}",
+ "coverage": ""
+ },
+ "13": {
+ "source": "",
+ "coverage": ""
+ },
+ "14": {
+ "source": "function covTest2(p1,p2) {",
+ "coverage": 1
+ },
+ "15": {
+ "source": " return 0;",
+ "coverage": 1
+ },
+ "16": {
+ "source": "}",
+ "coverage": ""
+ },
+ "17": {
+ "source": "",
+ "coverage": ""
+ },
+ "18": {
+ "source": "function covTest3(p1) {",
+ "coverage": 1
+ },
+ "19": {
+ "source": " for(i=0;i < p1;i++){",
+ "coverage": 0
+ },
+ "20": {
+ "source": " }",
+ "coverage": ""
+ },
+ "21": {
+ "source": " return i;",
+ "coverage": 0
+ },
+ "22": {
+ "source": "}",
+ "coverage": ""
+ },
+ "23": {
+ "source": "function covTest4(p1) {",
+ "coverage": 1
+ },
+ "24": {
+ "source": " i=0;",
+ "coverage": 0
+ },
+ "25": {
+ "source": " while(i < p1){",
+ "coverage": 0
+ },
+ "26": {
+ "source": " i++;",
+ "coverage": 0
+ },
+ "27": {
+ "source": " }",
+ "coverage": ""
+ },
+ "28": {
+ "source": " return i;",
+ "coverage": 0
+ },
+ "29": {
+ "source": "}",
+ "coverage": ""
+ },
+ "30": {
+ "source": "",
+ "coverage": ""
+ },
+ "31": {
+ "source": "describe('Array', function(){",
+ "coverage": 1
+ },
+ "32": {
+ "source": " describe('CovTest2', function(){",
+ "coverage": 1
+ },
+ "33": {
+ "source": " it('should return when the value is not present', function(){",
+ "coverage": 1
+ },
+ "34": {
+ "source": " assert.equal(0,covTest2(2,2));",
+ "coverage": 1
+ },
+ "35": {
+ "source": " })",
+ "coverage": ""
+ },
+ "36": {
+ "source": " })",
+ "coverage": ""
+ },
+ "37": {
+ "source": "})",
+ "coverage": ""
+ },
+ "38": {
+ "source": "",
+ "coverage": ""
+ }
+ }
+ }
+ ],
+ "stats": {
+ "suites": 5,
+ "tests": 4,
+ "passes": 4,
+ "pending": 0,
+ "failures": 0,
+ "start": "2014-10-23T17:56:02.339Z",
+ "end": "2014-10-23T17:56:02.344Z",
+ "duration": 5
+ },
+ "tests": [
+ {
+ "title": "should return when the value is not present",
+ "fullTitle": "Array CovTest should return when the value is not present",
+ "duration": 0
+ },
+ {
+ "title": "should return when the value is not present",
+ "fullTitle": "Array CovTest>3 should return when the value is not present",
+ "duration": 0
+ },
+ {
+ "title": "should return when the value is not present",
+ "fullTitle": "Array covTest4 should return when the value is not present",
+ "duration": 0
+ },
+ {
+ "title": "should return when the value is not present",
+ "fullTitle": "Array covTest3 should return when the value is not present",
+ "duration": 0
+ }
+ ],
+ "failures": [],
+ "passes": [
+ {
+ "title": "should return when the value is not present",
+ "fullTitle": "Array CovTest should return when the value is not present",
+ "duration": 0
+ },
+ {
+ "title": "should return when the value is not present",
+ "fullTitle": "Array CovTest>3 should return when the value is not present",
+ "duration": 0
+ },
+ {
+ "title": "should return when the value is not present",
+ "fullTitle": "Array covTest4 should return when the value is not present",
+ "duration": 0
+ },
+ {
+ "title": "should return when the value is not present",
+ "fullTitle": "Array covTest3 should return when the value is not present",
+ "duration": 0
+ }
+ ]
+} \ No newline at end of file
diff --git a/Tests/JavascriptCoverage/test.js b/Tests/JavascriptCoverage/test.js
new file mode 100644
index 0000000..273e921c
--- /dev/null
+++ b/Tests/JavascriptCoverage/test.js
@@ -0,0 +1,53 @@
+var assert = require("assert")
+var test = {
+ version: "1.0.0"
+}
+function covTest(p1,p2) {
+ if (p1 > 3) {
+ return 1;
+ }
+ else {
+ return p1 + p2;
+ }
+}
+
+function covTest2(p1,p2) {
+ return 0;
+}
+
+function covTest3(p1) {
+ for(i=0;i < p1;i++){
+ }
+ return i;
+}
+function covTest4(p1) {
+ i=0;
+ while(i < p1){
+ i++;
+ }
+ return i;
+}
+
+describe('Array', function(){
+ describe('CovTest', function(){
+ it('should return when the value is not present', function(){
+ assert.equal(4,covTest(2,2));
+ })
+ })
+
+ describe('CovTest>3', function(){
+ it('should return when the value is not present', function(){
+ assert.equal(1,covTest(4,2));
+ })
+ })
+ describe('covTest4', function(){
+ it('should return when the value is not present', function(){
+ assert.equal(5,covTest4(5));
+ })
+ })
+ describe('covTest3', function(){
+ it('should return when the value is not present', function(){
+ assert.equal(5,covTest3(5));
+ })
+ })
+})
diff --git a/Tests/JavascriptCoverage/test3.js b/Tests/JavascriptCoverage/test3.js
new file mode 100644
index 0000000..a1e31bc
--- /dev/null
+++ b/Tests/JavascriptCoverage/test3.js
@@ -0,0 +1,37 @@
+var assert = require("assert")
+var test = {
+ version: "1.0.0"
+}
+function covTest(p1,p2) {
+ if (p1 > 3) {
+ return 1;
+ }
+ else {
+ return p1 + p2;
+ }
+}
+
+function covTest2(p1,p2) {
+ return 0;
+}
+
+function covTest3(p1) {
+ for(i=0;i < p1;i++){
+ }
+ return i;
+}
+function covTest4(p1) {
+ i=0;
+ while(i < p1){
+ i++;
+ }
+ return i;
+}
+
+describe('Array', function(){
+ describe('CovTest2', function(){
+ it('should return when the value is not present', function(){
+ assert.equal(0,covTest2(2,2));
+ })
+ })
+})