Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @@ import os, sys
- @@ from string import Template
- @@ from subprocess import call
- TEST_SCRIPT = r"""
- from unittest import TestCase, main as m
- from xmlrunner import XMLTestRunner
- class DummyTest(TestCase):
- def test_fail(self):
- self.fail('Failed test case')
- def test_error(self):
- a = 1/0
- def test_success(self):
- self.assertEquals(1, 1)
- def main():
- m(testRunner=XMLTestRunner(output='$BUILD_REPORT/xunit'))
- if __name__ == '__main__' :
- main()
- """
- def echo_script(text, of):
- r"""Output a sequence of `echo`s to create a text file
- """
- return 'echo " " > %s\n' % (of,) + \
- '\n'.join('echo "%s" >> %s' % (l, of) for l in text.splitlines() )
- BUILD_SCRIPT = r"""
- virtualenv $VENV_ROOT/$BUILD_NUMBER
- %s
- $VENV_ROOT/$BUILD_NUMBER/$VENV_EASYINSTALL unittest-xml-reporting
- $VENV_ROOT/$BUILD_NUMBER/$VENV_PYTHON '$VENV_ROOT/$BUILD_NUMBER/testxml.py'
- """ % echo_script(TEST_SCRIPT, '$VENV_ROOT/$BUILD_NUMBER/testxml.py')
- @@ if sys.platform == 'win32':
- @@ bin = 'Scripts'
- @@ else :
- @@ bin = 'bin'
- @@
- @@ os.environ.update({
- @@ 'VENV_ROOT' : 'buildenv',
- @@ 'VENV_PYTHON' : '%s/python' % bin ,
- @@ 'VENV_EASYINSTALL' : '%s/easy_install' % bin ,
- @@ 'BUILD_REPORT' : 'rpt',
- @@ })
- @@
- @@ def _(fmtstr):
- @@ return Template(fmtstr).safe_substitute(os.environ)
- @@
- @@ for cmd in _(BUILD_SCRIPT).strip().splitlines():
- @@ call(cmd, shell=True)
Add Comment
Please, Sign In to add comment