2
# Copyright (C) 2012 Google Inc. All rights reserved.
4
# Redistribution and use in source and binary forms, with or without
5
# modification, are permitted provided that the following conditions are
8
# * Redistributions of source code must retain the above copyright
9
# notice, this list of conditions and the following disclaimer.
10
# * Redistributions in binary form must reproduce the above
11
# copyright notice, this list of conditions and the following disclaimer
12
# in the documentation and/or other materials provided with the
14
# * Neither the name of Google Inc. nor the names of its
15
# contributors may be used to endorse or promote products derived from
16
# this software without specific prior written permission.
18
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
# This script exports newly added tests to the W3C Web Performance WG's test
33
# You must have checked out the 'webperf' repository from https://dvcs.w3.org/hg/
35
# This script will export the LayoutTests/http/tests/w3c/submission directory
36
# to a local 'webperf' repository.
38
# The main step in exporting the tests is updating all of the URLs to account
39
# for the differences in directory layout.
45
if len(sys.argv) != 3:
46
print 'USAGE: %s path_to_webkit_checkout_root path_to_webperf_checkout_root'
49
source_directory = os.path.join(sys.argv[1], 'LayoutTests', 'http', 'tests', 'w3c', 'webperf')
50
destination_directory = os.path.join(sys.argv[2], 'tests')
52
directories_to_copy = ['resources', 'submission']
54
('localhost:8000', 'www.w3c-test.org'), # This is the alternate host for cross-server requests.
55
('127.0.0.1:8000', 'w3c-test.org'), # This is the primary test server.
56
('w3c/webperf', 'webperf/tests'), # We prepend /w3c to all of our paths.
57
('/w3c/resources/testharness', '/resources/testharness'),
58
('\n', '\r\n'), # Convert from *NIX format.
61
for directory_to_copy in directories_to_copy:
62
destination_subdirectory = os.path.join(destination_directory, directory_to_copy)
63
if not os.path.exists(destination_subdirectory):
64
os.makedirs(destination_subdirectory)
65
for root, dirs, files in os.walk(os.path.join(source_directory, directory_to_copy)):
66
print root, dirs, files
67
root = os.path.relpath(root, source_directory)
69
destination_subdirectory = os.path.join(destination_directory, root, dirname)
70
if not os.path.exists(destination_subdirectory):
71
os.makedirs(destination_subdirectory)
72
for filename in files:
73
if filename.endswith('-expected.txt'):
75
with open(os.path.join(source_directory, root, filename), 'r') as in_file:
76
with open(os.path.join(destination_directory, root, filename), 'w') as out_file:
78
for to_find, replace_with in replacements:
79
line = line.replace(to_find, replace_with)