Wiki

Ticket #239: test-and-out.patch

File test-and-out.patch, 4.1 KB (added by hopscc, 11 years ago)
  • Source/CommandLine.cobra

     
    901901            p.start 
    902902            p.waitForExit  # TODO: is this necessary? 
    903903        catch 
    904             try, File.delete(c.fullExeFileName) 
    905             catch IOException, pass 
    906             catch UnauthorizedAccessException, pass 
     904            if not .options.getDefault('keep-intermediate-files', 0)  
     905                _cleanupExeFile(c.fullExeFileName, '') 
    907906            throw 
    908907        success 
    909             try 
    910                 File.delete(c.fullExeFileName) 
    911             catch IOException 
    912                 print 'warning: Cannot remove "[c.fullExeFileName]"' 
    913             catch UnauthorizedAccessException 
    914                 print 'warning: Cannot remove "[c.fullExeFileName]"' 
    915  
     908            if not .options.getDefault('keep-intermediate-files', 0) 
     909                _cleanupExeFile(c.fullExeFileName, 'warning: Cannot remove "[c.fullExeFileName]"') 
     910                 
     911    def _cleanupExeFile(fullExeFileName as String, msg as String) 
     912        try  
     913            File.delete(fullExeFileName) 
     914            dbgExeFileName = Path.changeExtension(fullExeFileName, 'pdb') 
     915            if File.exists(dbgExeFileName), File.delete(dbgExeFileName) 
     916        catch IOException 
     917            if msg.length, print msg 
     918        catch UnauthorizedAccessException 
     919            if msg.length, print msg 
     920                 
     921                 
    916922    def doRun(paths as List<of String>) 
    917923        c = .doCompile(paths, false, false, nil) 
    918924        if c.errors.count 
  • Source/BackEndClr/SharpGenerator.cobra

     
    4545 
    4646    def writeSharpTestInvocation 
    4747        dt = DateTime.now 
    48         fileName = 'test-[dt.year][dt.month][dt.day][dt.hour][dt.minute].cs'  # TODO: format the numbers to have leading zeros 
     48        fileName = 'test-[dt.year][dt.month:D2][dt.day:D2][dt.hour:D2][dt.minute:D2].cs' 
     49        outName = .options.getDefault('out', '') 
     50        if outName.length  
     51            outDir = Path.getDirectoryName(outName) 
     52            if outDir.length, fileName = Path.combine(outDir, fileName) 
     53         
    4954        w = CodePoundLineWriter() 
    5055        w.writeLine('using CobraCoreInternal = Cobra.Core[.embedRunTimeSuffix];') 
    5156        w.writeLine('') 
     
    9499            outName = _modules.last.sharpFileName 
    95100        else if .options.containsKey('out') 
    96101            outName = .options.getDefault('out', '') 
     102            if outName.length and not Path.getFileName(outName).length  # no filename, assume just a dirname given 
     103                outName = Path.combine(outName, .defaultOutName to !) 
    97104        if outName == '', outName = .defaultOutName to ! 
    98105        if outName.endsWith('.cs') or outName.endsWith('.CS'), outName = outName[:-3] 
    99106        if outName.endsWith('.cobra') or outName.endsWith('.COBRA'), outName = outName[:-6] 
  • Source/BackEndClr/ScanClrType.cobra

     
    496496        isSameNativeType = argClrType == thisClrType 
    497497        for methInfo in argClrType.getMethods(BindingFlags(DeclaredOnly, Static, Instance, Public)) 
    498498            if methInfo.isSpecialName, continue 
     499            if methInfo.name.startsWith('test_'), continue # ignore cobra-inserted static test methods   
    499500            # print 
    500501            # print '--', methInfo, methInfo.isStatic 
    501502            name = Utils.cobraNameForNativeMemberName(methInfo.name) 
  • Source/BackEndJvm/JavaGenerator.cobra

     
    2828            outName = _modules.last.javaFileName 
    2929        else if .options.containsKey('out') 
    3030            outName = .options.getDefault('out', '') 
     31            if outName.length and not Path.getFileName(outName).length  # no filename, assume just a dirname given 
     32                outName = Path.combine(outName, .defaultOutName to !) 
    3133        if outName == '', outName = .defaultOutName to ! 
    3234        if outName.endsWith('.java') or outName.endsWith('.JAVA'), outName = outName[:-5] 
    3335        if outName.endsWith('.cobra') or outName.endsWith('.COBRA'), outName = outName[:-6]