コード例 #1
0
def run_tests_single(args):
    """Runs all the karma tests."""
    karma_path = shakaBuildHelpers.get_node_binary_path('karma')
    cmd = [karma_path, 'start']

    if shakaBuildHelpers.is_linux() and '--use-xvfb' in args:
        cmd = ['xvfb-run', '--auto-servernum'] + cmd

    # Get the browsers supported on the local system.
    browsers = _get_browsers()
    if not browsers:
        print >> sys.stderr, 'Unrecognized system "%s"' % platform.uname()[0]
        return 1

    print 'Starting tests...'
    if not args:
        # Run tests in all available browsers.
        print 'Running with platform default:', '--browsers', browsers
        cmd_line = cmd + ['--browsers', browsers]
        return shakaBuildHelpers.execute_get_code(cmd_line)
    else:
        # Run with command-line arguments from the user.
        if '--browsers' not in args:
            print 'No --browsers specified.'
            print 'In this mode, browsers must be manually connected to karma.'
        cmd_line = cmd + args
        return shakaBuildHelpers.execute_get_code(cmd_line)
コード例 #2
0
ファイル: test.py プロジェクト: Ross-cz/shaka-player
def run_tests_single(args):
  """Runs all the karma tests."""
  karma_path = shakaBuildHelpers.get_node_binary_path('karma')
  cmd = [karma_path, 'start']

  if shakaBuildHelpers.is_linux() and '--use-xvfb' in args:
    cmd = ['xvfb-run', '--auto-servernum'] + cmd

  # Get the browsers supported on the local system.
  browsers = _get_browsers()
  if not browsers:
    print >> sys.stderr, 'Unrecognized system "%s"' % platform.uname()[0]
    return 1

  print 'Starting tests...'
  if not args:
    # Run tests in all available browsers.
    print 'Running with platform default:', '--browsers', browsers
    cmd_line = cmd + ['--browsers', browsers]
    return shakaBuildHelpers.execute_get_code(cmd_line)
  else:
    # Run with command-line arguments from the user.
    if '--browsers' not in args:
      print 'No --browsers specified.'
      print 'In this mode, browsers must be manually connected to karma.'
    cmd_line = cmd + args
    return shakaBuildHelpers.execute_get_code(cmd_line)
コード例 #3
0
def check_js_lint():
    """Runs the JavaScript linter."""
    # TODO: things not enforced: property doc requirements
    logging.info('Running eslint...')

    eslint_path = shakaBuildHelpers.get_node_binary_path('eslint')
    args = []
    cmd_line = [eslint_path] + args + get_lint_files()
    return shakaBuildHelpers.execute_get_code(cmd_line) == 0
コード例 #4
0
    def RunCommand(self, karma_conf):
        """Build a command and send it to Karma for execution.

       Uses |self.parsed_args| and |self.karma_config| to build and run a Karma
       command.
    """
        karma = shakaBuildHelpers.get_node_binary_path('karma')
        cmd = ['xvfb-run', '--auto-servernum'
               ] if self.parsed_args.use_xvfb else []
        cmd += [karma, 'start']
        cmd += [karma_conf] if karma_conf else []
        cmd += ['--settings', json.dumps(self.karma_config)]

        if self.parsed_args.use_xvfb and not shakaBuildHelpers.is_linux():
            logging.error('xvfb can only be used on Linux')
            return 1

        if not shakaBuildHelpers.update_node_modules():
            logging.error('Failed to update node modules')
            return 1

        # There is no need to print a status here as the gendep and build
        # calls will print their own status updates.
        if self.parsed_args.build:
            if gendeps.gen_deps([]) != 0:
                logging.error('Failed to generate project dependencies')
                return 1

            if build.main(['--force'] if self.parsed_args.force else []) != 0:
                logging.error('Failed to build project')
                return 1

        # Before Running the command, print the command.
        if self.parsed_args.print_command:
            logging.info('Karma Run Command')
            logging.info('%s', cmd)

        # Run the command.
        results = []
        for run in range(self.parsed_args.runs):
            logging.info('Running test (%d / %d)...', run + 1,
                         self.parsed_args.runs)
            results.append(shakaBuildHelpers.execute_get_code(cmd))

        # Print a summary of the results.
        if self.parsed_args.runs > 1:
            logging.info('All runs completed. %d / %d runs passed.',
                         results.count(0), len(results))
            logging.info('Results (exit code): %r', results)
        else:
            logging.info('Run complete')
            logging.info('Result (exit code): %d', results[0])

        return 0 if all(result == 0 for result in results) else 1
