Beispiel #1
0
    def run(self):
        hopt, header = self.__getOptArg__(("-h", "--header"))
        if not header:
            raise GetoptError("no header file specified")
        elif len(self.__args__) > 1:
            raise GetoptError("too many arguments")
    
        cppUnitFile = None
        if len(self.__args__) == 1:
            cppUnitFile = self.__args__[0]
        else:
            root, filename = path.split(header)
            name, ext = path.splitext(filename)
            cppSuffix = XmlConfig().getCppSuffix()
            cppUnitFile = "%sTest%s" % (name, cppSuffix)
            cppUnitFile = path.join(XmlConfig().getUnitTestDir(), cppUnitFile)

        self.__checkAndMakeUnitTestDir()
        self.__checkAndGenerateUnitTestMakefile()
        self.__checkAndGenerateUnitTestMain()
        dieOnExists(cppUnitFile)
        FileDepot().add(cppUnitFile)
        parser = TemplateParser("template.cpp", cppUnitFile)
        parser.parse()
        with open(cppUnitFile, "a+") as output:
            headerParser = CppHeaderParser(header)
            cppUnitGenImpl = CppUnitGenImpl(header, output)
            cppUnitGenImpl.setParser(headerParser)
            headerParser.addObserver(cppUnitGenImpl)
            headerParser.parse()
        print "\t" + cppUnitFile + "\t\t\t\t[OK]"
Beispiel #2
0
 def __checkAndGenerateUnitTestMakefile(self):
     unitDir = XmlConfig().getUnitTestDir()
     makefile = path.join(unitDir, "makefile")
     if not path.exists(makefile):
         FileDepot().add(makefile)
         parser = TemplateParser("makefile.test", makefile)
         parser.addObserver(UnitTestMakefileObserver())
         parser.parse()
         print "\t" + makefile + "\t\t\t\t[OK]"
Beispiel #3
0
 def __checkAndGenerateUnitTestMain(self):
     cppSuffix = XmlConfig().getCppSuffix()
     unitDir = XmlConfig().getUnitTestDir()
     unitMain = path.join(unitDir, "main%s" % cppSuffix)
     if not path.exists(unitMain):
         FileDepot().add(unitMain)
         parser = TemplateParser("unittestmain.cpp", unitMain)
         parser.parse()
         print "\t" + unitMain + "\t\t\t\t[OK]"
Beispiel #4
0
 def run(self):
     if self.__arg__ == None:
         raise GetoptError("no header specified")
     if self.__args__:
         raise GetoptError("too many arguments")
 
     dieOnExists(self.__arg__)
     FileDepot().add(self.__arg__)
     parser = TemplateParser("template.h", self.__arg__)
     parser.parse()
     print "\t" + self.__arg__ + "\t\t\t\t[OK]"
Beispiel #5
0
 def testUnitMakefile(self):
     unitMakefile = path.join("test", "main.cc")
     unitMakefileStandard = path.join("test", "makefile_standard.test")
     self.__removeOnExists(unitMakefile)
     parser = TemplateParser("makefile.test", unitMakefile)
     parser.parse()
     expected = self.__getFileContent(unitMakefileStandard)
     expected = expected.replace("&date", date.today().isoformat())
     actual = self.__getFileContent(unitMakefile)
     self.assertEquals(expected, actual)
     remove(unitMakefile)
Beispiel #6
0
 def run(self):
     if len(self.__args__) > 1:
         raise GetoptError("too many arguments")
         
     makefile = "makefile"
     if len(self.__args__) == 1:
         makefile = self.__args__[0]
 
     dieOnExists(makefile)
     FileDepot().add(makefile)
     parser = TemplateParser("makefile", makefile)
     parser.parse()
     print "\t" + makefile + "\t\t\t\t[OK]"
Beispiel #7
0
    def run(self):
        if len(self.__args__) > 1:
            raise GetoptError("too many arguments")

        hopt, header = self.__getOptArg__(("-h", "--header"))

        cppFile = None
        if len(self.__args__) == 1:
            cppFile = self.__args__[0]
        elif not self.__args__ and header:
            name, ext = path.splitext(header)
            suffix = XmlConfig().getCppSuffix()
            cppFile = name + suffix
        else:
            raise GetoptError("no cpp file to generate")
    
        dieOnExists(cppFile)
        FileDepot().add(cppFile)
        parser = TemplateParser("template.cpp", cppFile)
        parser.parse()
        if header != None:
            self.__generateCppContentFromHeader(cppFile, header)
        print "\t" + cppFile + "\t\t\t\t[OK]"