Merge lp:~sergey.popov/nunit-summary/psg into lp:~charlie.poole/nunit-summary/old-trunk-do-not-use

Proposed by Sergey Popov
Status: Merged
Approved by: Charlie Poole
Approved revision: 5
Merge reported by: Charlie Poole
Merged at revision: not available
Proposed branch: lp:~sergey.popov/nunit-summary/psg
Merge into: lp:~charlie.poole/nunit-summary/old-trunk-do-not-use
Diff against target: None lines
To merge this branch: bzr merge lp:~sergey.popov/nunit-summary/psg
Reviewer Review Type Date Requested Status
Charlie Poole Approve
Review via email: mp+8362@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Sergey Popov (sergey.popov) wrote :

A little bugfix.

Revision history for this message
Charlie Poole (charlie.poole) wrote :

I forgot this was pending... looks OK.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'XmlTransformerOptions.cs'
2--- XmlTransformerOptions.cs 2009-07-05 05:50:06 +0000
3+++ XmlTransformerOptions.cs 2009-07-08 03:29:33 +0000
4@@ -20,7 +20,7 @@
5 bool noheader = false;
6 bool html = false;
7 bool brief = false;
8-
9+
10 List<string> inputFiles = new List<string>();
11
12 string transformFile = null;
13@@ -28,21 +28,30 @@
14
15 bool multipleOutput = false;
16
17- public XmlTransformerOptions( string[] args )
18+ public XmlTransformerOptions(string[] args)
19 {
20 if (Path.DirectorySeparatorChar == '\\')
21 optionChars += "/";
22
23- foreach (string arg in args)
24- if (optionChars.IndexOf(arg[0]) >= 0)
25- processOption( arg );
26- else if( IsWildCardPattern( arg ) )
27- processWildCardPattern( arg );
28- else
29- inputFiles.Add( arg );
30+ try
31+ {
32+ foreach (string arg in args)
33+ if (optionChars.IndexOf(arg[0]) >= 0)
34+ processOption(arg);
35+ else if (IsWildCardPattern(arg))
36+ processWildCardPattern(arg);
37+ else
38+ inputFiles.Add(arg);
39
40- if (inputFiles.Count == 0)
41- inputFiles.Add("TestResult.xml");
42+ if (inputFiles.Count == 0)
43+ inputFiles.Add("TestResult.xml");
44+ }
45+ catch (XmlTransformerOptionsException xcp)
46+ {
47+ Console.Error.WriteLine(xcp.Message);
48+ error = true;
49+ usage();
50+ }
51 }
52
53 private void processOption(string arg)
54@@ -53,10 +62,18 @@
55 switch (opt[0])
56 {
57 case "xsl":
58+ if (opt.Length != 2)
59+ {
60+ throw new XmlTransformerOptionsException("You must specify a file name for -xsl option!");
61+ }
62 transformFile = opt[1];
63 break;
64 case "o":
65 case "out":
66+ if (opt.Length != 2)
67+ {
68+ throw new XmlTransformerOptionsException("You must specify a file name for -out option!");
69+ }
70 outputFile = opt[1];
71 multipleOutput = Path.GetFileNameWithoutExtension(outputFile) == "*";
72 string ext = Path.GetExtension(outputFile);
73@@ -77,10 +94,7 @@
74 brief = true;
75 break;
76 default:
77- Console.Error.WriteLine("Invalid option: {0}", arg);
78- error=true;
79- usage();
80- break;
81+ throw new XmlTransformerOptionsException(String.Format("Invalid option: {0}", arg));
82 }
83 }
84
85@@ -91,9 +105,9 @@
86 if (dir == "") dir = Environment.CurrentDirectory;
87 string name = Path.GetFileName(arg);
88
89- if( IsWildCardPattern( dir ) )
90- processWildCardPattern( name, dir.Split(
91- new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }) );
92+ if (IsWildCardPattern(dir))
93+ processWildCardPattern(name, dir.Split(
94+ new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }));
95 else
96 foreach (string file in Directory.GetFiles(dir, name))
97 inputFiles.Add(file);
98@@ -132,7 +146,7 @@
99 string temp = d;
100 for (int index = count + 1; index < parts.Length; index++)
101 temp = Path.Combine(temp, parts[index]);
102- if( Directory.Exists( temp ) )
103+ if (Directory.Exists(temp))
104 processWildCardPattern(Path.Combine(temp, name));
105 }
106 }
107@@ -192,12 +206,12 @@
108
109 void usage()
110 {
111- Console.Error.WriteLine("Usage is: nunit-transform inputFile [options]" );
112+ Console.Error.WriteLine("Usage is: nunit-transform inputFile [options]");
113 Console.Error.WriteLine();
114 Console.Error.WriteLine(" inputFile The absolute or relative path to an input file to be");
115- Console.Error.WriteLine(" to be processed. Multiple files may be specified and" );
116+ Console.Error.WriteLine(" to be processed. Multiple files may be specified and");
117 Console.Error.WriteLine(" wildcard specifications may be used in either the name");
118- Console.Error.WriteLine(" of the file or the directory path. A directory specified" );
119+ Console.Error.WriteLine(" of the file or the directory path. A directory specified");
120 Console.Error.WriteLine(" as '**' represents all directories to any depth.");
121 Console.Error.WriteLine();
122 Console.Error.WriteLine(" -xsl=transform Specify xsl transform to use. If not specified, an");
123@@ -206,9 +220,9 @@
124 Console.Error.WriteLine(" gives the same output as nunit-console.");
125 Console.Error.WriteLine();
126 Console.Error.WriteLine(" -out=outputFile Define the output file. If missing, output is written to");
127- Console.Error.WriteLine(" -o=outputFile standard output. When multiple input files are processed," );
128- Console.Error.WriteLine(" the output basename may be specified as '*' to create" );
129- Console.Error.WriteLine(" a separate output file for each input using the basename" );
130+ Console.Error.WriteLine(" -o=outputFile standard output. When multiple input files are processed,");
131+ Console.Error.WriteLine(" the output basename may be specified as '*' to create");
132+ Console.Error.WriteLine(" a separate output file for each input using the basename");
133 Console.Error.WriteLine(" of the corresponding input file.");
134 Console.Error.WriteLine();
135 Console.Error.WriteLine(" If the extension of the output file is html or htm, the");
136@@ -231,4 +245,12 @@
137 Console.Error.WriteLine(" nunit-summary **/TestResult*.xml -out=allplatforms.txt");
138 }
139 }
140+
141+ internal class XmlTransformerOptionsException : Exception
142+ {
143+ public XmlTransformerOptionsException(string message)
144+ : base(message)
145+ {
146+ }
147+ }
148 }

Subscribers

People subscribed via source and target branches

to all changes: