Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Improved node names in Test results view

  • Loading branch information...
commit a152e638f19e8dec8a8a62b235f5d47e98b2fd83 1 parent 105c803
Aleksandra Lipiec authored October 27, 2011
19  org.erlide.cover.core/src/org/erlide/cover/core/EUnitEventHandler.java
@@ -56,7 +56,7 @@ public void handleEvent(final Event event) {
56 56
         OtpErlangTuple msg = (OtpErlangTuple) data;
57 57
         OtpErlangAtom resType = (OtpErlangAtom) msg.elementAt(0);
58 58
         log.info(resType);
59  
-        System.out.println(resType.toString());
  59
+        System.out.println(msg.toString());
60 60
 
61 61
         if (resType.atomValue().equals(GROUP_BEGIN)) {
62 62
             handle_group_begin(msg);
@@ -89,9 +89,16 @@ private void handle_group_begin(OtpErlangTuple msg) {
89 89
         final String description = msg.elementAt(2).toString();
90 90
 
91 91
         if (group != null && !group.equals("[]") && !group.equals("undefined")) {
  92
+            TestTreeObject parent = model.findNode(group);
  93
+            if(parent == null){
  94
+                model.addChildren(new TestTreeObject(group,
  95
+                        TestTreeObject.GROUP));
  96
+            }
  97
+            
92 98
             model.findNode(group).addChild(
93 99
                     new TestTreeObject(description, TestTreeObject.GROUP));
94 100
         } else {
  101
+            //TODO check if
95 102
             model.addChildren(new TestTreeObject(description,
96 103
                     TestTreeObject.GROUP));
97 104
         }
@@ -103,8 +110,14 @@ private void handle_group_canceled(OtpErlangTuple msg) {
103 110
         final String description = msg.elementAt(1).toString();
104 111
         final String reason = msg.elementAt(2).toString();
105 112
 
106  
-        model.findNode(description).setDescription(
107  
-                String.format("%s ... canceled: %s", description, reason));
  113
+        if (description != null && !description.equals("[]")
  114
+                && !description.equals("undefined")) {
  115
+            model.findNode(description).setDescription(
  116
+                    String.format("%s ... canceled: %s", description, reason));
  117
+        } else {
  118
+            model.addChildren(new TestTreeObject(reason,
  119
+                    TestTreeObject.FAILOURE));
  120
+        }
108 121
 
109 122
     }
110 123
 
49  org.erlide.cover.erlang/src/test_listener.erl
@@ -73,12 +73,12 @@ handle_begin(group, Data, St) ->
73 73
 	io:format("group begin: ~p~n", [Data]),
74 74
     Desc = proplists:get_value(desc, Data),
75 75
 	Group = case St of
76  
-				[H | _T] -> make_list(H);
  76
+				[H | _T] -> make_atom(H);
77 77
 				_ ->
78 78
 					""
79 79
 			end,
80 80
 	if Desc =/= "", Desc =/= undefined  ->
81  
-		   	erlide_jrpc:event(?TEVENT, {gbegin, Group, make_list(Desc)}),
  81
+		   	erlide_jrpc:event(?TEVENT, {gbegin, Group, make_atom(Desc)}),
82 82
 			[Desc | St];
83 83
 	   true ->
84 84
 		   St
@@ -86,10 +86,10 @@ handle_begin(group, Data, St) ->
86 86
 handle_begin(test, Data, St) ->	
87 87
 	io:format("test begin: ~p~n", [Data]),
88 88
 	io:format("test state: ~p~n", [St]),
89  
-	Desc = proplists:get_value(desc, Data),
  89
+	Desc = make_atom(proplists:get_value(desc, Data)),
90 90
     Line = proplists:get_value(line, Data, 0),
91 91
 	Group = case St of
92  
-				[H | _T] -> make_list(H);
  92
+				[H | _T] -> make_atom(H);
93 93
 				_ ->
94 94
 					""
95 95
 			end,
@@ -101,14 +101,14 @@ handle_end(group, Data, St) ->
101 101
     Desc = proplists:get_value(desc, Data),
102 102
 	if Desc =/= "", Desc =/= undefined ->
103 103
     		Time = proplists:get_value(time, Data),
104  
-			erlide_jrpc:event(?TEVENT, {gend, make_list(Desc), Time}),
  104
+			erlide_jrpc:event(?TEVENT, {gend, make_atom(Desc), Time}),
105 105
     		lists:delete(Desc, St);
106 106
 		true -> 
107 107
 			St
108 108
     end;
109 109
 handle_end(test, Data, St) ->
110 110
 	io:format("test end ~p~n", [Data]),
111  
-	Desc = proplists:get_value(desc, Data),
  111
+	Desc = make_atom(proplists:get_value(desc, Data)),
112 112
    	Line = proplists:get_value(line, Data, 0),
113 113
 	Source = case proplists:get_value(source, Data) of 
114 114
 				 {SM, SF, SA} ->
@@ -117,7 +117,7 @@ handle_end(test, Data, St) ->
117 117
 					 {[], [], 0}
118 118
 			 end,
119 119
 	Group = case St of
120  
-				[H | _T] -> make_list(H);
  120
+				[H | _T] -> make_atom(H);
121 121
 				_ ->
122 122
 					""
123 123
 			end,
@@ -137,16 +137,17 @@ handle_end(test, Data, St) ->
137 137
 handle_cancel(group, Data, St) ->
138 138
 	io:format("group canceled ~p~n", [Data]),
139 139
 	Desc = proplists:get_value(desc, Data),
  140
+	Res = cancel_info(Data),
  141
+	erlide_jrpc:event(?TEVENT, {gcanceled, make_atom(Desc), Res}),
140 142
 	if Desc =/= "", Desc =/= undefined ->
141  
-    		Res = cancel_info(Data),
142  
-			erlide_jrpc:event(?TEVENT, {gcanceled, make_list(Desc), Res}),
143 143
 			lists:delete(Desc, St);
144 144
 	   true ->
145 145
 		   St
146 146
 	end;
147 147
 handle_cancel(test, Data, St) ->
148 148
 	io:format("test canceled ~p~n", [Data]),
149  
-	Desc = proplists:get_value(desc, Data),
  149
+	erlide_jrpc:event(?TEVENT, canceled),
  150
+	Desc = make_atom(proplists:get_value(desc, Data)),
150 151
    	Line = proplists:get_value(line, Data, 0),
151 152
 	Res = cancel_info(Data),
152 153
 	Source = case proplists:get_value(source, Data) of 
@@ -156,7 +157,7 @@ handle_cancel(test, Data, St) ->
156 157
 					 {[], [], 0}
157 158
 			 end,
158 159
 	Group = case St of
159  
-				[H | _T] -> make_list(H);
  160
+				[H | _T] -> make_atom(H);
160 161
 				_ ->
161 162
 					""
162 163
 			end,
@@ -171,24 +172,26 @@ handle_cancel(test, Data, St) ->
171 172
 cancel_info(Data) ->
172 173
 	case proplists:get_value(reason, Data) of
173 174
     	undefined ->
174  
-			"skipped";
  175
+			'skipped';
175 176
     	timeout ->
176  
-        	"timed out";
  177
+        	'timeout';
177 178
         {startup, Reason} ->
178  
-			io_lib:format("could not start test process\n::~P\n\n",
179  
-          [Reason, 15]);
  179
+			list_to_atom(io_lib:format("could not start test process\n::~P\n\n",
  180
+          [Reason, 15]));
180 181
 		{blame, _SubId} ->
181  
-			"cancelled because of subtask";
  182
+			'cancelled because of subtask';
182 183
 		{exit, Reason} ->
183  
-			io_lib:format("unexpected termination of test process\n::~P\n\n",
184  
-          [Reason, 15]);
185  
-		{abort, _Reason} ->
186  
-			"aborted"		%%!!! 
  184
+			list_to_atom(io_lib:format("unexpected termination of test process\n::~P\n\n",
  185
+          [Reason, 15]));
  186
+		{abort, Reason} ->
  187
+			Reason
187 188
     end.
188 189
 
189  
-make_list(H) when is_binary(H) ->
190  
-	binary_to_list(H);
191  
-make_list(H) ->
  190
+make_atom(H) when is_binary(H) ->
  191
+	list_to_atom(binary_to_list(H));
  192
+make_atom(H) when is_list(H) ->
  193
+	list_to_atom(H);
  194
+make_atom(H) ->
192 195
 	H.
193 196
 
194 197
 

0 notes on commit a152e63

Please sign in to comment.
Something went wrong with that request. Please try again.