Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit 3bb8174

Browse files
tjfontaineorangemocha
authored andcommitted
test: refactor to use common testcfg
PR-URL: #25686 Reviewed-By: Julien Gilli <[email protected]>
1 parent d103d4e commit 3bb8174

File tree

5 files changed

+152
-519
lines changed

5 files changed

+152
-519
lines changed

test/gc/testcfg.py

Lines changed: 4 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,6 @@
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
1314

1325
def GetConfiguration(context, root):
133-
return GCTestConfiguration(context, root)
6+
return testpy.SimpleTestConfiguration(context, root, 'gc', ['--expose-gc'])

test/internet/testcfg.py

Lines changed: 4 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,6 @@
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 InternetTestCase(test.TestCase):
43-
44-
def __init__(self, path, file, mode, context, config):
45-
super(InternetTestCase, 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 += [self.file]
96-
return result
97-
98-
def GetSource(self):
99-
return open(self.file).read()
100-
101-
102-
class InternetTestConfiguration(test.TestConfiguration):
103-
104-
def __init__(self, context, root):
105-
super(InternetTestConfiguration, self).__init__(context, root)
106-
107-
def Ls(self, path):
108-
def SelectTest(name):
109-
return name.startswith('test-') and name.endswith('.js')
110-
return [f[:-3] for f in os.listdir(path) if SelectTest(f)]
111-
112-
def ListTests(self, current_path, path, mode):
113-
all_tests = [current_path + [t] for t in self.Ls(join(self.root))]
114-
result = []
115-
for test in all_tests:
116-
if self.Contains(path, test):
117-
file_path = join(self.root, reduce(join, test[1:], "") + ".js")
118-
result.append(InternetTestCase(test, file_path, mode, self.context, self))
119-
return result
120-
121-
def GetBuildRequirements(self):
122-
return ['sample', 'sample=shell']
123-
124-
def GetTestStatus(self, sections, defs):
125-
status_file = join(self.root, 'simple.status')
126-
if exists(status_file):
127-
test.ReadConfigurationInto(status_file, sections, defs)
128-
129-
1+
import sys, os
2+
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
3+
import testpy
1304

1315
def GetConfiguration(context, root):
132-
return InternetTestConfiguration(context, root)
6+
return testpy.SimpleTestConfiguration(context, root, 'internet')

0 commit comments

Comments
 (0)