Esempio n. 1
0
def format_tests(test_root, test_tree):
  tests = []
  for name, test in test_tree:
      command_line = test.read_file('description')
      failed = test.read_file('fail_message')
      if failed is None:
        status = 'pass'
      else:
        status = 'fail'

      file_infos = []
      for rel_path in test.list_files(text_only=False):
          path = os.path.join(test_root, name, rel_path)
          file_info = { 'name': os.path.join(name, rel_path) }
          if utils.guess_is_text_file(path) and os.path.getsize(path) > 0:
            file_info['contents'] = open(path, "rb").read()
          file_infos.append(file_info)

      tests.append({
        'name': name,
        'id': name.replace('.', '-'),
        'status': status,
        'files': file_infos
      })
  return sorted(tests, key = lambda t: t['name'])
Esempio n. 2
0
def format_tests(test_root, test_tree):
    tests = []
    for name, test in test_tree:
        command_line = test.read_file('description')
        failed = test.read_file('fail_message')
        if failed is None:
            status = 'pass'
        else:
            status = 'fail'

        file_infos = []
        for rel_path in test.list_files(text_only=False):
            path = os.path.join(test_root, name, rel_path)
            file_info = {'name': os.path.join(name, rel_path)}
            if utils.guess_is_text_file(path):
                file_info['contents'] = file_reader(path)
            file_infos.append(file_info)

        tests.append({
            'name': name,
            'id': name.replace('.', '-'),
            'status': status,
            'files': file_infos
        })
    return sorted(tests, key=lambda t: t['name'])
Esempio n. 3
0
 def list_files(self, glob=None, text_only=True):
     for root, dirs, files in os.walk(self.dir):
         for file in files:
             name = relpath(join(root, file), self.dir)
             if not glob or fnmatch.fnmatch(name, glob):
                 if not text_only or name == glob or guess_is_text_file(join(root, file)):
                     yield name