Skip to content

Commit 9e240bd

Browse files
committed
generate.py: enable overriding path of generated clar.suite
The generate.py script will currently always write the generated clar.suite file into the scanned directory, breaking out-of-tree builds with read-only source directories. Fix this issue by adding another option to allow overriding the output path of the generated file.
1 parent 0a513a9 commit 9e240bd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/generate.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ def refresh(self, path):
128128

129129
class TestSuite(object):
130130

131-
def __init__(self, path):
131+
def __init__(self, path, output):
132132
self.path = path
133+
self.output = output
133134

134135
def should_generate(self, path):
135136
if not os.path.isfile(path):
@@ -200,7 +201,7 @@ def callback_count(self):
200201
return sum(len(module.callbacks) for module in self.modules.values())
201202

202203
def write(self):
203-
output = os.path.join(self.path, 'clar.suite')
204+
output = os.path.join(self.output, 'clar.suite')
204205

205206
if not self.should_generate(output):
206207
return False
@@ -232,14 +233,16 @@ def write(self):
232233
parser = OptionParser()
233234
parser.add_option('-f', '--force', action="store_true", dest='force', default=False)
234235
parser.add_option('-x', '--exclude', dest='excluded', action='append', default=[])
236+
parser.add_option('-o', '--output', dest='output')
235237

236238
options, args = parser.parse_args()
237239
if len(args) > 1:
238240
print("More than one path given")
239241
sys.exit(1)
240242

241243
path = args.pop() if args else '.'
242-
suite = TestSuite(path)
244+
output = options.output or path
245+
suite = TestSuite(path, output)
243246
suite.load(options.force)
244247
suite.disable(options.excluded)
245248
if suite.write():

0 commit comments

Comments
 (0)