• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
6import os
7import sys
8import unittest
9
10# Needed because the test runner contains relative imports.
11TOOLS_PATH = os.path.dirname(os.path.dirname(os.path.dirname(
12    os.path.abspath(__file__))))
13sys.path.append(TOOLS_PATH)
14
15from testrunner.local.testsuite import TestSuite
16from testrunner.objects.testcase import TestCase
17
18
19class TestSuiteTest(unittest.TestCase):
20  def test_filter_testcases_by_status_first_pass(self):
21    suite = TestSuite('foo', 'bar')
22    suite.rules = {
23      '': {
24        'foo/bar': set(['PASS', 'SKIP']),
25        'baz/bar': set(['PASS', 'FAIL']),
26      },
27    }
28    suite.prefix_rules = {
29      '': {
30        'baz/': set(['PASS', 'SLOW']),
31      },
32    }
33    suite.tests = [
34      TestCase(suite, 'foo/bar', 'foo/bar'),
35      TestCase(suite, 'baz/bar', 'baz/bar'),
36    ]
37    suite.FilterTestCasesByStatus()
38    self.assertEquals(
39        [TestCase(suite, 'baz/bar', 'baz/bar')],
40        suite.tests,
41    )
42    outcomes = suite.GetStatusFileOutcomes(suite.tests[0].name,
43                                           suite.tests[0].variant)
44    self.assertEquals(set(['PASS', 'FAIL', 'SLOW']), outcomes)
45
46  def test_filter_testcases_by_status_second_pass(self):
47    suite = TestSuite('foo', 'bar')
48
49    suite.rules = {
50      '': {
51        'foo/bar': set(['PREV']),
52      },
53      'default': {
54        'foo/bar': set(['PASS', 'SKIP']),
55        'baz/bar': set(['PASS', 'FAIL']),
56      },
57      'stress': {
58        'baz/bar': set(['SKIP']),
59      },
60    }
61    suite.prefix_rules = {
62      '': {
63        'baz/': set(['PREV']),
64      },
65      'default': {
66        'baz/': set(['PASS', 'SLOW']),
67      },
68      'stress': {
69        'foo/': set(['PASS', 'SLOW']),
70      },
71    }
72
73    test1 = TestCase(suite, 'foo/bar', 'foo/bar')
74    test2 = TestCase(suite, 'baz/bar', 'baz/bar')
75    suite.tests = [
76      test1.create_variant(variant='default', flags=[]),
77      test1.create_variant(variant='stress', flags=['-v']),
78      test2.create_variant(variant='default', flags=[]),
79      test2.create_variant(variant='stress', flags=['-v']),
80    ]
81
82    suite.FilterTestCasesByStatus()
83    self.assertEquals(
84        [
85          TestCase(suite, 'foo/bar', 'foo/bar').create_variant(None, ['-v']),
86          TestCase(suite, 'baz/bar', 'baz/bar'),
87        ],
88        suite.tests,
89    )
90
91    self.assertEquals(
92        set(['PREV', 'PASS', 'SLOW']),
93        suite.GetStatusFileOutcomes(suite.tests[0].name,
94                                    suite.tests[0].variant),
95    )
96    self.assertEquals(
97        set(['PREV', 'PASS', 'FAIL', 'SLOW']),
98        suite.GetStatusFileOutcomes(suite.tests[1].name,
99                                    suite.tests[1].variant),
100    )
101
102  def test_fail_ok_outcome(self):
103    suite = TestSuite('foo', 'bar')
104    suite.rules = {
105      '': {
106        'foo/bar': set(['FAIL_OK']),
107        'baz/bar': set(['FAIL']),
108      },
109    }
110    suite.prefix_rules = {}
111    suite.tests = [
112      TestCase(suite, 'foo/bar', 'foo/bar'),
113      TestCase(suite, 'baz/bar', 'baz/bar'),
114    ]
115
116    for t in suite.tests:
117      self.assertEquals(['FAIL'], t.expected_outcomes)
118
119
120if __name__ == '__main__':
121    unittest.main()
122