scriptCommon.py 830 B

12345678910111213141516171819202122232425262728293031
  1. import os
  2. import sys
  3. import subprocess
  4. catchPath = os.path.dirname(os.path.realpath( os.path.dirname(sys.argv[0])))
  5. def getBuildExecutable():
  6. if os.name == 'nt':
  7. dir = os.environ.get('CATCH_DEV_OUT_DIR', "cmake-build-debug/projects/SelfTest.exe")
  8. return dir
  9. else:
  10. dir = os.environ.get('CATCH_DEV_OUT_DIR', "cmake-build-debug/projects/SelfTest")
  11. return dir
  12. def runAndCapture( args ):
  13. child = subprocess.Popen(" ".join( args ), shell=True, stdout=subprocess.PIPE)
  14. lines = []
  15. line = ""
  16. while True:
  17. out = child.stdout.read(1)
  18. if out == '' and child.poll():
  19. break
  20. if out != '':
  21. if out == '\n':
  22. lines.append( line )
  23. line = ""
  24. else:
  25. line = line + out
  26. return lines