summaryrefslogtreecommitdiff
path: root/deps/v8/tools/testrunner/local/testsuite_unittest.py
blob: a8483b9fc0a7437815e5c0e4c9902988143723b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env python
# Copyright 2016 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os
import sys
import unittest

# Needed because the test runner contains relative imports.
TOOLS_PATH = os.path.dirname(os.path.dirname(os.path.dirname(
    os.path.abspath(__file__))))
sys.path.append(TOOLS_PATH)

from testrunner.local.testsuite import TestSuite
from testrunner.objects.testcase import TestCase


class TestSuiteTest(unittest.TestCase):
  def test_filter_testcases_by_status_first_pass(self):
    suite = TestSuite('foo', 'bar')
    suite.tests = [
      TestCase(suite, 'foo/bar'),
      TestCase(suite, 'baz/bar'),
    ]
    suite.rules = {
      '': {
        'foo/bar': set(['PASS', 'SKIP']),
        'baz/bar': set(['PASS', 'FAIL']),
      },
    }
    suite.prefix_rules = {
      '': {
        'baz/': set(['PASS', 'SLOW']),
      },
    }
    suite.FilterTestCasesByStatus()
    self.assertEquals(
        [TestCase(suite, 'baz/bar')],
        suite.tests,
    )
    outcomes = suite.GetStatusFileOutcomes(suite.tests[0])
    self.assertEquals(set(['PASS', 'FAIL', 'SLOW']), outcomes)

  def test_filter_testcases_by_status_second_pass(self):
    suite = TestSuite('foo', 'bar')

    test1 = TestCase(suite, 'foo/bar')
    test2 = TestCase(suite, 'baz/bar')

    suite.tests = [
      test1.CopyAddingFlags(variant='default', flags=[]),
      test1.CopyAddingFlags(variant='stress', flags=['-v']),
      test2.CopyAddingFlags(variant='default', flags=[]),
      test2.CopyAddingFlags(variant='stress', flags=['-v']),
    ]

    suite.rules = {
      '': {
        'foo/bar': set(['PREV']),
      },
      'default': {
        'foo/bar': set(['PASS', 'SKIP']),
        'baz/bar': set(['PASS', 'FAIL']),
      },
      'stress': {
        'baz/bar': set(['SKIP']),
      },
    }
    suite.prefix_rules = {
      '': {
        'baz/': set(['PREV']),
      },
      'default': {
        'baz/': set(['PASS', 'SLOW']),
      },
      'stress': {
        'foo/': set(['PASS', 'SLOW']),
      },
    }
    suite.FilterTestCasesByStatus()
    self.assertEquals(
        [
          TestCase(suite, 'foo/bar', flags=['-v']),
          TestCase(suite, 'baz/bar'),
        ],
        suite.tests,
    )

    self.assertEquals(
        set(['PREV', 'PASS', 'SLOW']),
        suite.GetStatusFileOutcomes(suite.tests[0]),
    )
    self.assertEquals(
        set(['PREV', 'PASS', 'FAIL', 'SLOW']),
        suite.GetStatusFileOutcomes(suite.tests[1]),
    )

  def test_fail_ok_outcome(self):
    suite = TestSuite('foo', 'bar')
    suite.tests = [
      TestCase(suite, 'foo/bar'),
      TestCase(suite, 'baz/bar'),
    ]
    suite.rules = {
      '': {
        'foo/bar': set(['FAIL_OK']),
        'baz/bar': set(['FAIL']),
      },
    }
    suite.prefix_rules = {}

    for t in suite.tests:
      expected_outcomes = suite.GetExpectedOutcomes(t)
      self.assertEquals(['FAIL'], expected_outcomes)


if __name__ == '__main__':
    unittest.main()