Skip to content

Commit 1c429a6

Browse files
authored
Speed up test_cgcheck (#1736)
1 parent 0573b67 commit 1c429a6

2 files changed

Lines changed: 26 additions & 15 deletions

File tree

Src/IronPythonTest/Cases/IronPythonCasesManifest.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,6 @@ RunCondition=NOT $(IS_OSX) # ctypes tests not prepared for macOS
184184
[IronPython.scripts.test_builder]
185185
Ignore=true
186186

187-
[IronPython.scripts.test_cgcheck]
188-
Timeout=600000 # 10 minute timeout
189-
190187
[IronPython.scripts.test_parrot]
191188
Ignore=true
192189

Src/Scripts/generate.py

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# The .NET Foundation licenses this file to you under the Apache 2.0 License.
33
# See the LICENSE file in the project root for more information.
44

5+
import functools
56
import re
67
import sys
78
import os
@@ -23,7 +24,8 @@ def get_root_dir():
2324
os.path.join(root_dir, "Src", "StdLib"),
2425
]
2526

26-
START = "#region Generated %s"
27+
START_COMMON = "#region Generated"
28+
START = START_COMMON + " %s"
2729
END = "#endregion"
2830
PREFIX = r"^([ \t]*)"
2931

@@ -131,6 +133,27 @@ def text(self):
131133
def conditions(self):
132134
return ConditionWriter(self)
133135

136+
@functools.lru_cache()
137+
def find_candidates(dirname):
138+
def listdir(dirname):
139+
if dirname in exclude_directories:
140+
return
141+
142+
for file in os.listdir(dirname):
143+
if file == "obj": continue # obj folders are not interesting...
144+
filename = os.path.join(dirname, file)
145+
if os.path.isdir(filename):
146+
yield from listdir(filename)
147+
elif filename.endswith(".cs") and not file == "StandardTestStrings.cs": # TODO: fix encoding of StandardTestStrings.cs
148+
yield filename
149+
150+
res = []
151+
for file in listdir(dirname):
152+
with open(file, encoding='latin-1') as f:
153+
if START_COMMON in f.read():
154+
res.append(file)
155+
return res
156+
134157
class CodeGenerator:
135158
def __init__(self, name, generator):
136159
self.generator = generator
@@ -151,19 +174,10 @@ def do_generate(self):
151174
result.append(g.generate())
152175
return result
153176

154-
def do_dir(self, dirname):
155-
if dirname in exclude_directories:
156-
return
157-
for file in os.listdir(dirname):
158-
filename = os.path.join(dirname, file)
159-
if os.path.isdir(filename):
160-
self.do_dir(filename)
161-
elif filename.endswith(".cs") and not file == "StandardTestStrings.cs": # TODO: fix encoding of StandardTestStrings.cs
162-
self.do_file(filename)
163-
164177
def doit(self):
165178
for src_dir in source_directories:
166-
self.do_dir(src_dir)
179+
for file in find_candidates(src_dir):
180+
self.do_file(file)
167181
for g in self.generators:
168182
g.collect_info()
169183
return self.do_generate()

0 commit comments

Comments
 (0)