[recipes] add apycot.python.full recipe draft
authorDavid Douard <david.douard@logilab.fr>
Thu, 20 Nov 2014 20:03:21 +0100
changeset 1777 46fc18db6cc5
parent 1776 f1a23fc56270
child 1778 884c710a25fc
[recipes] add apycot.python.full recipe apycot.python.quick + pycoverage
recipes/apycot.python.full.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/recipes/apycot.python.full.py	Thu Nov 20 20:03:21 2014 +0100
@@ -0,0 +1,37 @@
+# an apycot recipe that run unit tests for python projects
+import os
+from os.path import join
+import sys
+
+from checkers.apycot import python # trigger registration
+from apycotlib import narvalactions as na, ERROR
+# `plan` (narvalbot.engine.Plan) exists in the globals
+
+with na.apycot_environment(plan) as test:
+    # for each source of the source configuration, we need the URL of
+    # the source repo, the changeset to use, the recipes to use to
+    # make the checkout then the install, and the eid of the
+    # Repository
+    for cset, url, repoeid, checkout, setup in test.src_configuration():
+        # we clone each repo in a dedicated directory (ensure there is
+        # no collision)
+        src = join(test.tmpdir, 'src', str(repoeid))
+        # then execute the checkout (clone + up to cset)
+        test.exec_recipe(checkout, rev=cset,
+                         dst_dir=src,
+                         source_url=url)
+        # now perform the setup process (build and install)
+        test.exec_recipe(setup,
+                         test=test,
+                         prefix=test.tmpdir,
+                         wdir=src)
+    # we can now run the checkers
+    repoeid = test.penvironment['repository']['eid']
+    test.set_project_path(join(test.tmpdir, 'src', str(repoeid)))
+
+    checker, status = test.run_checker('pylint')
+    checker, status = test.run_checker('pyunit')
+    if status > ERROR and checker.coverage_data:
+        checker, status = test.run_checker('pycoverage',
+                                           coverage_data=checker.coverage_data)
+