193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# 393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# Redistribution and use in source and binary forms, with or without 493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# modification, are permitted provided that the following conditions 593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# are met: 693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# 793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# 1. Redistributions of source code must retain the above 893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# copyright notice, this list of conditions and the following 993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# disclaimer. 1093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# 2. Redistributions in binary form must reproduce the above 1193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# copyright notice, this list of conditions and the following 1293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# disclaimer in the documentation and/or other materials 1393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# provided with the distribution. 1493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# 1593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY 1693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 1893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE 1993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 2093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 2293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 2493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 2593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)# SUCH DAMAGE. 2793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 2893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)import os 29e38fbeeb576b5094e34e038ab88d9d6a5c5c2214Torne (Richard Coles)import unittest 3093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 3193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)from webkitpy.common.system.outputcapture import OutputCapture 3293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)from webkitpy.w3c.test_parser import TestParser 3393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 3493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 3593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)options = {'all': False, 'no_overwrite': False} 3693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 3793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 3893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)class TestParserTest(unittest.TestCase): 3993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 4093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) def test_analyze_test_reftest_one_match(self): 4193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_html = """<head> 4293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<link rel="match" href="green-box-ref.xht" /> 4393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)</head> 4493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)""" 4593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_path = '/some/madeup/path/' 4693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) parser = TestParser(options, test_path + 'somefile.html') 4793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_info = parser.analyze_test(test_contents=test_html) 4893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 4993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertNotEqual(test_info, None, 'did not find a test') 5093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertTrue('test' in test_info.keys(), 'did not find a test file') 5193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertTrue('reference' in test_info.keys(), 'did not find a reference file') 5293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertTrue(test_info['reference'].startswith(test_path), 'reference path is not correct') 5393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test') 5493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertFalse('jstest' in test_info.keys(), 'test should not have been analyzed as a jstest') 5593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 5693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) def test_analyze_test_reftest_multiple_matches(self): 5793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_html = """<head> 5893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<link rel="match" href="green-box-ref.xht" /> 5993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<link rel="match" href="blue-box-ref.xht" /> 6093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<link rel="match" href="orange-box-ref.xht" /> 6193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)</head> 6293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)""" 6393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) oc = OutputCapture() 6493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) oc.capture_output() 6593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) try: 6693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_path = '/some/madeup/path/' 6793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) parser = TestParser(options, test_path + 'somefile.html') 6893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_info = parser.analyze_test(test_contents=test_html) 6993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) finally: 7093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) _, _, logs = oc.restore_output() 7193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 7293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertNotEqual(test_info, None, 'did not find a test') 7393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertTrue('test' in test_info.keys(), 'did not find a test file') 7493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertTrue('reference' in test_info.keys(), 'did not find a reference file') 7593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertTrue(test_info['reference'].startswith(test_path), 'reference path is not correct') 7693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test') 7793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertFalse('jstest' in test_info.keys(), 'test should not have been analyzed as a jstest') 7893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 7993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertEqual(logs, 'Multiple references are not supported. Importing the first ref defined in somefile.html\n') 8093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 8193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) def test_analyze_test_reftest_match_and_mismatch(self): 8293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_html = """<head> 8393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<link rel="match" href="green-box-ref.xht" /> 8493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<link rel="match" href="blue-box-ref.xht" /> 8593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<link rel="mismatch" href="orange-box-notref.xht" /> 8693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)</head> 8793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)""" 8893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) oc = OutputCapture() 8993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) oc.capture_output() 9093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 9193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) try: 9293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_path = '/some/madeup/path/' 9393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) parser = TestParser(options, test_path + 'somefile.html') 9493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_info = parser.analyze_test(test_contents=test_html) 9593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) finally: 9693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) _, _, logs = oc.restore_output() 9793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 9893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertNotEqual(test_info, None, 'did not find a test') 9993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertTrue('test' in test_info.keys(), 'did not find a test file') 10093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertTrue('reference' in test_info.keys(), 'did not find a reference file') 10193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertTrue(test_info['reference'].startswith(test_path), 'reference path is not correct') 10293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test') 10393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertFalse('jstest' in test_info.keys(), 'test should not have been analyzed as a jstest') 10493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 10593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertEqual(logs, 'Multiple references are not supported. Importing the first ref defined in somefile.html\n') 10693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 10793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) def test_analyze_test_reftest_with_ref_support_Files(self): 10893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) """ 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 support files """ 10993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 11093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_html = """<html> 11193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<head> 11293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<link rel="match" href="../reference/green-box-ref.xht" /> 11393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)</head> 11493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)""" 11593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) ref_html = """<head> 11693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<link href="support/css/ref-stylesheet.css" rel="stylesheet" type="text/css"> 11793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<style type="text/css"> 11893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) background-image: url("../../support/some-image.png") 11993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)</style> 12093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)</head> 12193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<body> 12293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<div><img src="../support/black96x96.png" alt="Image download support must be enabled" /></div> 12393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)</body> 12493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)</html> 12593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)""" 12693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_path = '/some/madeup/path/' 12793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) parser = TestParser(options, test_path + 'somefile.html') 12893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_info = parser.analyze_test(test_contents=test_html, ref_contents=ref_html) 12993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 13093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertNotEqual(test_info, None, 'did not find a test') 13193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertTrue('test' in test_info.keys(), 'did not find a test file') 13293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertTrue('reference' in test_info.keys(), 'did not find a reference file') 13393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertTrue(test_info['reference'].startswith(test_path), 'reference path is not correct') 13493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertTrue('refsupport' in test_info.keys(), 'there should be refsupport files for this test') 13593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertEquals(len(test_info['refsupport']), 3, 'there should be 3 support files in this reference') 13693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertFalse('jstest' in test_info.keys(), 'test should not have been analyzed as a jstest') 13793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 13893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) def test_analyze_jstest(self): 13993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) """ Tests analyze_test() using a jstest """ 14093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 14193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_html = """<head> 14293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<link href="/resources/testharness.css" rel="stylesheet" type="text/css"> 14393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<script src="/resources/testharness.js"></script> 14493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)</head> 14593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)""" 14693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_path = '/some/madeup/path/' 14793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) parser = TestParser(options, test_path + 'somefile.html') 14893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_info = parser.analyze_test(test_contents=test_html) 14993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 15093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertNotEqual(test_info, None, 'test_info is None') 15193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertTrue('test' in test_info.keys(), 'did not find a test file') 15293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertFalse('reference' in test_info.keys(), 'shold not have found a reference file') 15393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test') 15493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertTrue('jstest' in test_info.keys(), 'test should be a jstest') 15593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 15693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) def test_analyze_pixel_test_all_true(self): 15793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) """ Tests analyze_test() using a test that is neither a reftest or jstest with all=False """ 15893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 15993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_html = """<html> 16093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<head> 16193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<title>CSS Test: DESCRIPTION OF TEST</title> 16293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<link rel="author" title="NAME_OF_AUTHOR" /> 16393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<style type="text/css"><![CDATA[ 16493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)CSS FOR TEST 16593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)]]></style> 16693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)</head> 16793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<body> 16893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)CONTENT OF TEST 16993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)</body> 17093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)</html> 17193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)""" 17293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) # Set options to 'all' so this gets found 17393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) options['all'] = True 17493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 17593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_path = '/some/madeup/path/' 17693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) parser = TestParser(options, test_path + 'somefile.html') 17793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_info = parser.analyze_test(test_contents=test_html) 17893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 17993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertNotEqual(test_info, None, 'test_info is None') 18093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertTrue('test' in test_info.keys(), 'did not find a test file') 18193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertFalse('reference' in test_info.keys(), 'shold not have found a reference file') 18293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertFalse('refsupport' in test_info.keys(), 'there should be no refsupport files for this test') 18393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertFalse('jstest' in test_info.keys(), 'test should not be a jstest') 18493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 18593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) def test_analyze_pixel_test_all_false(self): 18693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) """ Tests analyze_test() using a test that is neither a reftest or jstest, with -all=False """ 18793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 18893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_html = """<html> 18993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<head> 19093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<title>CSS Test: DESCRIPTION OF TEST</title> 19193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<link rel="author" title="NAME_OF_AUTHOR" /> 19293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<style type="text/css"><![CDATA[ 19393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)CSS FOR TEST 19493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)]]></style> 19593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)</head> 19693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)<body> 19793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)CONTENT OF TEST 19893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)</body> 19993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)</html> 20093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)""" 20193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) # Set all to false so this gets skipped 20293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) options['all'] = False 20393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 20493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_path = '/some/madeup/path/' 20593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) parser = TestParser(options, test_path + 'somefile.html') 20693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_info = parser.analyze_test(test_contents=test_html) 20793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 20893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertEqual(test_info, None, 'test should have been skipped') 20993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) 21093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) def test_analyze_non_html_file(self): 21193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) """ Tests analyze_test() with a file that has no html""" 21293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) # FIXME: use a mock filesystem 21393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) parser = TestParser(options, os.path.join(os.path.dirname(__file__), 'test_parser.py')) 21493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) test_info = parser.analyze_test() 21593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) self.assertEqual(test_info, None, 'no tests should have been found in this file') 216