Example #1
0
def runTests(args):
  """Runs all the karma tests."""
  # Update node modules if needed.
  shakaBuildHelpers.updateNodeModules()

  # Generate dependencies required for the tests.
  if gendeps.genDeps([]) != 0:
    return 1

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

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

  # Get the browsers supported on the local system.
  browsers = _GetBrowsers()
  if not browsers:
    print >> sys.stderr, 'Unrecognized system', system
    return 1

  if len(args) == 0:
    # Run tests in all available browsers.
    cmdLine = cmd + ['--browsers', browsers]
    shakaBuildHelpers.printCmdLine(cmdLine)
    return subprocess.call(cmdLine)
  else:
    # Run with command-line arguments from the user.
    cmdLine = cmd + args
    shakaBuildHelpers.printCmdLine(cmdLine)
    return subprocess.call(cmdLine)
Example #2
0
def checkHtmlLint():
    """Runs the HTML linter over the HTML files."""
    htmlhint_path = shakaBuildHelpers.getNodeBinaryPath('htmlhint')
    base = shakaBuildHelpers.getSourceBase()
    files = ['index.html', 'demo/index.html', 'support.html']
    file_paths = [os.path.join(base, x) for x in files]
    cmdLine = [htmlhint_path] + file_paths
    shakaBuildHelpers.printCmdLine(cmdLine)
    return (subprocess.call(cmdLine) == 0)
Example #3
0
def checkHtmlLint():
  """Runs the HTML linter over the HTML files."""
  htmlhint_path = shakaBuildHelpers.getNodeBinaryPath('htmlhint')
  base = shakaBuildHelpers.getSourceBase()
  files = ['index.html', 'demo/index.html', 'support.html']
  file_paths = [os.path.join(base, x) for x in files]
  cmdLine = [htmlhint_path] + file_paths
  shakaBuildHelpers.printCmdLine(cmdLine)
  return (subprocess.call(cmdLine) == 0)
Example #4
0
def runTests(args):
    """Runs all the karma tests."""
    # Update node modules if needed.
    if not shakaBuildHelpers.updateNodeModules():
        return 1

    # Generate dependencies and compile library.
    # This is required for the tests.
    if gendeps.genDeps([]) != 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.isWindows():
        # Windows karma program has a different name
        karma_command_name = 'karma.cmd'

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

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

    print 'Starting tests...'
    if len(args) == 0:
        # Run tests in all available browsers.
        print 'Running with platform default:', '--browsers', browsers
        cmdLine = cmd + ['--browsers', browsers]
        shakaBuildHelpers.printCmdLine(cmdLine)
        return subprocess.call(cmdLine)
    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.'
        cmdLine = cmd + args
        shakaBuildHelpers.printCmdLine(cmdLine)
        return subprocess.call(cmdLine)
Example #5
0
def runTests(args):
  """Runs all the karma tests."""
  # Update node modules if needed.
  if not shakaBuildHelpers.updateNodeModules():
    return 1

  # Generate dependencies and compile library.
  # This is required for the tests.
  if gendeps.genDeps([]) != 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.isWindows():
    # Windows karma program has a different name
    karma_command_name = 'karma.cmd'

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

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

  print 'Starting tests...'
  if len(args) == 0:
    # Run tests in all available browsers.
    print 'Running with platform default:', '--browsers', browsers
    cmdLine = cmd + ['--browsers', browsers]
    shakaBuildHelpers.printCmdLine(cmdLine)
    return subprocess.call(cmdLine)
  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.'
    cmdLine = cmd + args
    shakaBuildHelpers.printCmdLine(cmdLine)
    return subprocess.call(cmdLine)
Example #6
0
def buildDocs(_):
  base = shakaBuildHelpers.getSourceBase()
  shutil.rmtree(os.path.join(base, 'docs', 'api'), ignore_errors=True)
  os.chdir(base)

  if shakaBuildHelpers.isWindows() or shakaBuildHelpers.isCygwin():
    # Windows has a different command name.  The Unix version does not seem to
    # work on Cygwin, but the windows one does.
    jsdoc = os.path.join('third_party', 'jsdoc', 'jsdoc.cmd')
  else:
    jsdoc = os.path.join('third_party', 'jsdoc', 'jsdoc')

  cmdLine = [jsdoc, '-c', 'jsdoc.conf.json']
  shakaBuildHelpers.printCmdLine(cmdLine)
  return subprocess.call(cmdLine)
Example #7
0
def buildDocs(_):
    base = shakaBuildHelpers.getSourceBase()
    shutil.rmtree(os.path.join(base, 'docs', 'api'), ignore_errors=True)
    os.chdir(base)

    if shakaBuildHelpers.isWindows() or shakaBuildHelpers.isCygwin():
        # Windows has a different command name.  The Unix version does not seem to
        # work on Cygwin, but the windows one does.
        jsdoc = os.path.join('third_party', 'jsdoc', 'jsdoc.cmd')
    else:
        jsdoc = os.path.join('third_party', 'jsdoc', 'jsdoc')

    cmdLine = [jsdoc, '-c', 'jsdoc.conf.json']
    shakaBuildHelpers.printCmdLine(cmdLine)
    return subprocess.call(cmdLine)
Example #8
0
def checkLint():
  """Runs the linter over the library files."""
  jsdoc3_tags = ','.join([
      'static', 'summary', 'namespace', 'event', 'description', 'property',
      'fires', 'listens', 'example', 'exportDoc'])
  args = ['--nobeep', '--custom_jsdoc_tags', jsdoc3_tags, '--strict']
  base = shakaBuildHelpers.getSourceBase()
  cmd = os.path.join(base, 'third_party', 'gjslint', 'gjslint')

  # Even though this is python, don't import and execute since gjslint expects
  # command-line arguments using argv.  Have to explicitly execute python so
  # it works on Windows.
  cmdLine = ['python', cmd] + args + getLintFiles()
  shakaBuildHelpers.printCmdLine(cmdLine)
  return (subprocess.call(cmdLine) == 0)
Example #9
0
def checkHtmlLint():
    """Runs the HTML linter over the HTML files.
  Skipped if htmlhint is not available.
  """
    htmlhint_path = shakaBuildHelpers.getNodeBinaryPath('htmlhint')
    if not os.path.exists(htmlhint_path):
        return True
    print 'Running htmlhint...'

    base = shakaBuildHelpers.getSourceBase()
    files = ['index.html', 'demo/index.html', 'support.html']
    file_paths = [os.path.join(base, x) for x in files]
    cmdLine = [htmlhint_path] + file_paths
    shakaBuildHelpers.printCmdLine(cmdLine)
    return (subprocess.call(cmdLine) == 0)
Example #10
0
def checkHtmlLint():
  """Runs the HTML linter over the HTML files.
  Skipped if htmlhint is not available.
  """
  htmlhint_path = shakaBuildHelpers.getNodeBinaryPath('htmlhint')
  if not os.path.exists(htmlhint_path):
    return True
  print 'Running htmlhint...'

  base = shakaBuildHelpers.getSourceBase()
  files = ['index.html', 'demo/index.html', 'support.html']
  file_paths = [os.path.join(base, x) for x in files]
  cmdLine = [htmlhint_path] + file_paths
  shakaBuildHelpers.printCmdLine(cmdLine)
  return (subprocess.call(cmdLine) == 0)
Example #11
0
def checkLint():
    """Runs the linter over the library files."""
    jsdoc3_tags = ','.join([
        'static', 'summary', 'namespace', 'event', 'description', 'property',
        'fires', 'listens', 'example', 'exportDoc'
    ])
    args = ['--nobeep', '--custom_jsdoc_tags', jsdoc3_tags, '--strict']
    base = shakaBuildHelpers.getSourceBase()
    cmd = os.path.join(base, 'third_party', 'gjslint', 'gjslint')

    # Even though this is python, don't import and execute since gjslint expects
    # command-line arguments using argv.  Have to explicitly execute python so
    # it works on Windows.
    cmdLine = ['python', cmd] + args + getLintFiles()
    shakaBuildHelpers.printCmdLine(cmdLine)
    return (subprocess.call(cmdLine) == 0)
Example #12
0
def genDeps(_):
  # Make the dist/ folder, ignore errors.
  base = shakaBuildHelpers.getSourceBase()
  try:
    os.mkdir(os.path.join(base, 'dist'))
  except OSError:
    pass
  os.chdir(base)
  depsWriter = os.path.join('third_party', 'closure', 'deps', 'depswriter.py')

  try:
    cmdLine = ['python', depsWriter] + depsArgs
    shakaBuildHelpers.printCmdLine(cmdLine)
    deps = subprocess.check_output(cmdLine)
    with open(os.path.join(base, 'dist', 'deps.js'), 'w') as f:
      f.write(deps)
    return 0
  except subprocess.CalledProcessError as e:
    return e.returncode
Example #13
0
def genDeps(_):
    # Make the dist/ folder, ignore errors.
    base = shakaBuildHelpers.getSourceBase()
    try:
        os.mkdir(os.path.join(base, 'dist'))
    except OSError:
        pass
    os.chdir(base)
    depsWriter = os.path.join('third_party', 'closure', 'deps',
                              'depswriter.py')

    try:
        cmdLine = ['python', depsWriter] + depsArgs
        shakaBuildHelpers.printCmdLine(cmdLine)
        deps = subprocess.check_output(cmdLine)
        with open(os.path.join(base, 'dist', 'deps.js'), 'w') as f:
            f.write(deps)
        return 0
    except subprocess.CalledProcessError as e:
        return e.returncode
Example #14
0
  def buildRaw(self, extra_opts):
    """Builds the files in |self.include| using the given extra Closure options.

    Arguments:
      extra_opts - An array of extra options to give to Closure.

    Returns:
      True on success; False on failure.
    """
    jar = os.path.join(shakaBuildHelpers.getSourceBase(),
        'third_party', 'closure', 'compiler.jar')
    jar = shakaBuildHelpers.cygwinSafePath(jar)
    files = map(shakaBuildHelpers.cygwinSafePath, list(self.include))

    try:
      cmdLine = ['java', '-jar', jar] + closure_opts + extra_opts + files
      shakaBuildHelpers.printCmdLine(cmdLine)
      subprocess.check_call(cmdLine)
      return True
    except subprocess.CalledProcessError:
      print >> sys.stderr, 'Build failed'
      return False
Example #15
0
    def buildRaw(self, extra_opts):
        """Builds the files in |self.include| using the given extra Closure options.

    Arguments:
      extra_opts - An array of extra options to give to Closure.

    Returns:
      True on success; False on failure.
    """
        jar = os.path.join(shakaBuildHelpers.getSourceBase(), 'third_party',
                           'closure', 'compiler.jar')
        jar = shakaBuildHelpers.cygwinSafePath(jar)
        files = map(shakaBuildHelpers.cygwinSafePath, list(self.include))

        try:
            cmdLine = ['java', '-jar', jar] + closure_opts + extra_opts + files
            shakaBuildHelpers.printCmdLine(cmdLine)
            subprocess.check_call(cmdLine)
            return True
        except subprocess.CalledProcessError:
            print >> sys.stderr, 'Build failed'
            return False