* support/packihx/configure.in,
[fw/sdcc] / support / regression / generate-cases.py
index 55839e9130f38c7b762d76755ded34c5e6ff1352..9c9bb04585ce5dc122a0f9aff0970e74531bf45f 100644 (file)
@@ -68,8 +68,8 @@ class InstanceGenerator:
         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
@@ -80,7 +80,7 @@ class InstanceGenerator:
         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
@@ -171,17 +171,22 @@ class InstanceGenerator:
         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()
+