reviewboard: script for creating test environment; rbmozui
authorGregory Szorc <gps@mozilla.com>
Mon, 30 Jun 2014 18:42:45 -0700
changeset 358878 2b4ece5493e8200d80095d51af2d0363534d4d7a
parent 358877 f88b52b8b264a6f802fa22989a9a1a68ae6952ed
child 358879 07201fc18a88afd7148d2e5220c9fa46473e122f
push id16998
push userrwood@mozilla.com
push dateMon, 02 May 2016 19:42:03 +0000
reviewboard: script for creating test environment; rbmozui Creating test environments was scriptable, so make a script to do it. The impetus for this was installing the rbmozui ReviewBoard extension, which required `setup.py develop` mode to not introduce a Node.js dependency.
README.rst
create-test-environment
hgext/reviewboard/tests/rbmanage.py
--- a/README.rst
+++ b/README.rst
@@ -43,18 +43,17 @@ number of features:
 If you are looking to turn Mercurial into a more powerful query tool or
 want to maintain a unified repository, *mozext* is very valuable.
 
 This extension lives under ``hgext/mozext``.
 
 Testing
 =======
 
-Testing requires a Python virtualenv because some extensions launch
-actual servers instead of mocking. To create the virtualenv::
+Testing requires a special Python environment. To create this
+environment:
 
-  $ virtualenv env
-  $ source env/bin/activate
-  $ pip install -r test-requirements.txt
-  $ easy_install ReviewBoard==2.0.2
+  $ ./create-test-environment
+  $ source venv/bin/activate
 
-(Yes, we need to use ``easy_install`` because ReviewBoard doesn't play
-nice with pip.)
+Then, launch the tests:
+
+  $ ./run-mercurial-tests.py
new file mode 100755
--- /dev/null
+++ b/create-test-environment
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+set -e
+
+if [ ! -d venv ]; then
+  virtualenv venv
+fi
+
+source venv/bin/activate
+pip install --upgrade -r test-requirements.txt
+
+# ReviewBoard doesn't work with pip, sadly.
+easy_install ReviewBoard==2.0.2
+
+# rbmozui requires Node.js when installed normally. But in local
+# development mode it doesn't. So use local development node.
+mkdir -p venv/tmp
+if [ -d venv/tmp/rbmozui ]; then
+  cd venv/tmp/rbmzui && git pull
+else
+  git clone git@github.com:mikeconley/rbmozui.git venv/tmp/rbmozui
+fi
+
+cd venv/tmp/rbmozui && python setup.py develop
--- a/hgext/reviewboard/tests/rbmanage.py
+++ b/hgext/reviewboard/tests/rbmanage.py
@@ -73,16 +73,20 @@ def main(args):
         f = open(os.devnull, 'w')
         subprocess.check_call(manage + ['syncdb', '--noinput'], cwd=path,
                 env=env, stdout=f, stderr=f)
 
         subprocess.check_call(manage + ['enable-extension',
             'rbbz.extension.BugzillaExtension'], cwd=path,
             env=env, stdout=f, stderr=f)
 
+        subprocess.check_call(manage + ['enable-extension',
+            'rbmozui.extension.RBMozUI'],
+            cwd=path, env=env, stdout=f, stderr=f)
+
         subprocess.check_call(manage + ['createsuperuser', '--username',
             'testadmin', '--email', 'testadmin@example.com', '--noinput'], cwd=path,
             env=env, stderr=f, stdout=f)
 
         from django.contrib.auth.models import User
         u = User.objects.get(username__exact='testadmin')
         u.set_password('password')
         u.save()