-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMSAutotest.aspx.cs
343 lines (286 loc) · 16.7 KB
/
MSAutotest.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
public partial class MSAutotest : System.Web.UI.Page
{
string sdkRoot = "C:\\Inetpub\\wwwroot\\sdk\\";
protected void Page_Load(object sender, EventArgs e)
{
string id = this.Request.QueryString["id"];
if (id == null)
return;
string failures = this.Request.QueryString["failures"];
string file = sdkRoot + "build-output/" + id + ".html";
if (!File.Exists(file))
{
Response.Write("The specified file doesn't exists!");
return;
}
// finding out the latest msautotest output
string[] lines = File.ReadAllLines(file);
string[] tokens;
StringBuilder html = new StringBuilder();
for (int i = lines.Length - 1; i >= 0; --i)
{
if (lines[i].Contains("MapServer autotest started"))
{
tokens = lines[i].Split(new string[] {"<a href=\"", " ", "\">stdout</a>", "\">stderr</a>"}, StringSplitOptions.RemoveEmptyEntries);
string resultfile = tokens[1].Replace("http://www.gisinternals.com/sdk/", sdkRoot);
if (!File.Exists(resultfile))
{
resultfile = tokens[1].Replace("http://vbkto.dyndns.org:1280/sdk/", sdkRoot);
if (!File.Exists(resultfile))
{
Response.Write("Unable to find autotest results!");
return;
}
}
// parsing the autotest results
lines = File.ReadAllLines(resultfile);
string autotest_dir = lines[0].Substring(4);
if (!autotest_dir.Contains("E:\\builds"))
autotest_dir = lines[2].Substring(4);
string testdir = "";
string mapfile = "";
string mapfilepath = "";
string results = "";
string requires = "";
List<string> run_params = new List<string>();
List<string> out_files = new List<string>();
int run_count = 0;
string[] renderers = new string[] { "", ".png24", ".png"};
int current_renderer = 0;
html.AppendLine("<h1>Test results for <span class=\"filename\">" + id + "</span></h1>");
html.AppendLine("<p>The raw outputs of the tests are avalilable from these direct links: <a href=\"" + tokens[1] + "\">stdout</a> <a href=\"" + tokens[2] + "\">stderr</a></p>");
if (failures == null)
html.AppendLine("<p>Click <a href=\"MSAutotest.aspx?id=" + id + "&failures=true\">here</a> to show the failures only.</p>");
else
html.AppendLine("<p>Click <a href=\"MSAutotest.aspx?id=" + id + "\">here</a> to show all results.</p>");
for (int j = 1; j < lines.Length; j++)
{
if (lines[j].Contains("cd gdal"))
{
if (testdir != "")
html.AppendLine("</table>");
current_renderer = 0;
html.AppendLine("<h2>gdal test results</h2>");
html.AppendLine("<table>");
html.AppendLine("<tr><th>MapFile</th><th>Result</th><th>Expected File</th><th>Result File</th><th>Requires</th><th>Run Params</th></tr>");
testdir = autotest_dir + "\\gdal\\";
}
if (lines[j].Contains("cd misc"))
{
if (testdir != "")
html.AppendLine("</table>");
current_renderer = 0;
html.AppendLine("<h2>misc test results</h2>");
html.AppendLine("<table>");
html.AppendLine("<tr><th>MapFile</th><th>Result</th><th>Expected File</th><th>Result File</th><th>Requires</th><th>Run Params</th></tr>");
testdir = autotest_dir + "\\misc\\";
}
if (lines[j].Contains("cd wxs"))
{
if (testdir != "")
html.AppendLine("</table>");
current_renderer = 0;
html.AppendLine("<h2>wxs test results</h2>");
html.AppendLine("<table>");
html.AppendLine("<tr><th>MapFile</th><th>Result</th><th>Expected File</th><th>Result File</th><th>Requires</th><th>Run Params</th></tr>");
testdir = autotest_dir + "\\wxs\\";
}
if (lines[j].Contains("cd renderers"))
{
if (testdir != "")
html.AppendLine("</table>");
current_renderer = 1;
html.AppendLine("<h2>renderers test results</h2>");
html.AppendLine("<p>renderer = <span style=\"color:Blue;font-weight:bold\">" + renderers[current_renderer].Substring(1) + "</span></p>");
html.AppendLine("<table>");
html.AppendLine("<tr><th>MapFile</th><th>Result</th><th>Expected File</th><th>Result File</th><th>Requires</th><th>Run Params</th></tr>");
testdir = autotest_dir + "\\renderers\\";
}
if (lines[j].Contains("cd query"))
{
if (testdir != "")
html.AppendLine("</table>");
current_renderer = 0;
html.AppendLine("<h2>query test results</h2>");
html.AppendLine("<table>");
html.AppendLine("<tr><th>MapFile</th><th>Result</th><th>Expected File</th><th>Result File</th><th>Requires</th><th>Run Params</th></tr>");
testdir = autotest_dir + "\\query\\";
}
if (lines[j].StartsWith("Test done"))
{
if (testdir != "")
html.AppendLine("</table>");
// collect summary
StringBuilder summary = new StringBuilder("Summary of the test: ");
summary.Append("<span style=\"color:Green;font-weight:bold\">" + lines[j].Substring(10) + "</span>");
if (++j < lines.Length)
summary.Append(" " + lines[j]);
if (++j < lines.Length)
summary.Append(", " + lines[j]);
if (++j < lines.Length)
summary.Append(", " + lines[j]);
if (++j < lines.Length)
summary.Append(", " + lines[j]);
if (++j < lines.Length && lines[j].Contains("Serious Failure!"))
summary.Append(", " + lines[j].Replace("Serious Failure!", "<span style=\"color:Red;font-weight:bold\">Serious Failure!</span>"));
html.AppendLine("<p>" + summary + "</p>");
if (current_renderer > 0)
++current_renderer;
if (current_renderer == renderers.Length)
current_renderer = 0;
else if (current_renderer > 0)
{
html.AppendLine("<p>renderer = <span style=\"color:Blue;font-weight:bold\">" + renderers[current_renderer].Substring(1) + "</span></p>");
html.AppendLine("<table>");
html.AppendLine("<tr><th>MapFile</th><th>Result</th><th>Expected File</th><th>Result File</th><th>Requires</th><th>Run Params</th></tr>");
}
}
if (lines[j].StartsWith(" test"))
{
string testFile = lines[j].Substring(8);
if (run_params.Count == run_count || testFile != out_files[run_count])
{
// There's something
continue;
}
// read result
if (j < lines.Length - 1)
results = lines[j + 1].Substring(1).Trim().Replace("TEST FAILED", "<span style=\"color:Red;font-weight:bold\">TEST FAILED</span>");
else
results = "";
if (failures != null && !results.Contains("TEST FAILED"))
{
++j;
++run_count;
continue;
}
string expected = testdir + "expected\\" + out_files[run_count];
if (File.Exists(expected))
expected = "<a href=\"ShowFile.aspx?file=" + testdir + "expected\\" + out_files[run_count] + "\">" + out_files[run_count] + "</a>";
else
expected = "";
string result = testdir + "result\\" + out_files[run_count];
if (!results.Contains("results match") && File.Exists(result))
result = "<a href=\"ShowFile.aspx?file=" + testdir + "result\\" + out_files[run_count] + "\">" + out_files[run_count] + "</a>";
else
result = "";
StringBuilder run_param = new StringBuilder(run_params[run_count]);
run_param.Replace("[MAPSERV]", "mapserv.exe");
run_param.Replace("[LEGEND]", "legend.exe");
run_param.Replace("[SCALEBAR]", "scalebar.exe");
run_param.Replace("[SHP2IMG]", "shp2img.exe");
run_param.Replace("[MAPFILE]", mapfile);
run_param.Replace("[RESULT]", out_files[run_count]);
run_param.Replace("[RESULT_DEMIME]", out_files[run_count]);
run_param.Replace("[RESULT_DEVERSION]", out_files[run_count]);
run_param.Replace("[POST]", "\"");
run_param.Replace("[/POST]", "\"");
if (current_renderer > 0)
run_param.Replace("[RENDERER]", "-i " + renderers[current_renderer].Substring(1));
else
run_param.Replace("[RENDERER]", "");
html.AppendLine("<tr><td><a href=\"ShowFile.aspx?file=" + mapfilepath + "\">" + mapfile + "</a></td><td>" + results + "</td><td>" + expected + "</td><td>" + result + "</td><td>" + requires + "</td><td>" + run_param.ToString() + "</td></tr>");
++run_count;
++j; // skip result row
}
if (lines[j].StartsWith(" Processing:"))
{
mapfile = lines[j].Substring(13);
mapfilepath = testdir + mapfile;
requires = "";
if (File.Exists(mapfilepath))
{
string[] maplines = File.ReadAllLines(mapfilepath);
run_params.Clear();
out_files.Clear();
run_count = 0;
foreach (string mapline in maplines)
{
if (mapline.Contains("REQUIRES:"))
requires = mapline.Substring(12).Trim();
else if (mapline.Contains("RUN_PARMS:"))
{
string[] items = mapline.Substring(13).Trim().Split();
if (items.Length >= 2)
{
StringBuilder cmdLine = new StringBuilder(items[1]);
out_files.Add(items[0]);
for (int c = 2; c < items.Length; c++)
{
cmdLine.Append(" " + items[c]);
}
run_params.Add(cmdLine.ToString());
}
else if (items.Length == 1)
{
out_files.Add(items[0]);
run_params.Add("[SHP2IMG] [RENDERER] -m [MAPFILE] -o [RESULT]");
}
}
}
if (run_params.Count == 0)
{
out_files.Add(mapfile.Replace(".map", renderers[current_renderer] + ".png"));
run_params.Add("[SHP2IMG] [RENDERER] -m [MAPFILE] -o [RESULT]");
}
// single test case
if (run_params.Count == 1)
{
// read result
if (j < lines.Length - 1)
results = lines[j + 1].Substring(1).Trim().Replace("TEST FAILED", "<span style=\"color:Red;font-weight:bold\">TEST FAILED</span>");
else
results = "";
if (failures != null && !results.Contains("TEST FAILED"))
{
++j;
continue;
}
string expected = testdir + "expected\\" + out_files[0];
if (File.Exists(expected))
expected = "<a href=\"ShowFile.aspx?file=" + testdir + "expected\\" + out_files[0] + "\">" + out_files[0] + "</a>";
else
expected = "";
string result = testdir + "result\\" + out_files[0];
if (!results.Contains("results match") && File.Exists(result))
result = "<a href=\"ShowFile.aspx?file=" + testdir + "result\\" + out_files[0] + "\">" + out_files[0] + "</a>";
else
result = "";
StringBuilder run_param = new StringBuilder(run_params[0]);
run_param.Replace("[MAPSERV]", "mapserv.exe");
run_param.Replace("[LEGEND]", "legend.exe");
run_param.Replace("[SCALEBAR]", "scalebar.exe");
run_param.Replace("[SHP2IMG]", "shp2img.exe");
run_param.Replace("[MAPFILE]", mapfile);
run_param.Replace("[RESULT]", out_files[0]);
run_param.Replace("[RESULT_DEMIME]", out_files[0]);
run_param.Replace("[RESULT_DEVERSION]", out_files[0]);
run_param.Replace("[POST]", "\"");
run_param.Replace("[/POST]", "\"");
if (current_renderer > 0)
run_param.Replace("[RENDERER]", "-i " + renderers[current_renderer].Substring(1));
else
run_param.Replace("[RENDERER]", "");
html.AppendLine("<tr><td><a href=\"ShowFile.aspx?file=" + mapfilepath + "\">" + mapfile + "</a></td><td>" + results + "</td><td>" + expected + "</td><td>" + result + "</td><td>" + requires + "</td><td>" + run_param.ToString() + "</td></tr>");
++j; // skip result row
}
}
}
}
if (testdir != "")
html.AppendLine("</table>");
break;
}
}
filelistDiv.InnerHtml = html.ToString();
}
}