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
|
# This script converts the Test House BAT LaTeX documents into
# twiki markup which is suitable for QtUiTest.
sub printTestFunc {
my $funcName = shift(@_);
print " $funcName: function()\n {\n prompt(twiki(\n";
foreach (@_) {
s/\n/\\n/g;
s/\"/\\\"/g;
print "\"$_\"+\n";
}
print "\"\"));\n },\n";
}
$testprefix="QTBATMA_";
$instep = 0;
$indescr = 0;
$insubsection = 0;
$testcounter = 0;
@testlines = ();
@lines = <STDIN>;
print "testcase = {\n\n";
foreach (@lines) {
chomp;
if ($insubsection) {
push @subsectionlines, @templines;
} else {
push @testlines, @templines;
}
@templines = ();
s/(``|'')/\"/g;
s/\\url{(.*)}/%BLUE%$1%ENDCOLOR%/g;
s/\t/ /g;
if (/\\subsection{(.*)}/) {
$insubsection = 1;
@subsectionlines = ();
push @templines, "---++ $1\n";
next;
}
if (/\\subsubsection{(.*)}/) {
if (defined $testname) {
printTestFunc($testname, @testlines);
@testlines = ();
}
if ($insubsection) {
$insubsection = 0;
push @templines, @subsectionlines;
push @templines, "-------\n";
}
$testcounter++;
if ($testcounter < 10) {
$tcs = "0$testcounter";
} else {
$tcs = "$testcounter";
}
$testname = "$testprefix$tcs";
push @templines, "---+++ $testname: $1\n";
next;
}
if (/descr{(.*)}\s*(.*)/) {
push @templines, "---++++ $1\n";
if ($2 ne "") {
push @templines, "$2\n";
}
$indescr = 1;
next;
}
if (/\\begin{(?:short)?stepstable}/) {
$step = 1;
push @templines, "---++++ Steps:\n";
push @templines, "| *No.* | *Description* | *Expected Result* |";
next;
}
if (/\\end{(?:short)?stepstable}/) {
$instep = 0;
push @templines, "\n";
next;
}
if (/\\step\s*(.*)/) {
$instep = 1;
$x = $1;
$x =~ s/\s*(&|\\\\)\s*/ | /g;
push @templines, "\n| $step $x";
$step++;
next;
}
if (/^\s*\\hline/ || /^\s*\\footnote/ || /^\s*\\begin/ || /^\s*\\end/) {
next;
}
if ($instep) {
s/\\item/%BB%/;
} else {
s/\\item/\ */;
}
if ($indescr) {
push @templines, "$_\n";
if (/^\s*$/) {
$indescr=0;
}
next;
}
if ($instep) {
$x = $_;
$x =~ s/\s*(&|\\\\)\s*/ | /g;
push @templines, "$x";
next;
}
}
printTestFunc($testname, @testlines);
print "\n}\n";
|