1 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 import unittest 6 7 from webkitpy.layout_tests.models import testharness_results 8 9 10 class TestHarnessResultCheckerTest(unittest.TestCase): 11 12 def test_is_testharness_output(self): 13 test_data = [ 14 {'content': 'foo', 'result': False}, 15 {'content': '', 'result': False}, 16 {'content': ' ', 'result': False}, 17 {'content': 'This is a testharness.js-based test.\nHarness: the test ran to completion.', 'result': True}, 18 {'content': '\n \r This is a testharness.js-based test. \n \r \n \rHarness: the test ran to completion. \n\n', 'result': True}, 19 {'content': ' This \nis a testharness.js-based test.\nHarness: the test ran to completion.', 'result': False}, 20 {'content': 'This is a testharness.js-based test. Harness: the test ran to completion.', 'result': False}, 21 {'content': 'This is a testharness.js-based test.\nFoo bar \n Harness: the test ran to completion.', 'result': True}, 22 {'content': 'This is a testharness.js-based test.\nFAIL: bah \n Harness: the test ran to completion.\n\n\n', 'result': True}, 23 ] 24 25 for data in test_data: 26 self.assertEqual(data['result'], testharness_results.is_testharness_output(data['content'])) 27 28 def test_is_testharness_output_passing(self): 29 test_data = [ 30 {'content': 'This is a testharness.js-based test.\n Harness: the test ran to completion.', 'result': True}, 31 {'content': 'This is a testharness.js-based test.\n \n Harness: the test ran to completion.', 'result': False}, 32 {'content': 'This is a testharness.js-based test.\n PASS: foo bar \n Harness: the test ran to completion.', 'result': True}, 33 {'content': 'This is a testharness.js-based test.\n PASS: foo bar FAIL \n Harness: the test ran to completion.', 'result': True}, 34 {'content': 'This is a testharness.js-based test.\n PASS: foo bar \nFAIL \n Harness: the test ran to completion.', 'result': False}, 35 {'content': 'This is a testharness.js-based test.\n CONSOLE ERROR: BLAH \n Harness: the test ran to completion.', 'result': True}, 36 {'content': 'This is a testharness.js-based test.\n Foo bar \n Harness: the test ran to completion.', 'result': False}, 37 {'content': 'This is a testharness.js-based test.\n FAIL: bah \n Harness: the test ran to completion.', 'result': False}, 38 {'content': 'This is a testharness.js-based test.\n TIMEOUT: bah \n Harness: the test ran to completion.', 'result': False}, 39 {'content': 'This is a testharness.js-based test.\n NOTRUN: bah \n Harness: the test ran to completion.', 'result': False}, 40 {'content': 'CONSOLE LOG: error.\nThis is a testharness.js-based test.\nPASS: things are fine.\nHarness: the test ran to completion.\n\n', 'result': True}, 41 {'content': 'CONSOLE ERROR: error.\nThis is a testharness.js-based test.\nPASS: things are fine.\nHarness: the test ran to completion.\n\n', 'result': True}, 42 {'content': 'RANDOM TEXT.\nThis is a testharness.js-based test.\nPASS: things are fine.\n.Harness: the test ran to completion.\n\n', 'result': False}, 43 ] 44 45 for data in test_data: 46 self.assertEqual(data['result'], testharness_results.is_testharness_output_passing(data['content'])) 47