Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: Tools/Scripts/webkitpy/w3c/test_parser_unittest.py

Issue 16171009: switch import-w3c-tests from using print statements to logging (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: clean up paths a bit Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions 6 # modification, are permitted provided that the following conditions
7 # are met: 7 # are met:
8 # 8 #
9 # 1. Redistributions of source code must retain the above 9 # 1. Redistributions of source code must retain the above
10 # copyright notice, this list of conditions and the following 10 # copyright notice, this list of conditions and the following
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 <link rel="match" href="orange-box-ref.xht" /> 62 <link rel="match" href="orange-box-ref.xht" />
63 </head> 63 </head>
64 """ 64 """
65 oc = OutputCapture() 65 oc = OutputCapture()
66 oc.capture_output() 66 oc.capture_output()
67 try: 67 try:
68 test_path = '/some/madeup/path/' 68 test_path = '/some/madeup/path/'
69 parser = TestParser(options, test_path + 'somefile.html') 69 parser = TestParser(options, test_path + 'somefile.html')
70 test_info = parser.analyze_test(test_contents=test_html) 70 test_info = parser.analyze_test(test_contents=test_html)
71 finally: 71 finally:
72 output, _, _ = oc.restore_output() 72 _, _, logs = oc.restore_output()
73 73
74 self.assertNotEqual(test_info, None, 'did not find a test') 74 self.assertNotEqual(test_info, None, 'did not find a test')
75 self.assertTrue('test' in test_info.keys(), 'did not find a test file') 75 self.assertTrue('test' in test_info.keys(), 'did not find a test file')
76 self.assertTrue('reference' in test_info.keys(), 'did not find a referen ce file') 76 self.assertTrue('reference' in test_info.keys(), 'did not find a referen ce file')
77 self.assertTrue(test_info['reference'].startswith(test_path), 'reference path is not correct') 77 self.assertTrue(test_info['reference'].startswith(test_path), 'reference path is not correct')
78 self.assertFalse('refsupport' in test_info.keys(), 'there should be no r efsupport files for this test') 78 self.assertFalse('refsupport' in test_info.keys(), 'there should be no r efsupport files for this test')
79 self.assertFalse('jstest' in test_info.keys(), 'test should not have bee n analyzed as a jstest') 79 self.assertFalse('jstest' in test_info.keys(), 'test should not have bee n analyzed as a jstest')
80 80
81 self.assertTrue(output.startswith('Warning'), 'no warning about multiple matches') 81 self.assertEqual(logs, 'Multiple references are not supported. Importing the first ref defined in somefile.html\n')
82 82
83 def test_analyze_test_reftest_match_and_mismatch(self): 83 def test_analyze_test_reftest_match_and_mismatch(self):
84 test_html = """<head> 84 test_html = """<head>
85 <link rel="match" href="green-box-ref.xht" /> 85 <link rel="match" href="green-box-ref.xht" />
86 <link rel="match" href="blue-box-ref.xht" /> 86 <link rel="match" href="blue-box-ref.xht" />
87 <link rel="mismatch" href="orange-box-notref.xht" /> 87 <link rel="mismatch" href="orange-box-notref.xht" />
88 </head> 88 </head>
89 """ 89 """
90 oc = OutputCapture() 90 oc = OutputCapture()
91 oc.capture_output() 91 oc.capture_output()
92 92
93 try: 93 try:
94 test_path = '/some/madeup/path/' 94 test_path = '/some/madeup/path/'
95 parser = TestParser(options, test_path + 'somefile.html') 95 parser = TestParser(options, test_path + 'somefile.html')
96 test_info = parser.analyze_test(test_contents=test_html) 96 test_info = parser.analyze_test(test_contents=test_html)
97 finally: 97 finally:
98 output, _, _ = oc.restore_output() 98 _, _, logs = oc.restore_output()
99 99
100 self.assertNotEqual(test_info, None, 'did not find a test') 100 self.assertNotEqual(test_info, None, 'did not find a test')
101 self.assertTrue('test' in test_info.keys(), 'did not find a test file') 101 self.assertTrue('test' in test_info.keys(), 'did not find a test file')
102 self.assertTrue('reference' in test_info.keys(), 'did not find a referen ce file') 102 self.assertTrue('reference' in test_info.keys(), 'did not find a referen ce file')
103 self.assertTrue(test_info['reference'].startswith(test_path), 'reference path is not correct') 103 self.assertTrue(test_info['reference'].startswith(test_path), 'reference path is not correct')
104 self.assertFalse('refsupport' in test_info.keys(), 'there should be no r efsupport files for this test') 104 self.assertFalse('refsupport' in test_info.keys(), 'there should be no r efsupport files for this test')
105 self.assertFalse('jstest' in test_info.keys(), 'test should not have bee n analyzed as a jstest') 105 self.assertFalse('jstest' in test_info.keys(), 'test should not have bee n analyzed as a jstest')
106 106
107 warnings = output.splitlines() 107 self.assertEqual(logs, 'Multiple references are not supported. Importing the first ref defined in somefile.html\n')
108 self.assertEquals(warnings, ["Warning: Webkit does not support multiple references. Importing the first ref defined in somefile.html"])
109 108
110 def test_analyze_test_reftest_with_ref_support_Files(self): 109 def test_analyze_test_reftest_with_ref_support_Files(self):
111 """ Tests analyze_test() using a reftest that has refers to a reference file outside of the tests directory and the reference file has paths to other su pport files """ 110 """ Tests analyze_test() using a reftest that has refers to a reference file outside of the tests directory and the reference file has paths to other su pport files """
112 111
113 test_html = """<html> 112 test_html = """<html>
114 <head> 113 <head>
115 <link rel="match" href="../reference/green-box-ref.xht" /> 114 <link rel="match" href="../reference/green-box-ref.xht" />
116 </head> 115 </head>
117 """ 116 """
118 ref_html = """<head> 117 ref_html = """<head>
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 test_info = parser.analyze_test(test_contents=test_html) 208 test_info = parser.analyze_test(test_contents=test_html)
210 209
211 self.assertEqual(test_info, None, 'test should have been skipped') 210 self.assertEqual(test_info, None, 'test should have been skipped')
212 211
213 def test_analyze_non_html_file(self): 212 def test_analyze_non_html_file(self):
214 """ Tests analyze_test() with a file that has no html""" 213 """ Tests analyze_test() with a file that has no html"""
215 # FIXME: use a mock filesystem 214 # FIXME: use a mock filesystem
216 parser = TestParser(options, os.path.join(os.path.dirname(__file__), 'te st_parser.py')) 215 parser = TestParser(options, os.path.join(os.path.dirname(__file__), 'te st_parser.py'))
217 test_info = parser.analyze_test() 216 test_info = parser.analyze_test()
218 self.assertEqual(test_info, None, 'no tests should have been found in th is file') 217 self.assertEqual(test_info, None, 'no tests should have been found in th is file')
OLDNEW
« Tools/Scripts/webkitpy/w3c/test_importer.py ('K') | « Tools/Scripts/webkitpy/w3c/test_parser.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698