• R/O
  • SSH
  • HTTPS

c4ju: Commit


Commit MetaInfo

Revision6 (tree)
Time2011-10-30 23:16:28
Authorsrz_zumix

Log Message

コミット忘れをアップ
ワースト(最大値)表示対応
テスト結果のコンソール出力対応

Change Summary

Incremental Difference

--- trunk/src/FilterBuilder.cs (nonexistent)
+++ trunk/src/FilterBuilder.cs (revision 6)
@@ -0,0 +1,132 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Linq;
4+using System.Text;
5+using System.Xml;
6+
7+namespace c4ju
8+{
9+ #region フィルター
10+ class FilterAttribute
11+ {
12+ public string Name;
13+ public string Value;
14+ public CSharpEval Eval;
15+ public WorstInfo Worst = null;
16+ };
17+ class Filter
18+ {
19+ public string TestName;
20+ public string strXPath;
21+ public List<FilterAttribute> list;
22+ };
23+ class WorstInfo
24+ {
25+ public string Name;
26+ public string file;
27+ public int line;
28+ public float Value = 0;
29+ };
30+ #endregion
31+
32+ class FilterBuilder
33+ {
34+ public static List<Filter> Build(string xmlpath)
35+ {
36+ XmlDocument doc_filter = new XmlDocument();
37+
38+ try
39+ {
40+ doc_filter.Load(xmlpath);
41+ }
42+ catch (Exception e)
43+ {
44+ Console.WriteLine(e.Message);
45+ return null;
46+ }
47+
48+ if (doc_filter.ChildNodes.Count == 0)
49+ {
50+ Console.WriteLine("not found filter.");
51+ return null;
52+ }
53+ XmlNode ccccNode = doc_filter.SelectSingleNode("//CCCC_Project");
54+ if (ccccNode == null)
55+ {
56+ Console.WriteLine("not found CCCC_Project node.");
57+ return null;
58+ }
59+ List<string> filter_xpaths = XmlToXPathList.Convert(ccccNode);
60+ if (filter_xpaths.Count == 0)
61+ {
62+ Console.WriteLine("not found test filter.");
63+ return null;
64+ }
65+ List<Filter> filter_list = new List<Filter>();
66+ foreach (string xpath in filter_xpaths)
67+ {
68+ Filter f = new Filter();
69+ XmlNode filter_node = doc_filter.SelectSingleNode(xpath);
70+ f.TestName = filter_node.ParentNode.Name + "/" + filter_node.Name + " : ";
71+ f.strXPath = xpath;
72+ f.list = new List<FilterAttribute>();
73+ foreach (XmlAttribute attr in filter_node.Attributes)
74+ {
75+ FilterAttribute a = new FilterAttribute();
76+ a.Name = attr.Name;
77+ a.Value = attr.Value;
78+ a.Eval = new CSharpEval();
79+ if (!a.Eval.Init(attr.Value))
80+ {
81+ Console.WriteLine("Evaluation of the filter expression is invalid xml.");
82+ return null;
83+ }
84+ f.list.Add(a);
85+ }
86+ filter_list.Add(f);
87+ }
88+ return filter_list;
89+ }
90+ }
91+}
92+
93+#region XmlToXPathList
94+class XmlToXPathList
95+{
96+ public static List<string> Convert(XmlNode node)
97+ {
98+ List<string> list = new List<string>();
99+ if (node.ChildNodes.Count == 0)
100+ {
101+ if (node.NodeType == XmlNodeType.Element)
102+ {
103+ string path = node.Name;
104+ XmlNode p = node.ParentNode;
105+ while (p != null && p.ParentNode != null)
106+ {
107+ path = p.Name + "/" + path;
108+ p = p.ParentNode;
109+ }
110+ path = "//" + path;
111+ list.Add(path);
112+ }
113+ }
114+ foreach (XmlNode n in node.ChildNodes)
115+ {
116+ list.AddRange(Convert(n));
117+ }
118+ return list;
119+ }
120+ public static List<string> Convert(XmlDocument doc)
121+ {
122+ List<string> list = new List<string>();
123+
124+ foreach (XmlNode n in doc.ChildNodes)
125+ {
126+ list.AddRange(Convert(n));
127+ }
128+ return list;
129+ }
130+}
131+
132+#endregion
--- trunk/src/Program.cs (revision 5)
+++ trunk/src/Program.cs (revision 6)
@@ -15,6 +15,8 @@
1515 static int Main(string[] args)
1616 {
1717 bool input_stdin = false;
18+ bool show_worst = false;
19+ bool quiet = false;
1820 List<string> files = new List<string>();
1921 string outfile = "test_default.xml";
2022 string filter_xmlpath = "filter_default.xml";
@@ -85,6 +87,18 @@
8587 }
8688 }
8789 #endregion
90+ #region ワースト情報の出力
91+ else if (option == "show_worst")
92+ {
93+ show_worst = true;
94+ }
95+ #endregion
96+ #region サイレントモード
97+ else if (option == "quiet")
98+ {
99+ quiet = true;
100+ }
101+ #endregion
88102 }
89103 else if( argv[0] == '-' )
90104 {
@@ -235,11 +249,33 @@
235249 fr.File = file;
236250 fr.Line = line;
237251 fr_list.Add(fr);
252+ string test_combine_name = test_case_name + "." + name;
253+ if (!quiet)
254+ {
255+ Console.WriteLine(test_combine_name);
256+ Console.WriteLine(fr.Message);
257+ }
258+
259+ // ワースト情報を保存
260+ if (show_worst)
261+ {
262+ if (filter_attr.Worst == null)
263+ {
264+ filter_attr.Worst = new WorstInfo();
265+ }
266+ if (lhs > filter_attr.Worst.Value)
267+ {
268+ filter_attr.Worst.Name = test_combine_name;
269+ filter_attr.Worst.Value = lhs;
270+ filter_attr.Worst.file = file;
271+ filter_attr.Worst.line = line;
272+ }
273+ }
238274 }
239275 }
240276 catch (Exception e)
241277 {
242- Console.WriteLine(e.Message);
278+ Console.Error.WriteLine(e.Message);
243279 }
244280 }
245281 }
@@ -271,7 +307,7 @@
271307 }
272308 catch (Exception e)
273309 {
274- Console.WriteLine(e.Message);
310+ Console.Error.WriteLine(e.Message);
275311 }
276312 #endregion
277313 }
@@ -278,7 +314,7 @@
278314 }
279315 catch (Exception e)
280316 {
281- Console.WriteLine(e.Message);
317+ Console.Error.WriteLine(e.Message);
282318 }
283319 }
284320 #endregion
@@ -293,6 +329,32 @@
293329 junitDoc.Save(outfile);
294330 #endregion
295331
332+ #region ワースト情報の出力
333+ if (show_worst)
334+ {
335+ Console.WriteLine("");
336+ Console.WriteLine("********************");
337+ Console.WriteLine("The largest values.");
338+ foreach (Filter filter in filter_list)
339+ {
340+ Console.WriteLine(filter.TestName);
341+ foreach (FilterAttribute attr in filter.list)
342+ {
343+ if (attr.Worst != null)
344+ {
345+ Console.WriteLine(" " + attr.Worst.Name);
346+ if (attr.Worst.file != null)
347+ {
348+ Console.WriteLine(" " + attr.Worst.file + ":" + attr.Worst.line);
349+ }
350+ Console.WriteLine(" " + attr.Name + " : " + attr.Worst.Value.ToString());
351+ Console.WriteLine("");
352+ }
353+ }
354+ }
355+ }
356+ #endregion
357+
296358 return 0;
297359 }
298360 }
--- trunk/src/Properties/AssemblyInfo.cs (revision 5)
+++ trunk/src/Properties/AssemblyInfo.cs (revision 6)
@@ -32,5 +32,5 @@
3232 // すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
3333 // 既定値にすることができます:
3434 // [assembly: AssemblyVersion("1.0.*")]
35-[assembly: AssemblyVersion("1.0.0.1")]
36-[assembly: AssemblyFileVersion("1.0.0.1")]
35+[assembly: AssemblyVersion("1.0.1.0")]
36+[assembly: AssemblyFileVersion("1.0.1.0")]
--- trunk/src/JunitXml.cs (revision 5)
+++ trunk/src/JunitXml.cs (revision 6)
@@ -23,7 +23,7 @@
2323 public class FailureResult
2424 {
2525 string m_message;
26- string m_file;
26+ string m_file = null;
2727 int m_line;
2828
2929 public string Message
--- trunk/readme.txt (revision 5)
+++ trunk/readme.txt (revision 6)
@@ -47,3 +47,14 @@
4747 対応するノードの属性に式を記述します。
4848 value にテスト対象の属性値が代入されます。
4949
50+--------------------------------------------------
51+Jenkins Job Sample
52+
53+======= job bat file =======
54+
55+SET TARGETDIR=%WORKSPACE%\.cccc
56+cd /d %TARGETDIR%
57+dir /s /b *.xml | call c4ju --filter="filter.xml" --out_xmlfile="%WORKSPACE%\test_default.xml" -
58+
59+============================
60+
Show on old repository browser