[tor-commits] [bridgedb/master] Add coverage and coveralls support to the test runner.

isis at torproject.org isis at torproject.org
Sun Jan 12 06:06:32 UTC 2014


commit 0f76862f3f5dd5d38f1cbbfb1fd8749da31f440d
Author: Isis Lovecruft <isis at torproject.org>
Date:   Tue Nov 19 03:17:34 2013 +0000

    Add coverage and coveralls support to the test runner.
    
     * FIXES the coverage part of #9865.
---
 .coveragerc      |   33 +++++++++++++++++++++++++++++++++
 .gitignore       |    4 ++++
 .travis.yml      |   21 +++++++++++++--------
 Makefile         |    3 +++
 README           |    2 +-
 requirements.txt |    3 ---
 setup.py         |    2 +-
 7 files changed, 55 insertions(+), 13 deletions(-)

diff --git a/.coveragerc b/.coveragerc
new file mode 100644
index 0000000..f8d4732
--- /dev/null
+++ b/.coveragerc
@@ -0,0 +1,33 @@
+[run]
+source = 
+     bridgedb
+     lib/bridgedb/test/test_*
+branch = True
+#parallel = True
+timid = True
+
+[report]
+modules = bridgedb
+omit = 
+     */test*
+     */_langs*
+     */_version*
+# Regexes for lines to exclude from report generation:
+exclude_lines = 
+     pragma: no cover
+     # don't complain if the code doesn't hit unimplemented sections:
+     raise NotImplementedError
+     # don't complain if non-runnable or debuging code isn't run:
+     if 0:
+     if False:
+     if self[.verbosity.]
+     if options[.verbosity.]
+     def __repr__
+     if __name__ == .__main__.:
+# Ignore source code which cannot be found:
+ignore_errors = True
+# Exit with status code 2 if under this percentage is covered:
+fail_under = 10
+
+[html]
+directory = doc/coverage-html
diff --git a/.gitignore b/.gitignore
index 47e47b1..e1a25c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -89,3 +89,7 @@ gnupghome/*
 
 # ignore persistent state files
 *bridgedb.state*
+
+# ignore coverage results files:
+.coverage
+.coverage.*
diff --git a/.travis.yml b/.travis.yml
index 6dcbfd9..7a47b36 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,7 +15,10 @@ notifications:
 
 before_install:
   - sudo apt-get update
-  - sudo apt-get install --no-install-suggests --no-install-recommends tor-geoipdb build-essential python-dev python-setuptools openssl sqlite3 libgpgme11-dev
+  # Distro development header/library/resource/buildtime dependencies
+  - sudo apt-get install --no-install-suggests --no-install-recommends tor-geoipdb build-essential openssl sqlite3 libgpgme11-dev
+  # Distro python dependencies
+  - sudo apt-get install --no-install-suggests --no-install-recommends python-dev python-setuptools
 
 python:
   - "2.6"
@@ -26,6 +29,7 @@ python:
 
 install:
   - pip install -r requirements.txt --use-mirrors
+  - pip install coverage coveralls sure --use-mirrors
   - make install
 
 #before_script:
@@ -34,12 +38,13 @@ install:
 
 # command to run tests, e.g. python setup.py test
 script:
-  - chmod u+x scripts/make-ssl-cert
-  - chmod u+x scripts/executioner
-  - ./scripts/make-ssl-cert
   - bridgedb mock -n 250
-  - bridgedb test
-  - ./scripts/executioner 180 bridgedb -c bridgedb.conf
-  # add this when #9199's (or some other trial-based) tests are merged:
-  #- bridgedb test
+  # Normally, we would do 'bridgedb test' here, but to run with coverage we
+  # have to do this instead:
+  - coverage run $(which trial) ./lib/bridgedb/test/test_*
+  - coverage report
+  - coverage html
   - echo "Build successful."
+
+after_success:
+  - coveralls
diff --git a/Makefile b/Makefile
index 4c49a9b..036997e 100644
--- a/Makefile
+++ b/Makefile
@@ -39,3 +39,6 @@ clean:
 	-rm -rf dist
 	-rm -rf lib/bridgedb.egg-info
 	-rm -rf _trial_temp
+
+coverage:
+	-coverage run $(which trial) ./lib/bridgedb/test/test_* && coverage report && coverage html
diff --git a/README b/README
index cdacdb2..3175957 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-## BridgeDB
+## BridgeDB [![Coverage Status](https://coveralls.io/repos/isislovecruft/bridgedb/badge.png)](https://coveralls.io/r/isislovecruft/bridgedb)
 -----------
 
 BridgeDB is a collection of backend servers used to distribute
diff --git a/requirements.txt b/requirements.txt
index eeab36f..3935c59 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,13 +3,10 @@ BeautifulSoup==3.2.1
 Mako==0.8.1
 MarkupSafe==0.18
 Twisted==13.1.0
-coverage==3.6
 https://ipaddr-py.googlecode.com/files/ipaddr-2.1.10.tar.gz#sha1=c608450b077b19773d4f1b5f1ef88b26f6650ce0#egg=ipaddr-2.1.10-py2.7
 pyOpenSSL==0.13.1
 pygeoip==0.2.7
 pygpgme==0.3
 recaptcha==1.0rc1
 recaptcha-client==1.0.6
-sure==1.2.2
-trialcoverage==0.3.12
 zope.interface>=4.0.5
diff --git a/setup.py b/setup.py
index d07e51a..4359fed 100644
--- a/setup.py
+++ b/setup.py
@@ -281,7 +281,7 @@ setuptools.setup(
     scripts=['scripts/bridgedb',
              'scripts/gen_bridge_descriptors'],
     extras_require={'test': ["sure==0.4.5",
-                             "trialcoverage==0.3.12"]},
+                             "coverage==3.6"]},
     zip_safe=False,
     cmdclass=get_cmdclass(),
     include_package_data=True,





More information about the tor-commits mailing list