testcfg.py 1.98 KB
Newer Older
1 2 3 4 5 6 7 8
# 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

from testrunner.local import testsuite
from testrunner.local import utils
9
from testrunner.objects import testcase
10
from testrunner.outproc import base as outproc
11 12 13

PROTOCOL_TEST_JS = "protocol-test.js"
EXPECTED_SUFFIX = "-expected.txt"
14
RESOURCES_FOLDER = "resources"
15

16
class TestSuite(testsuite.TestSuite):
17
  def ListTests(self):
18
    tests = []
19 20
    for dirname, dirs, files in os.walk(
        os.path.join(self.root), followlinks=True):
21 22
      for dotted in [x for x in dirs if x.startswith('.')]:
        dirs.remove(dotted)
23 24
      if dirname.endswith(os.path.sep + RESOURCES_FOLDER):
        continue
25 26 27 28 29 30 31
      dirs.sort()
      files.sort()
      for filename in files:
        if filename.endswith(".js") and filename != PROTOCOL_TEST_JS:
          fullpath = os.path.join(dirname, filename)
          relpath = fullpath[len(self.root) + 1 : -3]
          testname = relpath.replace(os.path.sep, "/")
32
          test = self._create_test(testname)
33 34 35
          tests.append(test)
    return tests

36
  def _test_class(self):
37
    return TestCase
38

39

40
class TestCase(testcase.TestCase):
41
  def __init__(self, *args, **kwargs):
42
    super(TestCase, self).__init__(*args, **kwargs)
43 44 45

    self._source_flags = self._parse_source_flags()

46
  def _get_files_params(self):
47 48 49 50 51 52 53 54 55 56 57
    return [
      os.path.join(self.suite.root, PROTOCOL_TEST_JS),
      os.path.join(self.suite.root, self.path + self._get_suffix()),
    ]

  def _get_source_flags(self):
    return self._source_flags

  def _get_source_path(self):
    return os.path.join(self.suite.root, self.path + self._get_suffix())

58
  def get_shell(self):
59 60
    return 'inspector-test'

61 62
  @property
  def output_proc(self):
63 64 65
    return outproc.ExpectedOutProc(
        self.expected_outcomes,
        os.path.join(self.suite.root, self.path) + EXPECTED_SUFFIX)
66

67

68 69
def GetSuite(*args, **kwargs):
  return TestSuite(*args, **kwargs)