Commit 9e240bd2c496353ffafdaa7fadd4301abd424c4c

Patrick Steinhardt 2017-05-10T12:02:03

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.

diff --git a/tests/generate.py b/tests/generate.py
index 5d1a8e6..b1562fa 100644
--- a/tests/generate.py
+++ b/tests/generate.py
@@ -128,8 +128,9 @@ class Module(object):
 
 class TestSuite(object):
 
-    def __init__(self, path):
+    def __init__(self, path, output):
         self.path = path
+        self.output = output
 
     def should_generate(self, path):
         if not os.path.isfile(path):
@@ -200,7 +201,7 @@ class TestSuite(object):
         return sum(len(module.callbacks) for module in self.modules.values())
 
     def write(self):
-        output = os.path.join(self.path, 'clar.suite')
+        output = os.path.join(self.output, 'clar.suite')
 
         if not self.should_generate(output):
             return False
@@ -232,6 +233,7 @@ if __name__ == '__main__':
     parser = OptionParser()
     parser.add_option('-f', '--force', action="store_true", dest='force', default=False)
     parser.add_option('-x', '--exclude', dest='excluded', action='append', default=[])
+    parser.add_option('-o', '--output', dest='output')
 
     options, args = parser.parse_args()
     if len(args) > 1:
@@ -239,7 +241,8 @@ if __name__ == '__main__':
         sys.exit(1)
 
     path = args.pop() if args else '.'
-    suite = TestSuite(path)
+    output = options.output or path
+    suite = TestSuite(path, output)
     suite.load(options.force)
     suite.disable(options.excluded)
     if suite.write():