From 6ae60b1a99f747618c637f1c1131127420d9446a Mon Sep 17 00:00:00 2001 From: "phajdan.jr@chromium.org" Date: Fri, 8 Mar 2013 18:04:06 +0000 Subject: [PATCH] Add an option to package test data to export_tarball script. 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 --- tools/export_tarball/export_tarball.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tools/export_tarball/export_tarball.py b/tools/export_tarball/export_tarball.py index 518d097c9db291..de8edb5f5aebb6 100755 --- a/tools/export_tarball/export_tarball.py +++ b/tools/export_tarball/export_tarball.py @@ -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', @@ -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( @@ -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 @@ -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) @@ -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. @@ -135,7 +140,7 @@ 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') @@ -143,7 +148,12 @@ def main(argv): 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()