olemis

Untitled

Feb 24th, 2010
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1.  
  2. @@ import os, sys
  3. @@ from string import Template
  4. @@ from subprocess import call
  5.  
  6. TEST_SCRIPT = r"""
  7.  
  8. from unittest import TestCase, main as m
  9. from xmlrunner import XMLTestRunner
  10.  
  11. class DummyTest(TestCase):
  12.  def test_fail(self):
  13.    self.fail('Failed test case')
  14.  def test_error(self):
  15.    a = 1/0
  16.  def test_success(self):
  17.    self.assertEquals(1, 1)
  18.  
  19. def main():
  20.  m(testRunner=XMLTestRunner(output='$BUILD_REPORT/xunit'))
  21.  
  22. if __name__ == '__main__' :
  23.  main()
  24. """
  25.  
  26. def echo_script(text, of):
  27.   r"""Output a sequence of `echo`s to create a text file
  28.  """
  29.   return 'echo " " > %s\n' % (of,) + \
  30.               '\n'.join('echo "%s" >> %s' % (l, of) for l in text.splitlines() )
  31.  
  32. BUILD_SCRIPT = r"""
  33.  
  34. virtualenv $VENV_ROOT/$BUILD_NUMBER
  35. %s
  36. $VENV_ROOT/$BUILD_NUMBER/$VENV_EASYINSTALL unittest-xml-reporting
  37. $VENV_ROOT/$BUILD_NUMBER/$VENV_PYTHON '$VENV_ROOT/$BUILD_NUMBER/testxml.py'
  38. """ % echo_script(TEST_SCRIPT, '$VENV_ROOT/$BUILD_NUMBER/testxml.py')
  39.  
  40. @@ if sys.platform == 'win32':
  41. @@   bin = 'Scripts'
  42. @@ else :
  43. @@   bin = 'bin'
  44. @@
  45. @@ os.environ.update({
  46. @@       'VENV_ROOT' : 'buildenv',
  47. @@       'VENV_PYTHON' : '%s/python' % bin ,
  48. @@       'VENV_EASYINSTALL' : '%s/easy_install' % bin ,
  49. @@       'BUILD_REPORT' : 'rpt',
  50. @@     })
  51. @@
  52. @@ def _(fmtstr):
  53. @@   return Template(fmtstr).safe_substitute(os.environ)
  54. @@
  55. @@ for cmd in _(BUILD_SCRIPT).strip().splitlines():
  56. @@   call(cmd, shell=True)
  57.  
Add Comment
Please, Sign In to add comment