v8/test/test262/archive.py
machenbach 0d65554c05 [gn] Port test262 archiving to gn
This calls the action that archives test262 in gn. In gn
we can't specify an action output outside the product
directory. This works around it with an extra action
stamp file in the product directory, while the archive
remains in the test directory.

We don't want to generate the archive in the product
directory, as some legacy archiving scripts might include
it and it's too large. It should only be included in the
swarming tasks that are going to use it for testing.

BUG=chromium:474921

Review-Url: https://codereview.chromium.org/2034713005
Cr-Commit-Position: refs/heads/master@{#36731}
2016-06-06 08:56:58 +00:00

37 lines
1.0 KiB
Python
Executable File

#!/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')):
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)
# 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()))