summaryrefslogtreecommitdiff
path: root/deps/v8/test/test262/archive.py
blob: 894853e20854e07bd05fb4b348140796bf47e666 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
# Copyright 2016 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os
import sys
import tarfile
import time

# In GN we expect the path to a stamp file as an argument.
if len(sys.argv) == 2:
  STAMP_FILE = os.path.abspath(sys.argv[1])

os.chdir(os.path.dirname(os.path.abspath(__file__)))

# Workaround for slow grp and pwd calls.
tarfile.grp = None
tarfile.pwd = None

def filter_git(tar_info):
  if tar_info.name.startswith(os.path.join('data', '.git')) or \
      tar_info.name.startswith(os.path.join('harness', '.git')):
    return None
  else:
    tar_info.uname = tar_info.gname = "test262"
    return tar_info

with tarfile.open('data.tar', 'w') as tar:
  tar.add('data', filter=filter_git)
  tar.add('harness', filter=filter_git)

# Workaround for GN. We can't specify the tarfile as output because it's
# not in the product directory. Therefore we track running of this script
# with an extra stamp file in the product directory.
if len(sys.argv) == 2:
  with open(STAMP_FILE, 'w') as f:
    f.write(str(time.time()))