testcfg.py 3.77 KB
Newer Older
1
# Copyright 2008 the V8 project authors. All rights reserved.
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
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above
#       copyright notice, this list of conditions and the following
#       disclaimer in the documentation and/or other materials provided
#       with the distribution.
#     * Neither the name of Google Inc. nor the names of its
#       contributors may be used to endorse or promote products derived
#       from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

28 29
# for py2/py3 compatibility
from functools import reduce
30 31

import os
32 33

from testrunner.local import testsuite
34
from testrunner.objects import testcase
35
from testrunner.outproc import mozilla
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
EXCLUDED = [
  "CVS",
  ".svn",
]

FRAMEWORK = [
  "browser.js",
  "shell.js",
  "jsref.js",
  "template.js",
]

TEST_DIRS = [
  "ecma",
  "ecma_2",
  "ecma_3",
  "js1_1",
  "js1_2",
  "js1_3",
  "js1_4",
  "js1_5",
]

class TestLoader(testsuite.JSTestLoader):
  @property
  def excluded_files(self):
    return set(FRAMEWORK)
64

65 66 67
  @property
  def excluded_dirs(self):
    return set(EXCLUDED)
68

69 70 71
  @property
  def test_dirs(self):
    return TEST_DIRS
72

73 74 75
  def _to_relpath(self, abspath, _):
    # TODO: refactor this by setting the test path during the TestCase creation
    return os.path.relpath(abspath, self.test_root)
76 77


78
class TestSuite(testsuite.TestSuite):
79 80
  def __init__(self, *args, **kwargs):
    super(TestSuite, self).__init__(*args, **kwargs)
81 82 83 84 85
    self.test_root = os.path.join(self.root, "data")
    self._test_loader.test_root = self.test_root

  def _test_loader_class(self):
    return TestLoader
86

87
  def _test_class(self):
88
    return TestCase
89 90


91
class TestCase(testcase.D8TestCase):
92
  def _get_files_params(self):
93 94
    files = [os.path.join(self.suite.root, "mozilla-shell-emulation.js")]
    testfilename = self.path + ".js"
95
    testfilepath = testfilename.split(os.path.sep)
96
    for i in range(len(testfilepath)):
97
      script = os.path.join(self.suite.test_root,
98 99 100
                            reduce(os.path.join, testfilepath[:i], ""),
                            "shell.js")
      if os.path.exists(script):
101
        files.append(script)
102

103
    files.append(os.path.join(self.suite.test_root, testfilename))
104
    return files
105

106
  def _get_suite_flags(self):
107
    return ['--expose-gc']
108

109
  def _get_source_path(self):
110
    return os.path.join(self.suite.test_root, self.path + self._get_suffix())
111

112 113
  @property
  def output_proc(self):
114 115
    if not self.expected_outcomes:
      if self.path.endswith('-n'):
116 117
        return mozilla.MOZILLA_PASS_NEGATIVE
      return mozilla.MOZILLA_PASS_DEFAULT
118
    if self.path.endswith('-n'):
119 120
      return mozilla.NegOutProc(self.expected_outcomes)
    return mozilla.OutProc(self.expected_outcomes)
121 122


123 124
def GetSuite(*args, **kwargs):
  return TestSuite(*args, **kwargs)