示例#1
0
def main(argv):
  parser = argparse.ArgumentParser(
    prog="testjs",
    description=sys.modules['__main__'].__doc__,
    formatter_class=argparse.RawTextHelpFormatter)

  testjs.add_argparse_options(parser)
  infra_libs.logs.add_argparse_options(parser)
  args = parser.parse_args(argv)
  infra_libs.logs.process_argparse_options(args)

  # Do more processing here
  LOGGER.info('Testjs starting.')

  LOGGER.info('Fetching Chrome...')
  cache_dir = os.path.expanduser('~/.cached_browsers')
  chrome, _ = fetch_browser.run('chrome', cache_dir, sys.platform, 'stable')

  if sys.platform == 'linux2':
    with testjs.get_display() as display:
      for target in args.target:
        LOGGER.info('Running karma for %s', target)
        testjs.test_karma(target, chrome, display)
  else:
    for target in args.target:
      LOGGER.info('Running karma for %s', target)
      testjs.test_karma(target, chrome, None)
示例#2
0
 def test_get_display(self, choice, exists, popen):
   choice.return_value = 102
   exists.side_effect = [False, True]
   fake_popen = mock.MagicMock()
   fake_popen.poll.return_value = None
   fake_popen.pid = 1234
   popen.return_value = fake_popen
   with utils.temporary_directory() as tempdir:
     tempfile = os.path.join(tempdir, 'pidfile')
     real_tempfile = '%s102' % tempfile
     with open(real_tempfile, 'w') as f:
       f.write('1234')
     testjs.LOCK_LOCATION = '%s%%d' % tempfile
     with testjs.get_display() as display:
       self.assertEquals(display, ':102')