Skip to content

Commit

Permalink
Add an option to package test data to export_tarball script.
Browse files Browse the repository at this point in the history
It is helpful to have test data in a separate tarball, because
then the main tarball (with everything needed to compile the browser)
can be kept small while still allowing people to run tests as an option.

BUG=none

Review URL: https://codereview.chromium.org/12621004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186981 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
phajdan.jr@chromium.org committed Mar 8, 2013
1 parent e484a3e commit 6ae60b1
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions tools/export_tarball/export_tarball.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,10 @@
'breakpad/src/processor/testdata',
'chrome/browser/resources/tracing/tests',
'chrome/common/extensions/docs',
'chrome/test/data',
'chrome/tools/test/reference_build',
'content/test/data',
'courgette/testdata',
'data',
'media/test/data',
'native_client/src/trusted/service_runtime/testdata',
'net/data',
'src/chrome/test/data',
'o3d/documentation',
'o3d/samples',
Expand Down Expand Up @@ -71,6 +67,13 @@
'webkit/tools/test/reference_build',
)

TESTDIRS = (
'chrome/test/data',
'content/test/data',
'media/test/data',
'net/data',
)


def GetSourceDirectory():
return os.path.realpath(
Expand All @@ -96,7 +99,7 @@ def add(self, name, arcname=None, recursive=True, exclude=None, filter=None):

# Remove contents of non-essential directories, but preserve gyp files,
# so that build/gyp_chromium can work.
for nonessential_dir in NONESSENTIAL_DIRS:
for nonessential_dir in (NONESSENTIAL_DIRS + TESTDIRS):
dir_path = os.path.join(GetSourceDirectory(), nonessential_dir)
if (name.startswith(dir_path) and
os.path.isfile(name) and
Expand All @@ -108,9 +111,11 @@ def add(self, name, arcname=None, recursive=True, exclude=None, filter=None):

def main(argv):
parser = optparse.OptionParser()
parser.add_option("--basename")
parser.add_option("--remove-nonessential-files",
dest="remove_nonessential_files",
action="store_true", default=False)
parser.add_option("--test-data", action="store_true")
parser.add_option("--xz", action="store_true")

options, args = parser.parse_args(argv)
Expand All @@ -121,7 +126,7 @@ def main(argv):
return 1

if not os.path.exists(GetSourceDirectory()):
print 'Cannot find the src directory.'
print 'Cannot find the src directory ' + GetSourceDirectory()
return 1

# This command is from src/DEPS; please keep them in sync.
Expand All @@ -135,15 +140,20 @@ def main(argv):
else:
output_fullname = args[0] + '.tar.bz2'

output_basename = os.path.basename(args[0])
output_basename = options.basename or os.path.basename(args[0])

if options.xz:
archive = MyTarFile.open(output_fullname, 'w')
else:
archive = MyTarFile.open(output_fullname, 'w:bz2')
archive.set_remove_nonessential_files(options.remove_nonessential_files)
try:
archive.add(GetSourceDirectory(), arcname=output_basename)
if options.test_data:
for directory in TESTDIRS:
archive.add(os.path.join(GetSourceDirectory(), directory),
arcname=os.path.join(output_basename, directory))
else:
archive.add(GetSourceDirectory(), arcname=output_basename)
finally:
archive.close()

Expand Down

0 comments on commit 6ae60b1

Please sign in to comment.