Index: chrome/test/gpu/generate_webgl_conformance_test_list.py |
=================================================================== |
--- chrome/test/gpu/generate_webgl_conformance_test_list.py (revision 113824) |
+++ chrome/test/gpu/generate_webgl_conformance_test_list.py (working copy) |
@@ -45,29 +45,50 @@ |
EXPECTATION_FILE = "webgl_conformance_test_expectations.txt" |
EXPECTATION_REGEXP = re.compile( |
r'^(?P<BUG>\S+)\s+' |
- '(?P<OS>(\s*(WIN|MAC|LINUX)\s*)+):' |
+ '(?P<MODIFIER>(\s*(WIN|MAC|LINUX|RELEASE|DEBUG)\s*)+):' |
'(?P<TEST>[^=]+)=' |
'(?P<OUTCOME>(\s*(PASS|FAIL|TIMEOUT)\s*)+)') |
-def is_matching_os(expected_os_list): |
- """Returns true if the current OS is in the given list. |
+def map_to_macro_conditions(modifier_list): |
+ """Returns a string containing macro conditions wrapped in '(*)'. |
- Given a list containing 'WIN', 'MAC' or 'LINUX', return true if the current |
- OS, represented as 'win32', 'darwin' or 'linux*', respectively, exists in the |
- list. |
+ Given a list containing 'WIN', 'MAC', 'LINUX', 'RELEASE', or 'DEBUG', |
+ return the corresponding macro conditions. |
""" |
- if sys.platform.startswith('linux') and 'LINUX' in expected_os_list: |
- return True; |
- if sys.platform == 'darwin' and 'MAC' in expected_os_list: |
- return True; |
- if sys.platform == 'win32' and 'WIN' in expected_os_list: |
- return True; |
- return False; |
+ rt = '' |
+ release = False |
+ debug = False |
+ for modifier in modifier_list: |
+ if modifier == 'RELEASE': |
+ release = True |
+ elif modifier == 'DEBUG': |
+ debug = True |
+ else: |
+ if rt: |
+ rt += ' || ' |
+ if modifier == 'WIN': |
+ rt = rt + 'defined(OS_WIN)' |
+ elif modifier == 'MAC': |
+ rt = rt + 'defined(OS_MACOSX)' |
+ elif modifier == 'LINUX': |
+ rt = rt + 'defined(OS_LINUX)' |
+ if release == debug: |
+ return rt |
+ |
+ if rt: |
+ rt = '(' + rt + ') && ' |
+ |
+ if debug: |
+ rt = rt + '!defined(NDEBUG)' |
+ if release: |
+ rt = rt + 'defined(NDEBUG)' |
+ |
+ return rt |
+ |
def main(argv): |
"""Main function for the WebGL conformance test list generator. |
""" |
- |
if not os.path.exists(os.path.join(INPUT_DIR, INPUT_FILE)): |
print >> sys.stderr, "ERROR: WebGL conformance tests do not exist." |
print >> sys.stderr, "Run the script from the directory containing it." |
@@ -77,31 +98,39 @@ |
print >> sys.stderr, "Run the script from the directory containing it." |
return 1 |
+ output = open(OUTPUT_FILE, "w") |
+ output.write(COPYRIGHT) |
+ output.write(WARNING) |
+ output.write(HEADER_GUARD) |
+ |
test_prefix = {} |
test_expectations = open(EXPECTATION_FILE) |
for line in test_expectations: |
line_match = EXPECTATION_REGEXP.match(line) |
if line_match: |
match_dict = line_match.groupdict() |
- os_list = match_dict['OS'].strip().split() |
- if not is_matching_os(os_list): |
- continue |
+ modifier_list = match_dict['MODIFIER'].strip().split() |
+ macro_conditions = map_to_macro_conditions(modifier_list) |
test = match_dict['TEST'].strip() |
outcome_list = match_dict['OUTCOME'].strip().split() |
if 'TIMEOUT' in outcome_list: |
- test_prefix[test] = "DISABLED_" |
+ prefix = "DISABLED_" |
elif 'FAIL' in outcome_list: |
if 'PASS' in outcome_list: |
- test_prefix[test] = "FLAKY_" |
+ prefix = "FLAKY_" |
else: |
- test_prefix[test] = "FAILS_" |
+ prefix = "FAILS_" |
+ if macro_conditions: |
+ output.write('#if %s\n' % macro_conditions) |
+ output.write('#define MAYBE_%s %s%s\n' % (test, prefix, test)) |
+ output.write('#elif !defined(MAYBE_%s)\n' % test) |
+ output.write('#define MAYBE_%s %s\n' % (test, test)) |
+ output.write('#endif\n') |
+ test_prefix[test] = 'MAYBE_' |
+ else: |
+ test_prefix[test] = prefix |
test_expectations.close() |
- output = open(OUTPUT_FILE, "w") |
- output.write(COPYRIGHT) |
- output.write(WARNING) |
- output.write(HEADER_GUARD) |
- |
unparsed_files = [INPUT_FILE] |
while unparsed_files: |
filename = unparsed_files.pop(0) |