1 #!/usr/bin/env python 2 # Copyright 2016 the V8 project 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. 5 6 import os 7 import sys 8 import unittest 9 10 # Needed because the test runner contains relative imports. 11 TOOLS_PATH = os.path.dirname(os.path.dirname(os.path.dirname( 12 os.path.abspath(__file__)))) 13 sys.path.append(TOOLS_PATH) 14 15 from testrunner.local.testsuite import TestSuite 16 from testrunner.objects.testcase import TestCase 17 18 19 class TestSuiteTest(unittest.TestCase): 20 def test_filter_testcases_by_status_first_pass(self): 21 suite = TestSuite('foo', 'bar') 22 suite.tests = [ 23 TestCase(suite, 'foo/bar'), 24 TestCase(suite, 'baz/bar'), 25 ] 26 suite.rules = { 27 '': { 28 'foo/bar': set(['PASS', 'SKIP']), 29 'baz/bar': set(['PASS', 'FAIL']), 30 }, 31 } 32 suite.wildcards = { 33 '': { 34 'baz/*': set(['PASS', 'SLOW']), 35 }, 36 } 37 suite.FilterTestCasesByStatus(warn_unused_rules=False) 38 self.assertEquals( 39 [TestCase(suite, 'baz/bar')], 40 suite.tests, 41 ) 42 self.assertEquals(set(['PASS', 'FAIL', 'SLOW']), suite.tests[0].outcomes) 43 44 def test_filter_testcases_by_status_second_pass(self): 45 suite = TestSuite('foo', 'bar') 46 47 test1 = TestCase(suite, 'foo/bar') 48 test2 = TestCase(suite, 'baz/bar') 49 50 # Contrived outcomes from filtering by variant-independent rules. 51 test1.outcomes = set(['PREV']) 52 test2.outcomes = set(['PREV']) 53 54 suite.tests = [ 55 test1.CopyAddingFlags(variant='default', flags=[]), 56 test1.CopyAddingFlags(variant='stress', flags=['-v']), 57 test2.CopyAddingFlags(variant='default', flags=[]), 58 test2.CopyAddingFlags(variant='stress', flags=['-v']), 59 ] 60 61 suite.rules = { 62 'default': { 63 'foo/bar': set(['PASS', 'SKIP']), 64 'baz/bar': set(['PASS', 'FAIL']), 65 }, 66 'stress': { 67 'baz/bar': set(['SKIP']), 68 }, 69 } 70 suite.wildcards = { 71 'default': { 72 'baz/*': set(['PASS', 'SLOW']), 73 }, 74 'stress': { 75 'foo/*': set(['PASS', 'SLOW']), 76 }, 77 } 78 suite.FilterTestCasesByStatus(warn_unused_rules=False, variants=True) 79 self.assertEquals( 80 [ 81 TestCase(suite, 'foo/bar', flags=['-v']), 82 TestCase(suite, 'baz/bar'), 83 ], 84 suite.tests, 85 ) 86 87 self.assertEquals( 88 set(['PASS', 'SLOW', 'PREV']), 89 suite.tests[0].outcomes, 90 ) 91 self.assertEquals( 92 set(['PASS', 'FAIL', 'SLOW', 'PREV']), 93 suite.tests[1].outcomes, 94 ) 95 96 97 if __name__ == '__main__': 98 unittest.main() 99