Created
August 5, 2012 22:40
-
-
Save alex/3267593 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import os | |
from fabric.api import task, local | |
class Test(object): | |
def __init__(self, func, deps=[], needs_pypy=True): | |
self.func = func | |
self.deps = deps | |
self.needs_pypy = needs_pypy | |
def install_deps(self): | |
local("pip install {}".format(" ".join(self.deps))) | |
def download_pypy(self): | |
local("wget https://bitbucket.org/pypy/pypy/get/default.tar.bz2 -O `pwd`/../pypy.tar.bz2") | |
local("bunzip2 `pwd`/../pypy.tar.bz2") | |
local("tar -xf `pwd`/../pypy.tar -C `pwd`/../") | |
[path_name] = glob.glob("../pypy-pypy*") | |
path_name = os.path.abspath(path_name) | |
with open("pypy_marker", "w") as f: | |
f.write(path_name) | |
def run_tests(self): | |
env = {} | |
if self.needs_pypy: | |
with open("pypy_marker") as f: | |
env["pypy_path"] = f.read() | |
self.func(env) | |
@task | |
def install_requirements(): | |
t = TEST_TYPES[os.environ["TEST_TYPE"]] | |
if t.deps: | |
t.install_deps() | |
if t.needs_pypy: | |
t.download_pypy() | |
@task | |
def run_tests(): | |
t = TEST_TYPES[os.environ["TEST_TYPE"]] | |
t.run_tests() | |
def run_own_tests(env): | |
local("PYTHONPATH=%(pypy_path)s:$PYTHONPATH py.test" % env) | |
def run_translate_tests(env): | |
local("PYTHONPATH=%(pypy_path)s:$PYTHONPATH %(pypy_path)s/pypy/translator/goal/translate.py --batch -Ojit targetrupypy.py" % env) | |
def run_docs_tests(env): | |
local("sphinx-build -W -b html docs/ docs/_build/") | |
TEST_TYPES = { | |
"own": Test(run_own_tests, deps=["pytest"]), | |
"translate": Test(run_translate_tests), | |
"docs": Test(run_docs_tests, deps=["sphinx"], needs_pypy=False), | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment