Пример #1
0
def CMDremap(args):
  """Creates a directory with all the dependencies mapped into it.

  Useful to test manually why a test is failing. The target executable is not
  run.
  """
  parser = OptionParserIsolate(command='remap', require_result=False)
  options, _ = parser.parse_args(args)
  complete_state = load_complete_state(options, STATS_ONLY)

  if not options.outdir:
    options.outdir = run_test_from_archive.make_temp_dir(
        'isolate', complete_state.root_dir)
  else:
    if not os.path.isdir(options.outdir):
      os.makedirs(options.outdir)
  print 'Remapping into %s' % options.outdir
  if len(os.listdir(options.outdir)):
    raise ExecutionError('Can\'t remap in a non-empty directory')
  recreate_tree(
      outdir=options.outdir,
      indir=complete_state.root_dir,
      infiles=complete_state.result.files,
      action=run_test_from_archive.HARDLINK,
      as_sha1=False)
  if complete_state.result.read_only:
    run_test_from_archive.make_writable(options.outdir, True)

  if complete_state.result_file:
    complete_state.save_files()
  return 0
Пример #2
0
def CMDrun(args):
  """Runs the test executable in an isolated (temporary) directory.

  All the dependencies are mapped into the temporary directory and the
  directory is cleaned up after the target exits. Warning: if -outdir is
  specified, it is deleted upon exit.

  Argument processing stops at the first non-recognized argument and these
  arguments are appended to the command line of the target to run. For example,
  use: isolate.py -r foo.results -- --gtest_filter=Foo.Bar
  """
  parser = OptionParserIsolate(command='run', require_result=False)
  parser.enable_interspersed_args()
  options, args = parser.parse_args(args)
  complete_state = load_complete_state(options, STATS_ONLY)
  cmd = complete_state.result.command + args
  if not cmd:
    raise ExecutionError('No command to run')
  cmd = trace_inputs.fix_python_path(cmd)
  try:
    if not options.outdir:
      options.outdir = run_test_from_archive.make_temp_dir(
          'isolate', complete_state.root_dir)
    else:
      if not os.path.isdir(options.outdir):
        os.makedirs(options.outdir)
    recreate_tree(
        outdir=options.outdir,
        indir=complete_state.root_dir,
        infiles=complete_state.result.files,
        action=run_test_from_archive.HARDLINK,
        as_sha1=False)
    cwd = os.path.normpath(
        os.path.join(options.outdir, complete_state.result.relative_cwd))
    if not os.path.isdir(cwd):
      # It can happen when no files are mapped from the directory containing the
      # .isolate file. But the directory must exist to be the current working
      # directory.
      os.makedirs(cwd)
    if complete_state.result.read_only:
      run_test_from_archive.make_writable(options.outdir, True)
    logging.info('Running %s, cwd=%s' % (cmd, cwd))
    result = subprocess.call(cmd, cwd=cwd)
  finally:
    if options.outdir:
      run_test_from_archive.rmtree(options.outdir)

  if complete_state.result_file:
    complete_state.save_files()
  return result
Пример #3
0
def MODEremap(outdir, state):
    if not outdir:
        outdir = tempfile.mkdtemp(prefix="isolate")
    else:
        if not os.path.isdir(outdir):
            os.makedirs(outdir)
    print "Remapping into %s" % outdir
    if len(os.listdir(outdir)):
        print "Can't remap in a non-empty directory"
        return 1
    recreate_tree(outdir, state.root_dir, state.result.files.keys(), run_test_from_archive.HARDLINK)
    if state.result.read_only:
        run_test_from_archive.make_writable(outdir, True)
    return 0
Пример #4
0
def MODEremap(outdir, state):
    if not outdir:
        outdir = tempfile.mkdtemp(prefix='isolate')
    else:
        if not os.path.isdir(outdir):
            os.makedirs(outdir)
    print 'Remapping into %s' % outdir
    if len(os.listdir(outdir)):
        print 'Can\'t remap in a non-empty directory'
        return 1
    recreate_tree(outdir, state.root_dir, state.result.files.keys(),
                  run_test_from_archive.HARDLINK)
    if state.result.read_only:
        run_test_from_archive.make_writable(outdir, True)
    return 0
Пример #5
0
def MODEremap(outdir, indir, data):
  if not outdir:
    outdir = tempfile.mkdtemp(prefix='isolate')
  else:
    if not os.path.isdir(outdir):
      os.makedirs(outdir)
  print 'Remapping into %s' % outdir
  if len(os.listdir(outdir)):
    print 'Can\'t remap in a non-empty directory'
    return 1
  recreate_tree(
      outdir, indir, data['files'].keys(), run_test_from_archive.HARDLINK)
  if data['read_only']:
    run_test_from_archive.make_writable(outdir, True)
  return 0
Пример #6
0
def MODErun(_outdir, state):
    """Always uses a temporary directory."""
    try:
        outdir = tempfile.mkdtemp(prefix="isolate")
        recreate_tree(outdir, state.root_dir, state.result.files.keys(), run_test_from_archive.HARDLINK)
        cwd = os.path.join(outdir, state.result.relative_cwd)
        if not os.path.isdir(cwd):
            os.makedirs(cwd)
        if state.result.read_only:
            run_test_from_archive.make_writable(outdir, True)
        if not state.result.command:
            print "No command to run"
            return 1
        cmd = trace_inputs.fix_python_path(state.result.command)
        logging.info("Running %s, cwd=%s" % (cmd, cwd))
        return subprocess.call(cmd, cwd=cwd)
    finally:
        run_test_from_archive.rmtree(outdir)
Пример #7
0
def MODErun(_outdir, state):
    """Always uses a temporary directory."""
    try:
        outdir = tempfile.mkdtemp(prefix='isolate')
        recreate_tree(outdir, state.root_dir, state.result.files.keys(),
                      run_test_from_archive.HARDLINK)
        cwd = os.path.join(outdir, state.result.relative_cwd)
        if not os.path.isdir(cwd):
            os.makedirs(cwd)
        if state.result.read_only:
            run_test_from_archive.make_writable(outdir, True)
        if not state.result.command:
            print 'No command to run'
            return 1
        cmd = trace_inputs.fix_python_path(state.result.command)
        logging.info('Running %s, cwd=%s' % (cmd, cwd))
        return subprocess.call(cmd, cwd=cwd)
    finally:
        run_test_from_archive.rmtree(outdir)
Пример #8
0
def MODErun(_outdir, indir, data):
  """Always uses a temporary directory."""
  try:
    outdir = tempfile.mkdtemp(prefix='isolate')
    recreate_tree(
        outdir, indir, data['files'].keys(), run_test_from_archive.HARDLINK)
    cwd = os.path.join(outdir, data['relative_cwd'])
    if not os.path.isdir(cwd):
      os.makedirs(cwd)
    if data['read_only']:
      run_test_from_archive.make_writable(outdir, True)
    if not data['command']:
      print 'No command to run'
      return 1
    cmd = trace_inputs.fix_python_path(data['command'])
    logging.info('Running %s, cwd=%s' % (cmd, cwd))
    return subprocess.call(cmd, cwd=cwd)
  finally:
    run_test_from_archive.rmtree(outdir)
Пример #9
0
def CMDrun(args):
  """Runs the test executable in an isolated (temporary) directory.

  All the dependencies are mapped into the temporary directory and the
  directory is cleaned up after the target exits. Warning: if -outdir is
  specified, it is deleted upon exit.
  """
  parser = OptionParserIsolate(command='run', require_result=False)
  options, _ = parser.parse_args(args)
  complete_state = load_complete_state(options, STATS_ONLY)
  try:
    if not options.outdir:
      options.outdir = tempfile.mkdtemp(prefix='isolate')
    else:
      if not os.path.isdir(options.outdir):
        os.makedirs(options.outdir)
    recreate_tree(
        options.outdir,
        complete_state.root_dir,
        complete_state.result.files.keys(),
        run_test_from_archive.HARDLINK)
    cwd = os.path.join(options.outdir, complete_state.result.relative_cwd)
    if not os.path.isdir(cwd):
      os.makedirs(cwd)
    if complete_state.result.read_only:
      run_test_from_archive.make_writable(options.outdir, True)
    if not complete_state.result.command:
      raise ExecutionError('No command to run')
    cmd = trace_inputs.fix_python_path(complete_state.result.command)
    logging.info('Running %s, cwd=%s' % (cmd, cwd))
    result = subprocess.call(cmd, cwd=cwd)
  finally:
    if options.outdir:
      run_test_from_archive.rmtree(options.outdir)

  if complete_state.result_file:
    complete_state.save_files()
  return result