無視リスト対応
オプション修正
@@ -16,10 +16,12 @@ | ||
16 | 16 | { |
17 | 17 | bool input_stdin = false; |
18 | 18 | bool show_worst = false; |
19 | - bool quiet = false; | |
19 | + bool verbose = false; | |
20 | 20 | List<string> files = new List<string>(); |
21 | 21 | string outfile = "test_default.xml"; |
22 | 22 | string filter_xmlpath = "filter_default.xml"; |
23 | + List<string> excluding = new List<string>(); | |
24 | + string excluding_list_txt = null; | |
23 | 25 | |
24 | 26 | #region コマンドライン解析 |
25 | 27 | // コマンドライン引数の解析 |
@@ -31,6 +33,7 @@ | ||
31 | 33 | string option = argv.Substring(2); |
32 | 34 | string opt_out_xmlfile = "out_xmlfile"; |
33 | 35 | string opt_filter = "filter"; |
36 | + string opt_excluding = "excluding"; | |
34 | 37 | #region 出力ファイル |
35 | 38 | if (option.IndexOf(opt_out_xmlfile) == 0) |
36 | 39 | { |
@@ -62,6 +65,8 @@ | ||
62 | 65 | --help : generate this help message. |
63 | 66 | --out_xmlfile=<path> : path of xml report. |
64 | 67 | --filter=<path> : path of test filter xml. |
68 | +--excluding=<file> : read the ignore list from a file. | |
69 | +--verbose : displays detailed messages. | |
65 | 70 | " |
66 | 71 | ); |
67 | 72 | return 0; |
@@ -93,12 +98,32 @@ | ||
93 | 98 | show_worst = true; |
94 | 99 | } |
95 | 100 | #endregion |
96 | - #region サイレントモード | |
97 | - else if (option == "quiet") | |
101 | + #region 無視リスト | |
102 | + else if (option.IndexOf(opt_excluding) == 0) | |
98 | 103 | { |
99 | - quiet = true; | |
104 | + // フィルターファイル名の指定 | |
105 | + if (option.Length > 1) | |
106 | + { | |
107 | + if (option.IndexOf("=") == opt_excluding.Length) | |
108 | + excluding_list_txt = option.Substring(opt_excluding.Length + 1); | |
109 | + } | |
110 | + else if (i < args.Length) | |
111 | + { | |
112 | + filter_xmlpath = args[++i]; | |
113 | + } | |
114 | + | |
115 | + if (excluding_list_txt[0] == '\"') | |
116 | + { | |
117 | + excluding_list_txt = excluding_list_txt.Substring(1, excluding_list_txt.Length - 2); | |
118 | + } | |
100 | 119 | } |
101 | 120 | #endregion |
121 | + #region verbose | |
122 | + else if (option == "verbose") | |
123 | + { | |
124 | + verbose = true; | |
125 | + } | |
126 | + #endregion | |
102 | 127 | } |
103 | 128 | else if( argv[0] == '-' ) |
104 | 129 | { |
@@ -145,6 +170,20 @@ | ||
145 | 170 | } |
146 | 171 | #endregion |
147 | 172 | |
173 | + #region 無視リスト | |
174 | + if (excluding_list_txt != null) | |
175 | + { | |
176 | + using (StreamReader sr = new StreamReader(excluding_list_txt)) | |
177 | + { | |
178 | + string line = null; | |
179 | + while ((line = sr.ReadLine()) != null) | |
180 | + { | |
181 | + excluding.Add(line); | |
182 | + } | |
183 | + } | |
184 | + } | |
185 | + #endregion | |
186 | + | |
148 | 187 | #region テストの開始処理 |
149 | 188 | Stopwatch test_suites_sw = new Stopwatch(); |
150 | 189 | Stopwatch test_case_sw = new Stopwatch(); |
@@ -171,7 +210,10 @@ | ||
171 | 210 | { |
172 | 211 | xml.Load(f); |
173 | 212 | |
174 | - Console.WriteLine(f); | |
213 | + if (verbose) | |
214 | + { | |
215 | + Console.WriteLine(f); | |
216 | + } | |
175 | 217 | |
176 | 218 | foreach (Filter filter in filter_list) |
177 | 219 | { |
@@ -250,7 +292,7 @@ | ||
250 | 292 | fr.Line = line; |
251 | 293 | fr_list.Add(fr); |
252 | 294 | string test_combine_name = test_case_name + "." + name; |
253 | - if (!quiet) | |
295 | + if (verbose) | |
254 | 296 | { |
255 | 297 | Console.WriteLine(test_combine_name); |
256 | 298 | Console.WriteLine(fr.Message); |
@@ -286,16 +328,38 @@ | ||
286 | 328 | } |
287 | 329 | |
288 | 330 | test_sw.Stop(); |
331 | + bool except = false; | |
289 | 332 | if (fr_list.Count > 0) |
290 | 333 | { |
291 | - ++failure_count; | |
334 | + string full_name = test_case_name + "." + name; | |
335 | + foreach (string pattern in excluding) | |
336 | + { | |
337 | + if (System.Text.RegularExpressions.Regex.IsMatch(full_name, pattern)) | |
338 | + { | |
339 | + // マッチしたら無視 | |
340 | + except = true; | |
341 | + break; | |
342 | + } | |
343 | + } | |
292 | 344 | } |
293 | - junitDoc.AppendTestCase(TestSuite | |
345 | + XmlNode testcase = junitDoc.AppendTestCase(TestSuite | |
294 | 346 | , name |
295 | 347 | , true |
296 | 348 | , test_sw.Elapsed |
297 | 349 | , fr_list |
298 | 350 | ); |
351 | + if (except) | |
352 | + { | |
353 | + // skip ノード追加 | |
354 | + testcase.AppendChild(junitDoc.CreateElement("skipped")); | |
355 | + } | |
356 | + else | |
357 | + { | |
358 | + if (fr_list.Count > 0) | |
359 | + { | |
360 | + ++failure_count; | |
361 | + } | |
362 | + } | |
299 | 363 | #endregion |
300 | 364 | } |
301 | 365 | test_case_sw.Stop(); |
@@ -19,6 +19,8 @@ | ||
19 | 19 | --help : generate help message. |
20 | 20 | --out_xmlfile=<path> : path of xml report. |
21 | 21 | --filter=<path> : path of test filter xml. |
22 | + --excluding=<file> : read the ignore list from a file. | |
23 | + --verbose : displays detailed messages. | |
22 | 24 | |
23 | 25 | -------------------------------------------------- |
24 | 26 | Description |
@@ -48,6 +50,23 @@ | ||
48 | 50 | value にテスト対象の属性値が代入されます。 |
49 | 51 | |
50 | 52 | -------------------------------------------------- |
53 | +Use Excluding | |
54 | + | |
55 | +--excluding=<file> オプションを使用することで任意のテスト結果を無視(スキップ)することができます。 | |
56 | + | |
57 | +file には、無視したいテストの条件が書かれたファイルを指定します。 | |
58 | +条件には、無視したいテストの名前を一行ごとに記述します。 | |
59 | +(正規表現が使用できます。) | |
60 | + | |
61 | +==== sample excluding txt ==== | |
62 | +.*Test.* | |
63 | +.*anonymous.* | |
64 | +============================== | |
65 | + | |
66 | + | |
67 | + | |
68 | + | |
69 | +-------------------------------------------------- | |
51 | 70 | Jenkins Job Sample |
52 | 71 | |
53 | 72 | ======= job bat file ======= |