Adding Coverage Commands to service/go
authorTiago Ferraz <tiago.ferraz@gmail.com>
Thu, 12 Feb 2015 13:44:04 +0000 (11:44 -0200)
committerTiago Ferraz <tiago.ferraz@gmail.com>
Thu, 12 Feb 2015 13:48:34 +0000 (11:48 -0200)
Added unit and integration coverage generation command and a combination of both coverage in go script.

service/.coveragerc [new file with mode: 0644]
service/.gitignore
service/go
service/test_requirements.txt

diff --git a/service/.coveragerc b/service/.coveragerc
new file mode 100644 (file)
index 0000000..6f97047
--- /dev/null
@@ -0,0 +1,7 @@
+[run]
+branch = True
+source = pixelated
+omit = test/*
+
+[report]
+ingore-errors = True
index 2a85c8d..f1cd03b 100644 (file)
@@ -1,4 +1,7 @@
 .virtualenv/
+.venv/
 soledad-test/
 build/
 test/perf/**/results
+.coverage
+htmlcov/
index 308e4f0..ac953bd 100755 (executable)
@@ -1,6 +1,11 @@
 #!/bin/bash
 
 NUM_OF_CORES=''
+TRIAL_PATH=''
+
+function getTrialAbsolutePath {
+    TRIAL_PATH="$(which trial)"
+}
 
 function resolveNumOfCores {
         if [ "$(uname)" ==  "Darwin" ]; then
@@ -56,6 +61,37 @@ function runJSHint {
         echo "Done."
 }
 
+function runCoverageUnit {
+        echo "Generating Unit Test Converage Information."
+        coverage erase
+        getTrialAbsolutePath
+        coverage run -p --source=pixelated $TRIAL_PATH --reporter=text $* test.unit
+        coverage combine
+        coverage html
+        echo "Done."
+}
+
+function runCoverageIntegration {
+        echo "Generating Integration Test Converage Information."
+        coverage erase
+        getTrialAbsolutePath
+        coverage run -p --source=pixelated $TRIAL_PATH --reporter=text $* test.integration
+        coverage combine
+        coverage html
+        echo "Done."
+}
+
+function runCoverageUnitAndIntegration {
+        echo "Generating Unit and Integration Test Converage Information."
+        coverage erase
+        getTrialAbsolutePath
+        coverage run -p --source=pixelated $TRIAL_PATH --reporter=text test.unit
+        coverage run -p --source=pixelated $TRIAL_PATH --reporter=text test.integration
+        coverage combine
+        coverage html
+        echo "Done."
+}
+
 if [ "$1" == 'test' ]; then
         runJSHint
         runPep8
@@ -74,6 +110,12 @@ elif [ "$1" == 'setupjs' ]; then
 elif [ "$1" == 'setup' ]; then
         setupjs
         setuppy "${@:2}"
+elif [ "$1" == 'coverage_unit' ]; then
+        runCoverageUnit "${@:2}"
+elif [ "$1" == 'coverage_integration' ]; then
+        runCoverageIntegration "${@:2}"
+elif [ "$1" == 'coverage_all' ]; then
+        runCoverageUnitAndIntegration "${@:2}"
 elif [ "$1" == 'start' ]; then
         /usr/bin/env pixelated-user-agent "${@:2}"
 else
index 98d8665..5179330 100644 (file)
@@ -8,4 +8,5 @@ funkload==1.16.1
 tornado==4.0.2
 pep8==1.5.7
 tempdir==0.6
+coverage