コード例 #5
0
ファイル: test.py プロジェクト: baconz/shaka-player
def run_tests(args):
    """Runs all the karma tests."""
    # Update node modules if needed.
    if not shakaBuildHelpers.update_node_modules():
        return 1

    # Generate dependencies and compile library.
    # This is required for the tests.
    if gendeps.gen_deps([]) != 0:
        return 1

    build_args = []
    if "--force" in args:
        build_args.append("--force")
        args.remove("--force")

    if "--no-build" in args:
        args.remove("--no-build")
    else:
        if build.main(build_args) != 0:
            return 1

    karma_command_name = "karma"
    if shakaBuildHelpers.is_windows():
        # Windows karma program has a different name
        karma_command_name = "karma.cmd"

    karma_path = shakaBuildHelpers.get_node_binary_path(karma_command_name)
    cmd = [karma_path, "start"]

    # Get the browsers supported on the local system.
    browsers = _get_browsers()
    if not browsers:
        print >> sys.stderr, 'Unrecognized system "%s"' % platform.uname()[0]
        return 1

    print "Starting tests..."
    if not args:
        # Run tests in all available browsers.
        print "Running with platform default:", "--browsers", browsers
        cmd_line = cmd + ["--browsers", browsers]
        shakaBuildHelpers.print_cmd_line(cmd_line)
        return subprocess.call(cmd_line)
    else:
        # Run with command-line arguments from the user.
        if "--browsers" not in args:
            print "No --browsers specified."
            print "In this mode, browsers must be manually connected to karma."
        cmd_line = cmd + args
        shakaBuildHelpers.print_cmd_line(cmd_line)
        return subprocess.call(cmd_line)
コード例 #6
0
ファイル: test.py プロジェクト: runt18/shaka-player
def run_tests(args):
    """Runs all the karma tests."""
    # Update node modules if needed.
    if not shakaBuildHelpers.update_node_modules():
        return 1

    # Generate dependencies and compile library.
    # This is required for the tests.
    if gendeps.gen_deps([]) != 0:
        return 1

    build_args = []
    if '--force' in args:
        build_args.append('--force')
        args.remove('--force')

    if '--no-build' in args:
        args.remove('--no-build')
    else:
        if build.main(build_args) != 0:
            return 1

    karma_command_name = 'karma'
    if shakaBuildHelpers.is_windows():
        # Windows karma program has a different name
        karma_command_name = 'karma.cmd'

    karma_path = shakaBuildHelpers.get_node_binary_path(karma_command_name)
    cmd = [karma_path, 'start']

    # Get the browsers supported on the local system.
    browsers = _get_browsers()
    if not browsers:
        print >> sys.stderr, 'Unrecognized system "%s"' % platform.uname()[0]
        return 1

    print 'Starting tests...'
    if not args:
        # Run tests in all available browsers.
        print 'Running with platform default:', '--browsers', browsers
        cmd_line = cmd + ['--browsers', browsers]
        shakaBuildHelpers.print_cmd_line(cmd_line)
        return subprocess.call(cmd_line)
    else:
        # Run with command-line arguments from the user.
        if '--browsers' not in args:
            print 'No --browsers specified.'
            print 'In this mode, browsers must be manually connected to karma.'
        cmd_line = cmd + args
        shakaBuildHelpers.print_cmd_line(cmd_line)
        return subprocess.call(cmd_line)
コード例 #7
0
def check_html_lint():
    """Runs the HTML linter over the HTML files.

  Returns:
    True on success, False on failure.
  """
    logging.info('Running htmlhint...')
    htmlhint_path = shakaBuildHelpers.get_node_binary_path('htmlhint')
    base = shakaBuildHelpers.get_source_base()
    files = ['index.html', 'demo/index.html', 'support.html']
    file_paths = [os.path.join(base, x) for x in files]
    config_path = os.path.join(base, '.htmlhintrc')
    cmd_line = [htmlhint_path, '--config=' + config_path] + file_paths
    return shakaBuildHelpers.execute_get_code(cmd_line) == 0
