|
1 | | -# Copyright 2008 the V8 project authors. All rights reserved. |
2 | | -# Redistribution and use in source and binary forms, with or without |
3 | | -# modification, are permitted provided that the following conditions are |
4 | | -# met: |
5 | | -# |
6 | | -# * Redistributions of source code must retain the above copyright |
7 | | -# notice, this list of conditions and the following disclaimer. |
8 | | -# * Redistributions in binary form must reproduce the above |
9 | | -# copyright notice, this list of conditions and the following |
10 | | -# disclaimer in the documentation and/or other materials provided |
11 | | -# with the distribution. |
12 | | -# * Neither the name of Google Inc. nor the names of its |
13 | | -# contributors may be used to endorse or promote products derived |
14 | | -# from this software without specific prior written permission. |
15 | | -# |
16 | | -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 | | -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 | | -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 | | -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 | | -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 | | -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 | | -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | | -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | | -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | | -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 | | -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | | - |
28 | | -import test |
29 | | -import os |
30 | | -import shutil |
31 | | -from shutil import rmtree |
32 | | -from os import mkdir |
33 | | -from glob import glob |
34 | | -from os.path import join, dirname, exists |
35 | | -import re |
36 | | - |
37 | | - |
38 | | -FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") |
39 | | -FILES_PATTERN = re.compile(r"//\s+Files:(.*)") |
40 | | - |
41 | | - |
42 | | -class GCTestCase(test.TestCase): |
43 | | - |
44 | | - def __init__(self, path, file, mode, context, config): |
45 | | - super(GCTestCase, self).__init__(context, path, mode) |
46 | | - self.file = file |
47 | | - self.config = config |
48 | | - self.mode = mode |
49 | | - self.tmpdir = join(dirname(self.config.root), 'tmp') |
50 | | - |
51 | | - def AfterRun(self, result): |
52 | | - # delete the whole tmp dir |
53 | | - try: |
54 | | - rmtree(self.tmpdir) |
55 | | - except: |
56 | | - pass |
57 | | - # make it again. |
58 | | - try: |
59 | | - mkdir(self.tmpdir) |
60 | | - except: |
61 | | - pass |
62 | | - |
63 | | - def BeforeRun(self): |
64 | | - # delete the whole tmp dir |
65 | | - try: |
66 | | - rmtree(self.tmpdir) |
67 | | - except: |
68 | | - pass |
69 | | - # make it again. |
70 | | - # intermittently fails on win32, so keep trying |
71 | | - while not os.path.exists(self.tmpdir): |
72 | | - try: |
73 | | - mkdir(self.tmpdir) |
74 | | - except: |
75 | | - pass |
76 | | - |
77 | | - def GetLabel(self): |
78 | | - return "%s %s" % (self.mode, self.GetName()) |
79 | | - |
80 | | - def GetName(self): |
81 | | - return self.path[-1] |
82 | | - |
83 | | - def GetCommand(self): |
84 | | - result = [self.config.context.GetVm(self.mode)] |
85 | | - source = open(self.file).read() |
86 | | - flags_match = FLAGS_PATTERN.search(source) |
87 | | - if flags_match: |
88 | | - result += flags_match.group(1).strip().split() |
89 | | - files_match = FILES_PATTERN.search(source); |
90 | | - additional_files = [] |
91 | | - if files_match: |
92 | | - additional_files += files_match.group(1).strip().split() |
93 | | - for a_file in additional_files: |
94 | | - result.append(join(dirname(self.config.root), '..', a_file)) |
95 | | - result += ["--expose-gc"] |
96 | | - result += [self.file] |
97 | | - return result |
98 | | - |
99 | | - def GetSource(self): |
100 | | - return open(self.file).read() |
101 | | - |
102 | | - |
103 | | -class GCTestConfiguration(test.TestConfiguration): |
104 | | - |
105 | | - def __init__(self, context, root): |
106 | | - super(GCTestConfiguration, self).__init__(context, root) |
107 | | - |
108 | | - def Ls(self, path): |
109 | | - def SelectTest(name): |
110 | | - return name.startswith('test-') and name.endswith('.js') |
111 | | - return [f[:-3] for f in os.listdir(path) if SelectTest(f)] |
112 | | - |
113 | | - def ListTests(self, current_path, path, mode): |
114 | | - all_tests = [current_path + [t] for t in self.Ls(join(self.root))] |
115 | | - result = [] |
116 | | - for test in all_tests: |
117 | | - if self.Contains(path, test): |
118 | | - file_path = join(self.root, reduce(join, test[1:], "") + ".js") |
119 | | - result.append(GCTestCase(test, file_path, mode, self.context, self)) |
120 | | - return result |
121 | | - |
122 | | - def GetBuildRequirements(self): |
123 | | - return ['sample', 'sample=shell'] |
124 | | - |
125 | | - def GetTestStatus(self, sections, defs): |
126 | | - status_file = join(self.root, 'gc.status') |
127 | | - if exists(status_file): |
128 | | - test.ReadConfigurationInto(status_file, sections, defs) |
129 | | - |
130 | | - |
| 1 | +import sys, os |
| 2 | +sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
| 3 | +import testpy |
131 | 4 |
|
132 | 5 | def GetConfiguration(context, root): |
133 | | - return GCTestConfiguration(context, root) |
| 6 | + return testpy.SimpleTestConfiguration(context, root, 'gc', ['--expose-gc']) |
0 commit comments