self.functions = []
# Emit the suite wrapper into a temporary file
self.tmpname = tempfile.mktemp()
- (self.basename, self.ext) = re.split(r'\.', self.inname)
- self.ext = '.' + self.ext
+ (self.dirname, self.filename) = os.path.split(self.inname)
+ (self.basename, self.ext) = os.path.splitext (self.filename)
def permute(self, basepath, keys, trans = {}):
"""Permutes across all of the names. For each value, recursivly creates
if len(keys) == 0:
# End of the recursion.
# Set the runtime substitutions.
- trans['testcase'] = basepath
+ trans['testcase'] = re.sub(r'\\', r'\\\\', basepath)
# Create the instance from the template
T = TemplateDocument(self.tmpname)
T.substitutions = trans
createdir(outdir)
# Generate
- self.permute(os.path.join(outdir, os.path.basename(self.basename)), self.replacements.keys())
+ self.permute(os.path.join(outdir, self.basename), self.replacements.keys())
# Remove the temporary file
os.remove(self.tmpname)
-# Check and parse the command line arguments
-if len(sys.argv) < 3:
- # PENDING: How to throw an error?
- print "usage: generate-cases.py template.c outdir"
+def main():
+ # Check and parse the command line arguments
+ if len(sys.argv) < 3:
+ print "usage: generate-cases.py template.c outdir"
+ sys.exit(-1)
+
+ # Input name is the first arg.
-# Input name is the first arg.
+ s = InstanceGenerator(sys.argv[1])
+ s.generate()
-s = InstanceGenerator(sys.argv[1])
-s.generate()
+if __name__ == '__main__':
+ main()
+