コード例 #8
0
def run_tests_single(args):
    """Runs all the karma tests."""
    # Update node modules if needed.
    if not shakaBuildHelpers.update_node_modules():
        return 1

    # Generate dependencies and compile library.
    # This is required for the tests.
    if gendeps.gen_deps([]) != 0:
        return 1

    build_args = []
    if '--force' in args:
        build_args.append('--force')
        args.remove('--force')

    if '--no-build' in args:
        args.remove('--no-build')
    else:
        if build.main(build_args) != 0:
            return 1

    karma_path = shakaBuildHelpers.get_node_binary_path('karma')
    cmd = [karma_path, 'start']

    if shakaBuildHelpers.is_linux() and '--use-xvfb' in args:
        cmd = ['xvfb-run', '--auto-servernum'] + cmd

    # Get the browsers supported on the local system.
    browsers = _get_browsers()
    if not browsers:
        print >> sys.stderr, 'Unrecognized system "%s"' % platform.uname()[0]
        return 1

    print 'Starting tests...'
    if not args:
        # Run tests in all available browsers.
        print 'Running with platform default:', '--browsers', browsers
        cmd_line = cmd + ['--browsers', browsers]
        return shakaBuildHelpers.execute_get_code(cmd_line)
    else:
        # Run with command-line arguments from the user.
        if '--browsers' not in args:
            print 'No --browsers specified.'
            print 'In this mode, browsers must be manually connected to karma.'
        cmd_line = cmd + args
        return shakaBuildHelpers.execute_get_code(cmd_line)
コード例 #9
0
ファイル: test.py プロジェクト: CCC-EE/shaka-player
def run_tests(args):
  """Runs all the karma tests."""
  # Update node modules if needed.
  if not shakaBuildHelpers.update_node_modules():
    return 1

  # Generate dependencies and compile library.
  # This is required for the tests.
  if gendeps.gen_deps([]) != 0:
    return 1

  build_args = []
  if '--force' in args:
    build_args.append('--force')
    args.remove('--force')

  if '--no-build' in args:
    args.remove('--no-build')
  else:
    if build.main(build_args) != 0:
      return 1

  karma_path = shakaBuildHelpers.get_node_binary_path('karma')
  cmd = [karma_path, 'start']

  # Get the browsers supported on the local system.
  browsers = _get_browsers()
  if not browsers:
    print >> sys.stderr, 'Unrecognized system "%s"' % platform.uname()[0]
    return 1

  print 'Starting tests...'
  if not args:
    # Run tests in all available browsers.
    print 'Running with platform default:', '--browsers', browsers
    cmd_line = cmd + ['--browsers', browsers]
    shakaBuildHelpers.print_cmd_line(cmd_line)
    return subprocess.call(cmd_line)
  else:
    # Run with command-line arguments from the user.
    if '--browsers' not in args:
      print 'No --browsers specified.'
      print 'In this mode, browsers must be manually connected to karma.'
    cmd_line = cmd + args
    shakaBuildHelpers.print_cmd_line(cmd_line)
    return subprocess.call(cmd_line)
コード例 #10
0
ファイル: check.py プロジェクト: indiereign/shaka-player
def check_html_lint():
  """Runs the HTML linter over the HTML files.

  Returns:
    True on success, False on failure.
  """
  # Update node modules if needed.
  if not shakaBuildHelpers.update_node_modules():
    return False

  logging.info('Running htmlhint...')
  htmlhint_path = shakaBuildHelpers.get_node_binary_path('htmlhint')
  base = shakaBuildHelpers.get_source_base()
  files = ['index.html', 'demo/index.html', 'support.html']
  file_paths = [os.path.join(base, x) for x in files]
  config_path = os.path.join(base, '.htmlhintrc')
  cmd_line = [htmlhint_path, '--config=' + config_path] + file_paths
  return shakaBuildHelpers.execute_get_code(cmd_line) == 0
コード例 #11
0
ファイル: check.py プロジェクト: baconz/shaka-player
def check_html_lint():
  """Runs the HTML linter over the HTML files.

  Skipped if htmlhint is not available.

  Returns:
    True on success, False on failure.
  """
  htmlhint_path = shakaBuildHelpers.get_node_binary_path('htmlhint')
  if not os.path.exists(htmlhint_path):
    return True
  print 'Running htmlhint...'

  base = shakaBuildHelpers.get_source_base()
  files = ['index.html', 'demo/index.html', 'support.html']
  file_paths = [os.path.join(base, x) for x in files]
  cmd_line = [htmlhint_path] + file_paths
  shakaBuildHelpers.print_cmd_line(cmd_line)
  return subprocess.call(cmd_line) == 0
コード例 #12
0
def check_html_lint():
    """Runs the HTML linter over the HTML files.

  Skipped if htmlhint is not available.

  Returns:
    True on success, False on failure.
  """
    htmlhint_path = shakaBuildHelpers.get_node_binary_path('htmlhint')
    if not os.path.exists(htmlhint_path):
        return True
    print 'Running htmlhint...'

    base = shakaBuildHelpers.get_source_base()
    files = ['index.html', 'demo/index.html', 'support.html']
    file_paths = [os.path.join(base, x) for x in files]
    config_path = os.path.join(base, '.htmlhintrc')
    cmd_line = [htmlhint_path, '--config=' + config_path] + file_paths
    return shakaBuildHelpers.execute_get_code(cmd_line) == 0