annotate testing/utp_1.1/document_utp_results.m @ 52:daf4eab1a51e database-connection-manager tip

Fix. Default password should be [] not an empty string
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:29:47 +0100
parents 409a22968d5e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
44
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
1 % Given a set of results from utp_run, this function attaches additional
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
2 % documentation for each unit test.
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
3 function newResults = document_utp_results(results)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
4
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
5
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
6 for kk=1:numel(results)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
7 fprintf(1, '+ %d documenting %s/%s/%s\n', kk, results(kk).class, results(kk).method, results(kk).num);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
8 newResults(kk) = readUTP(results(kk));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
9 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
10
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
11 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
12
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
13
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
14 function result = readUTP(result)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
15
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
16 filename = result.file;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
17 utpFcn = result.utp;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
18
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
19
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
20 % parse the utp fcn
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
21 parts = regexp(utpFcn, filesep, 'split');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
22 utp = parts{end};
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
23
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
24 if strcmp(utp, 'xx')
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
25 % the utp failed to run
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
26 result.doc.desc = '';
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
27 result.doc.syntax = '';
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
28 result.doc.syntaxCode = '';
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
29 result.doc.algo = '';
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
30 result.doc.algoCode = '';
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
31 return;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
32 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
33
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
34
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
35 fd = fopen(filename);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
36 if fd < 0
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
37 warning('Failed to open %s', filename);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
38
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
39 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
40
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
41 fulltxt = {};
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
42 while ~feof(fd)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
43 fulltxt = [fulltxt {fgetl(fd)}];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
44 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
45
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
46 fclose(fd);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
47
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
48 % parse the txt for this test only
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
49
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
50 % 1) find the utp_XX
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
51 % 2) backtrack to find <TestDescription>
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
52 % 3) read forward to get the end of the fcn (count even closing end's)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
53
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
54 res = regexp(fulltxt, ['result\s*=\s*' utp]);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
55 fcnLine = find(~cellfun('isempty', res));
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
56
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
57 % backtrack to look for the test description start
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
58 line = findLine(fulltxt, '<TestDescription>', fcnLine, true);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
59
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
60 % parse out the test description
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
61 result.doc.desc = parseSection(fulltxt(line:end), utp, '<TestDescription>', '</TestDescription>', result.class, result.method, true, true);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
62
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
63 % parse out the syntax test
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
64 result.doc.syntax = parseSection(fulltxt(line:end), utp, '<SyntaxDescription>', '</SyntaxDescription>', result.class, result.method, true, true);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
65
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
66 % parse out syntax code
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
67 result.doc.syntaxCode = parseSection(fulltxt(line:end), utp, '<SyntaxCode>', '</SyntaxCode>', result.class, result.method, false, false);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
68
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
69 % parse out the algorithm test
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
70 result.doc.algo = parseSection(fulltxt(line:end), utp, '<AlgoDescription>', '</AlgoDescription>', result.class, result.method, true, true);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
71
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
72 % parse out algorithm code
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
73 result.doc.algoCode = parseSection(fulltxt(line:end), utp, '<AlgoCode>', '</AlgoCode>', result.class, result.method, false, false);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
74
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
75
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
76
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
77 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
78
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
79 function line = findLine(lines, tag, startLine, backwards)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
80
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
81
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
82 % backtrack to look for the test description start
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
83 line = startLine;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
84 if backwards
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
85 while line > 0
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
86 try
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
87 if strfind(lines{line}, tag)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
88 break;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
89 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
90 catch
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
91 lines
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
92 line
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
93 tag
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
94 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
95 line = line - 1;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
96 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
97 else
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
98 while line <= numel(lines)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
99 if strfind(lines{line}, tag)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
100 break;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
101 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
102 line = line + 1;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
103 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
104 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
105
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
106 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
107
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
108 function desc = parseSection(lines, utp, startTag, endTag, class, method, stripComments, trimLines)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
109
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
110 % go forward capturing the description until we hit end of the
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
111 % description
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
112 line = 1;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
113 desc = '';
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
114 foundStart = false;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
115 while line < numel(lines)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
116 if strfind(lines{line}, startTag)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
117 foundStart = true;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
118 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
119 if foundStart
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
120 lineTxt = lines{line};
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
121 if stripComments
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
122 lineTxt = strrep(lineTxt, '%', '');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
123 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
124 lineTxt = regexprep(lineTxt, ['%*\s*' startTag], '');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
125 lineTxt = regexprep(lineTxt, ['%*\s*' endTag], '');
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
126 lineTxt = strrep(lineTxt, '<METHOD>', ['[' class '/' method ']']);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
127 if trimLines
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
128 lineTxt = strtrim(lineTxt);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
129 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
130 desc = [desc sprintf('%s\n', lineTxt)];
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
131 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
132 if strfind(lines{line}, endTag)
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
133 break;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
134 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
135 line = line + 1;
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
136 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
137
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
138 desc = strtrim(desc);
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
139
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
140
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
141 end
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
142
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
143
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
144
409a22968d5e Add unit tests
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff changeset
145