2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """Auto-generates the WebGL conformance test list header file.
8 Parses the WebGL conformance test *.txt file, which contains a list of URLs
9 for individual conformance tests (each on a new line). It recursively parses
10 *.txt files. For each test URL, the matching gtest call is created and
11 sent to the C++ header file.
20 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
21 // Use of this source code is governed by a BSD-style license that can be
22 // found in the LICENSE file.
26 // DO NOT EDIT! This file is auto-generated by
27 // generate_webgl_conformance_test_list.py
28 // It is included by webgl_conformance_test.cc
32 #ifndef CONTENT_TEST_GPU_WEBGL_CONFORMANCE_TEST_LIST_AUTOGEN_H_
33 #define CONTENT_TEST_GPU_WEBGL_CONFORMANCE_TEST_LIST_AUTOGEN_H_
36 HEADER_GUARD_END
= """
37 #endif // CONTENT_TEST_GPU_WEBGL_CONFORMANCE_TEST_LIST_AUTOGEN_H_
41 # Assume this script is run from the src/content/test/gpu directory.
42 INPUT_DIR
= "../../../third_party/webgl_conformance"
43 INPUT_FILE
= "00_test_list.txt"
44 OUTPUT_FILE
= "webgl_conformance_test_list_autogen.h"
47 """Main function for the WebGL conformance test list generator.
49 if not os
.path
.exists(os
.path
.join(INPUT_DIR
, INPUT_FILE
)):
50 print >> sys
.stderr
, "ERROR: WebGL conformance tests do not exist."
51 print >> sys
.stderr
, "Run the script from the directory containing it."
54 output
= open(OUTPUT_FILE
, "w")
55 output
.write(COPYRIGHT
)
57 output
.write(HEADER_GUARD
)
61 unparsed_files
= [INPUT_FILE
]
63 filename
= unparsed_files
.pop(0)
65 input = open(os
.path
.join(INPUT_DIR
, filename
))
67 print >> sys
.stderr
, "WARNING: %s does not exist (skipped)." % filename
71 url
= re
.sub("//.*", "", url
)
72 url
= re
.sub("#.*", "", url
)
74 # Some filename has options before them, for example,
75 # --min-version 1.0.2 testname.html
83 # Cannot use os.path.join() because Windows with use "\\" but this path
84 # is sent through javascript.
85 if os
.path
.dirname(filename
):
86 url
= "%s/%s" % (os
.path
.dirname(filename
), url
)
88 # Queue all text files for parsing, because test list URLs are nested
90 if re
.match(".+\.txt\s*$", url
):
91 unparsed_files
.append(url
)
93 # Convert the filename to a valid test name and output the gtest code.
95 name
= os
.path
.splitext(url
)[0]
96 name
= re
.sub("\W+", "_", name
)
97 if os
.path
.exists(os
.path
.join(INPUT_DIR
, url
)):
98 output
.write('CONFORMANCE_TEST(%s,\n "%s");\n' % (name
, url
))
100 print >> sys
.stderr
, "WARNING: %s does not exist (skipped)." % url
103 output
.write(HEADER_GUARD_END
)
107 if __name__
== "__main__":
108 sys
.exit(main(sys
.argv
[1:]))