Wiki

Ticket #89: ticket89-files-arg.patch

File ticket89-files-arg.patch, 1.8 KB (added by hopscc, 16 years ago)
  • Source/CommandLine.cobra

     
    11431143        validate names and add into fileList 
    11441144        """ 
    11451145        for fileName as String in fileNamesList 
    1146             baseDir = Path.getDirectoryName(fileName) 
    11471146            try 
     1147                what = 'name "[fileName]"' 
     1148                baseDir = Path.getDirectoryName(fileName) 
    11481149                for line in File.readAllLines(fileName) 
    11491150                    line = line.trim 
    11501151                    if line.length==0 or line.startsWith('#') 
    11511152                        continue 
    11521153                    # note that source files are relative to the location of the "files file" 
    1153                     _processAsFile(Path.combine(baseDir, line), fileList, nil) 
     1154                    what = 'line - filename "[line]"' 
     1155                    fileArg = Path.combine(baseDir, line) 
     1156                    _processAsFile(fileArg, fileList, nil) 
    11541157            catch IOException 
    11551158                _error('Cannot open file "[fileName]".') 
     1159            catch ArgumentException 
     1160                _error('Invalid filesFile [what].') 
    11561161 
    11571162    def _processAsFile(arg as String, fileList as List<of String>, errHint as String?) 
    11581163        """ 
  • Tests/700-command-line/860-files.cobra

     
     1# check missing/weirded filesFiles arg 
     2class Test 
     3 
     4    def main is shared 
     5        .check('-c -files:xyzzy', 'cannot open file "xyzzy"') 
     6        .check('-c -files: ', 'invalid filesfile name "".') 
     7        .check('-c -files:100-find-cobra.exe', 'invalid filesfile line - filename') 
     8     
     9    def check(opt as String, contains) is shared 
     10        process as System.Diagnostics.Process? 
     11 
     12        output = CobraCore.runCobraExe('[opt] ', out process) 
     13        assert output.toLower.contains(contains)