Revision 1d91e75c
Von Sven Schöling vor etwa 15 Jahren hinzugefügt
t/001compile.t | ||
---|---|---|
1 |
# -*- Mode: perl; indent-tabs-mode: nil -*- |
|
2 |
# |
|
3 |
# The contents of this file are subject to the Mozilla Public |
|
4 |
# License Version 1.1 (the "License"); you may not use this file |
|
5 |
# except in compliance with the License. You may obtain a copy of |
|
6 |
# the License at http://www.mozilla.org/MPL/ |
|
7 |
# |
|
8 |
# Software distributed under the License is distributed on an "AS |
|
9 |
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
|
10 |
# implied. See the License for the specific language governing |
|
11 |
# rights and limitations under the License. |
|
12 |
# |
|
13 |
# The Original Code are the Bugzilla Tests. |
|
14 |
# |
|
15 |
# The Initial Developer of the Original Code is Zach Lipton |
|
16 |
# Portions created by Zach Lipton are |
|
17 |
# Copyright (C) 2001 Zach Lipton. All |
|
18 |
# Rights Reserved. |
|
19 |
# |
|
20 |
# Contributor(s): Zach Lipton <zach@zachlipton.com> |
|
21 |
|
|
22 |
|
|
23 |
################# |
|
24 |
#Bugzilla Test 1# |
|
25 |
###Compilation### |
|
26 |
|
|
27 |
use strict; |
|
28 |
|
|
29 |
use lib 't'; |
|
30 |
use lib '../modules/override'; |
|
31 |
use lib '../modules/fallback'; |
|
32 |
|
|
33 |
use Support::Files; |
|
34 |
|
|
35 |
use Test::More tests => scalar(@Support::Files::testitems); |
|
36 |
|
|
37 |
# Need this to get the available driver information |
|
38 |
use DBI; |
|
39 |
my @DBI_drivers = DBI->available_drivers; |
|
40 |
|
|
41 |
# Bugzilla requires Perl 5.8.0 now. Checksetup will tell you this if you run it, but |
|
42 |
# it tests it in a polite/passive way that won't make it fail at compile time. We'll |
|
43 |
# slip in a compile-time failure if it's missing here so a tinderbox on < 5.8 won't |
|
44 |
# pass and mistakenly let people think Bugzilla works on any perl below 5.8. |
|
45 |
require 5.008; |
|
46 |
|
|
47 |
# Capture the TESTOUT from Test::More or Test::Builder for printing errors. |
|
48 |
# This will handle verbosity for us automatically. |
|
49 |
my $fh; |
|
50 |
{ |
|
51 |
local $^W = 0; # Don't complain about non-existent filehandles |
|
52 |
if (-e \*Test::More::TESTOUT) { |
|
53 |
$fh = \*Test::More::TESTOUT; |
|
54 |
} elsif (-e \*Test::Builder::TESTOUT) { |
|
55 |
$fh = \*Test::Builder::TESTOUT; |
|
56 |
} else { |
|
57 |
$fh = \*STDOUT; |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
my @testitems = @Support::Files::testitems; |
|
62 |
my $perlapp = "\"$^X\""; |
|
63 |
|
|
64 |
# Test the scripts by compiling them |
|
65 |
|
|
66 |
foreach my $file (@testitems) { |
|
67 |
$file =~ s/\s.*$//; # nuke everything after the first space (#comment) |
|
68 |
next if (!$file); # skip null entries |
|
69 |
|
|
70 |
# Skip mod_perl.pl in all cases. It doesn't compile correctly from the command line. |
|
71 |
if ($file eq 'mod_perl.pl') { |
|
72 |
ok(1, "Skipping mod_perl.pl"); |
|
73 |
next; |
|
74 |
} |
|
75 |
|
|
76 |
# Check that we have a DBI module to support the DB, if this is a database |
|
77 |
# module (but not Schema) |
|
78 |
if ($file =~ m#Bugzilla/DB/([^/]+)\.pm$# && $file ne "Bugzilla/DB/Schema.pm") { |
|
79 |
if (!grep(lc($_) =~ /$1/i, @DBI_drivers)) { |
|
80 |
ok(1,$file." - Skipping, as the DBD module not installed"); |
|
81 |
next; |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
open (FILE,$file); |
|
86 |
my $bang = <FILE>; |
|
87 |
close (FILE); |
|
88 |
my $T = ""; |
|
89 |
if ($bang =~ m/#!\S*perl\s+-.*T/) { |
|
90 |
$T = "T"; |
|
91 |
} |
|
92 |
my $command = "$perlapp -c$T -I modules/fallback -I modules/override $file 2>&1"; |
|
93 |
my $loginfo=`$command`; |
|
94 |
#print '@@'.$loginfo.'##'; |
|
95 |
if ($loginfo =~ /syntax ok$/im) { |
|
96 |
if ($loginfo ne "$file syntax OK\n") { |
|
97 |
ok(0,$file." --WARNING"); |
|
98 |
print $fh $loginfo; |
|
99 |
} else { |
|
100 |
ok(1,$file); |
|
101 |
} |
|
102 |
} else { |
|
103 |
ok(0,$file." --ERROR"); |
|
104 |
print $fh $loginfo; |
|
105 |
} |
|
106 |
} |
|
107 |
|
|
108 |
exit 0; |
t/002goodperl.t | ||
---|---|---|
1 |
# -*- Mode: perl; indent-tabs-mode: nil -*- |
|
2 |
# |
|
3 |
# The contents of this file are subject to the Mozilla Public |
|
4 |
# License Version 1.1 (the "License"); you may not use this file |
|
5 |
# except in compliance with the License. You may obtain a copy of |
|
6 |
# the License at http://www.mozilla.org/MPL/ |
|
7 |
# |
|
8 |
# Software distributed under the License is distributed on an "AS |
|
9 |
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
|
10 |
# implied. See the License for the specific language governing |
|
11 |
# rights and limitations under the License. |
|
12 |
# |
|
13 |
# The Original Code are the Bugzilla Tests. |
|
14 |
# |
|
15 |
# The Initial Developer of the Original Code is Zach Lipton |
|
16 |
# Portions created by Zach Lipton are |
|
17 |
# Copyright (C) 2001 Zach Lipton. All |
|
18 |
# Rights Reserved. |
|
19 |
# |
|
20 |
# Contributor(s): Zach Lipton <zach@zachlipton.com> |
|
21 |
# Jacob Steenhagen <jake@bugzilla.org> |
|
22 |
# David D. Kilzer <ddkilzer@theracingworld.com> |
|
23 |
|
|
24 |
|
|
25 |
################# |
|
26 |
#Bugzilla Test 2# |
|
27 |
####GoodPerl##### |
|
28 |
|
|
29 |
use strict; |
|
30 |
|
|
31 |
use lib 't'; |
|
32 |
|
|
33 |
use Support::Files; |
|
34 |
|
|
35 |
use Test::More tests => (scalar(@Support::Files::testitems) * 3); |
|
36 |
|
|
37 |
my @testitems = @Support::Files::testitems; # get the files to test. |
|
38 |
|
|
39 |
foreach my $file (@testitems) { |
|
40 |
$file =~ s/\s.*$//; # nuke everything after the first space (#comment) |
|
41 |
next if (!$file); # skip null entries |
|
42 |
if (! open (FILE, $file)) { |
|
43 |
ok(0,"could not open $file --WARNING"); |
|
44 |
} |
|
45 |
my $file_line1 = <FILE>; |
|
46 |
close (FILE); |
|
47 |
|
|
48 |
$file =~ m/.*\.(.*)/; |
|
49 |
my $ext = $1; |
|
50 |
|
|
51 |
if ($file_line1 !~ m/^#\!/) { |
|
52 |
ok(1,"$file does not have a shebang"); |
|
53 |
} else { |
|
54 |
my $flags; |
|
55 |
if (!defined $ext || $ext eq "pl") { |
|
56 |
# standalone programs aren't taint checked yet |
|
57 |
$flags = "w"; |
|
58 |
} elsif ($ext eq "pm") { |
|
59 |
ok(0, "$file is a module, but has a shebang"); |
|
60 |
next; |
|
61 |
} elsif ($ext eq "cgi") { |
|
62 |
# cgi files must be taint checked |
|
63 |
$flags = "wT"; |
|
64 |
} else { |
|
65 |
ok(0, "$file has shebang but unknown extension"); |
|
66 |
next; |
|
67 |
} |
|
68 |
|
|
69 |
if ($file_line1 =~ m#^\#\!/usr/bin/perl\s#) { |
|
70 |
if ($file_line1 =~ m#\s-$flags#) { |
|
71 |
ok(1,"$file uses standard perl location and -$flags"); |
|
72 |
} else { |
|
73 |
ok(0,"$file is MISSING -$flags --WARNING"); |
|
74 |
} |
|
75 |
} else { |
|
76 |
ok(0,"$file uses non-standard perl location"); |
|
77 |
} |
|
78 |
} |
|
79 |
} |
|
80 |
|
|
81 |
foreach my $file (@testitems) { |
|
82 |
my $found_use_strict = 0; |
|
83 |
$file =~ s/\s.*$//; # nuke everything after the first space (#comment) |
|
84 |
next if (!$file); # skip null entries |
|
85 |
if (! open (FILE, $file)) { |
|
86 |
ok(0,"could not open $file --WARNING"); |
|
87 |
next; |
|
88 |
} |
|
89 |
while (my $file_line = <FILE>) { |
|
90 |
if ($file_line =~ m/^\s*use strict/) { |
|
91 |
$found_use_strict = 1; |
|
92 |
last; |
|
93 |
} |
|
94 |
} |
|
95 |
close (FILE); |
|
96 |
if ($found_use_strict) { |
|
97 |
ok(1,"$file uses strict"); |
|
98 |
} else { |
|
99 |
ok(0,"$file DOES NOT use strict --WARNING"); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
# Check to see that all error messages use tags (for l10n reasons.) |
|
104 |
foreach my $file (@testitems) { |
|
105 |
$file =~ s/\s.*$//; # nuke everything after the first space (#comment) |
|
106 |
next if (!$file); # skip null entries |
|
107 |
if (! open (FILE, $file)) { |
|
108 |
ok(0,"could not open $file --WARNING"); |
|
109 |
next; |
|
110 |
} |
|
111 |
my $lineno = 0; |
|
112 |
my $error = 0; |
|
113 |
|
|
114 |
while (!$error && (my $file_line = <FILE>)) { |
|
115 |
$lineno++; |
|
116 |
if ($file_line =~ /Throw.*Error\("(.*?)"/) { |
|
117 |
if ($1 =~ /\s/) { |
|
118 |
ok(0,"$file has a Throw*Error call on line $lineno which doesn't use a tag --ERROR"); |
|
119 |
$error = 1; |
|
120 |
} |
|
121 |
} |
|
122 |
} |
|
123 |
|
|
124 |
ok(1,"$file uses Throw*Error calls correctly") if !$error; |
|
125 |
|
|
126 |
close(FILE); |
|
127 |
} |
|
128 |
|
|
129 |
exit 0; |
t/003safesys.t | ||
---|---|---|
1 |
# -*- Mode: perl; indent-tabs-mode: nil -*- |
|
2 |
# |
|
3 |
# The contents of this file are subject to the Mozilla Public |
|
4 |
# License Version 1.1 (the "License"); you may not use this file |
|
5 |
# except in compliance with the License. You may obtain a copy of |
|
6 |
# the License at http://www.mozilla.org/MPL/ |
|
7 |
# |
|
8 |
# Software distributed under the License is distributed on an "AS |
|
9 |
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
|
10 |
# implied. See the License for the specific language governing |
|
11 |
# rights and limitations under the License. |
|
12 |
# |
|
13 |
# The Original Code are the Bugzilla Tests. |
|
14 |
# |
|
15 |
# The Initial Developer of the Original Code is Zach Lipton |
|
16 |
# Portions created by Zach Lipton are |
|
17 |
# Copyright (C) 2001 Zach Lipton. All |
|
18 |
# Rights Reserved. |
|
19 |
# |
|
20 |
# Contributor(s): Zach Lipton <zach@zachlipton.com> |
|
21 |
|
|
22 |
|
|
23 |
################# |
|
24 |
#Bugzilla Test 3# |
|
25 |
###Safesystem#### |
|
26 |
|
|
27 |
use strict; |
|
28 |
|
|
29 |
use lib 't'; |
|
30 |
|
|
31 |
use Support::Files; |
|
32 |
|
|
33 |
use Test::More tests => scalar(@Support::Files::testitems); |
|
34 |
|
|
35 |
# Capture the TESTOUT from Test::More or Test::Builder for printing errors. |
|
36 |
# This will handle verbosity for us automatically. |
|
37 |
my $fh; |
|
38 |
{ |
|
39 |
local $^W = 0; # Don't complain about non-existent filehandles |
|
40 |
if (-e \*Test::More::TESTOUT) { |
|
41 |
$fh = \*Test::More::TESTOUT; |
|
42 |
} elsif (-e \*Test::Builder::TESTOUT) { |
|
43 |
$fh = \*Test::Builder::TESTOUT; |
|
44 |
} else { |
|
45 |
$fh = \*STDOUT; |
|
46 |
} |
|
47 |
} |
|
48 |
|
|
49 |
my @testitems = @Support::Files::testitems; |
|
50 |
my $perlapp = "\"$^X\""; |
|
51 |
|
|
52 |
foreach my $file (@testitems) { |
|
53 |
$file =~ s/\s.*$//; # nuke everything after the first space (#comment) |
|
54 |
next if (!$file); # skip null entries |
|
55 |
my $command = "$perlapp -c -It -MSupport::Systemexec $file 2>&1"; |
|
56 |
my $loginfo=`$command`; |
|
57 |
if ($loginfo =~ /arguments for Support::Systemexec::(system|exec)/im) { |
|
58 |
ok(0,"$file DOES NOT use proper system or exec calls"); |
|
59 |
print $fh $loginfo; |
|
60 |
} else { |
|
61 |
ok(1,"$file uses proper system and exec calls"); |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
exit 0; |
t/004template.t | ||
---|---|---|
1 |
# -*- Mode: perl; indent-tabs-mode: nil -*- |
|
2 |
# |
|
3 |
# The contents of this file are subject to the Mozilla Public |
|
4 |
# License Version 1.1 (the "License"); you may not use this file |
|
5 |
# except in compliance with the License. You may obtain a copy of |
|
6 |
# the License at http://www.mozilla.org/MPL/ |
|
7 |
# |
|
8 |
# Software distributed under the License is distributed on an "AS |
|
9 |
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
|
10 |
# implied. See the License for the specific language governing |
|
11 |
# rights and limitations under the License. |
|
12 |
# |
|
13 |
# The Original Code are the Bugzilla tests. |
|
14 |
# |
|
15 |
# The Initial Developer of the Original Code is Jacob Steenhagen. |
|
16 |
# Portions created by Jacob Steenhagen are |
|
17 |
# Copyright (C) 2001 Jacob Steenhagen. All |
|
18 |
# Rights Reserved. |
|
19 |
# |
|
20 |
# Contributor(s): Jacob Steenhagen <jake@bugzilla.org> |
|
21 |
# Zach Lipton <zach@zachlipton.com> |
|
22 |
# David D. Kilzer <ddkilzer@kilzer.net> |
|
23 |
# Tobias Burnus <burnus@net-b.de> |
|
24 |
# |
|
25 |
|
|
26 |
################# |
|
27 |
#Bugzilla Test 4# |
|
28 |
####Templates#### |
|
29 |
|
|
30 |
use strict; |
|
31 |
|
|
32 |
use lib 't'; |
|
33 |
|
|
34 |
use Support::Templates; |
|
35 |
|
|
36 |
# Bug 137589 - Disable command-line input of CGI.pm when testing |
|
37 |
use CGI qw(-no_debug); |
|
38 |
|
|
39 |
use File::Spec; |
|
40 |
use Template; |
|
41 |
use Test::More tests => ( scalar(@referenced_files) * scalar(@languages) |
|
42 |
+ $num_actual_files ); |
|
43 |
|
|
44 |
# Capture the TESTOUT from Test::More or Test::Builder for printing errors. |
|
45 |
# This will handle verbosity for us automatically. |
|
46 |
my $fh; |
|
47 |
{ |
|
48 |
local $^W = 0; # Don't complain about non-existent filehandles |
|
49 |
if (-e \*Test::More::TESTOUT) { |
|
50 |
$fh = \*Test::More::TESTOUT; |
|
51 |
} elsif (-e \*Test::Builder::TESTOUT) { |
|
52 |
$fh = \*Test::Builder::TESTOUT; |
|
53 |
} else { |
|
54 |
$fh = \*STDOUT; |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
58 |
# Checks whether one of the passed files exists |
|
59 |
sub existOnce { |
|
60 |
foreach my $file (@_) { |
|
61 |
return $file if -e $file; |
|
62 |
} |
|
63 |
return 0; |
|
64 |
} |
|
65 |
|
|
66 |
# Check to make sure all templates that are referenced in |
|
67 |
# Bugzilla exist in the proper place. |
|
68 |
|
|
69 |
foreach my $lang (@languages) { |
|
70 |
foreach my $file (@referenced_files) { |
|
71 |
my @path = map(File::Spec->catfile($_, $file), |
|
72 |
split(':', $include_path{$lang} . ":" . $include_path{"en"})); |
|
73 |
if (my $path = existOnce(@path)) { |
|
74 |
ok(1, "$path exists"); |
|
75 |
} else { |
|
76 |
ok(0, "$file cannot be located --ERROR"); |
|
77 |
print $fh "Looked in:\n " . join("\n ", @path) . "\n"; |
|
78 |
} |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
foreach my $include_path (@include_paths) { |
|
83 |
# Processes all the templates to make sure they have good syntax |
|
84 |
my $provider = Template::Provider->new( |
|
85 |
{ |
|
86 |
INCLUDE_PATH => $include_path , |
|
87 |
# Need to define filters used in the codebase, they don't |
|
88 |
# actually have to function in this test, just be defined. |
|
89 |
# See Template.pm for the actual codebase definitions. |
|
90 |
|
|
91 |
# Initialize templates (f.e. by loading plugins like Hook). |
|
92 |
PRE_PROCESS => "global/initialize.none.tmpl", |
|
93 |
|
|
94 |
FILTERS => |
|
95 |
{ |
|
96 |
html_linebreak => sub { return $_; }, |
|
97 |
no_break => sub { return $_; } , |
|
98 |
js => sub { return $_ } , |
|
99 |
base64 => sub { return $_ } , |
|
100 |
inactive => [ sub { return sub { return $_; } }, 1] , |
|
101 |
closed => [ sub { return sub { return $_; } }, 1] , |
|
102 |
obsolete => [ sub { return sub { return $_; } }, 1] , |
|
103 |
url_quote => sub { return $_ } , |
|
104 |
css_class_quote => sub { return $_ } , |
|
105 |
xml => sub { return $_ } , |
|
106 |
quoteUrls => sub { return $_ } , |
|
107 |
bug_link => [ sub { return sub { return $_; } }, 1] , |
|
108 |
csv => sub { return $_ } , |
|
109 |
unitconvert => sub { return $_ }, |
|
110 |
time => sub { return $_ } , |
|
111 |
wrap_comment => sub { return $_ }, |
|
112 |
none => sub { return $_ } , |
|
113 |
ics => [ sub { return sub { return $_; } }, 1] , |
|
114 |
}, |
|
115 |
} |
|
116 |
); |
|
117 |
|
|
118 |
foreach my $file (@{$actual_files{$include_path}}) { |
|
119 |
my $path = File::Spec->catfile($include_path, $file); |
|
120 |
if (-e $path) { |
|
121 |
my ($data, $err) = $provider->fetch($file); |
|
122 |
|
|
123 |
if (!$err) { |
|
124 |
ok(1, "$file syntax ok"); |
|
125 |
} |
|
126 |
else { |
|
127 |
ok(0, "$file has bad syntax --ERROR"); |
|
128 |
print $fh $data . "\n"; |
|
129 |
} |
|
130 |
} |
|
131 |
else { |
|
132 |
ok(1, "$path doesn't exist, skipping test"); |
|
133 |
} |
|
134 |
} |
|
135 |
|
|
136 |
# check to see that all templates have a version string: |
|
137 |
# disabled for lx-office |
|
138 |
|
|
139 |
# foreach my $file (@{$actual_files{$include_path}}) { |
|
140 |
# my $path = File::Spec->catfile($include_path, $file); |
|
141 |
# open(TMPL, $path); |
|
142 |
# my $firstline = <TMPL>; |
|
143 |
# if ($firstline =~ /\d+\.\d+\@[\w\.-]+/) { |
|
144 |
# ok(1,"$file has a version string"); |
|
145 |
# } else { |
|
146 |
# ok(0,"$file does not have a version string --ERROR"); |
|
147 |
# } |
|
148 |
# close(TMPL); |
|
149 |
# } |
|
150 |
} |
|
151 |
|
|
152 |
exit 0; |
t/005no_tabs.t | ||
---|---|---|
1 |
# -*- Mode: perl; indent-tabs-mode: nil -*- |
|
2 |
# |
|
3 |
# The contents of this file are subject to the Mozilla Public |
|
4 |
# License Version 1.1 (the "License"); you may not use this file |
|
5 |
# except in compliance with the License. You may obtain a copy of |
|
6 |
# the License at http://www.mozilla.org/MPL/ |
|
7 |
# |
|
8 |
# Software distributed under the License is distributed on an "AS |
|
9 |
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
|
10 |
# implied. See the License for the specific language governing |
|
11 |
# rights and limitations under the License. |
|
12 |
# |
|
13 |
# The Original Code are the Bugzilla tests. |
|
14 |
# |
|
15 |
# The Initial Developer of the Original Code is Jacob Steenhagen. |
|
16 |
# Portions created by Jacob Steenhagen are |
|
17 |
# Copyright (C) 2001 Jacob Steenhagen. All |
|
18 |
# Rights Reserved. |
|
19 |
# |
|
20 |
# Contributor(s): Jacob Steenhagen <jake@bugzilla.org> |
|
21 |
# David D. Kilzer <ddkilzer@kilzer.net> |
|
22 |
# |
|
23 |
|
|
24 |
################# |
|
25 |
#Bugzilla Test 5# |
|
26 |
#####no_tabs##### |
|
27 |
|
|
28 |
use strict; |
|
29 |
|
|
30 |
use lib 't'; |
|
31 |
|
|
32 |
use Support::Files; |
|
33 |
use Support::Templates; |
|
34 |
|
|
35 |
use File::Spec; |
|
36 |
use Test::More tests => ( scalar(@Support::Files::testitems) |
|
37 |
+ $Support::Templates::num_actual_files); |
|
38 |
|
|
39 |
my @testitems = @Support::Files::testitems; |
|
40 |
for my $path (@Support::Templates::include_paths) { |
|
41 |
push(@testitems, map(File::Spec->catfile($path, $_), |
|
42 |
Support::Templates::find_actual_files($path))); |
|
43 |
} |
|
44 |
|
|
45 |
foreach my $file (@testitems) { |
|
46 |
open (FILE, "$file"); |
|
47 |
if (grep /\t/, <FILE>) { |
|
48 |
ok(0, "$file contains tabs --WARNING"); |
|
49 |
} else { |
|
50 |
ok(1, "$file has no tabs"); |
|
51 |
} |
|
52 |
close (FILE); |
|
53 |
} |
|
54 |
|
|
55 |
exit 0; |
t/006spellcheck.t | ||
---|---|---|
1 |
# -*- Mode: perl; indent-tabs-mode: nil -*- |
|
2 |
# |
|
3 |
# The contents of this file are subject to the Mozilla Public |
|
4 |
# License Version 1.1 (the "License"); you may not use this file |
|
5 |
# except in compliance with the License. You may obtain a copy of |
|
6 |
# the License at http://www.mozilla.org/MPL/ |
|
7 |
# |
|
8 |
# Software distributed under the License is distributed on an "AS |
|
9 |
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
|
10 |
# implied. See the License for the specific language governing |
|
11 |
# rights and limitations under the License. |
|
12 |
# |
|
13 |
# The Original Code are the Bugzilla Tests. |
|
14 |
# |
|
15 |
# The Initial Developer of the Original Code is Zach Lipton |
|
16 |
# Portions created by Zach Lipton are |
|
17 |
# Copyright (C) 2002 Zach Lipton. All |
|
18 |
# Rights Reserved. |
|
19 |
# |
|
20 |
# Contributor(s): Zach Lipton <zach@zachlipton.com> |
|
21 |
|
|
22 |
|
|
23 |
################# |
|
24 |
#Bugzilla Test 6# |
|
25 |
####Spelling##### |
|
26 |
|
|
27 |
use lib 't'; |
|
28 |
use Support::Files; |
|
29 |
|
|
30 |
BEGIN { # yes the indenting is off, deal with it |
|
31 |
#add the words to check here: |
|
32 |
@evilwords = qw( |
|
33 |
anyways |
|
34 |
arbitary |
|
35 |
databasa |
|
36 |
dependan |
|
37 |
existance |
|
38 |
existant |
|
39 |
paramater |
|
40 |
varsion |
|
41 |
fomr |
|
42 |
); |
|
43 |
|
|
44 |
$testcount = scalar(@Support::Files::testitems); |
|
45 |
} |
|
46 |
|
|
47 |
use Test::More tests => $testcount; |
|
48 |
|
|
49 |
# Capture the TESTOUT from Test::More or Test::Builder for printing errors. |
|
50 |
# This will handle verbosity for us automatically. |
|
51 |
my $fh; |
|
52 |
{ |
|
53 |
local $^W = 0; # Don't complain about non-existent filehandles |
|
54 |
if (-e \*Test::More::TESTOUT) { |
|
55 |
$fh = \*Test::More::TESTOUT; |
|
56 |
} elsif (-e \*Test::Builder::TESTOUT) { |
|
57 |
$fh = \*Test::Builder::TESTOUT; |
|
58 |
} else { |
|
59 |
$fh = \*STDOUT; |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 |
my @testitems = @Support::Files::testitems; |
|
64 |
|
|
65 |
# at last, here we actually run the test... |
|
66 |
my $evilwordsregexp = join('|', @evilwords); |
|
67 |
|
|
68 |
foreach my $file (@testitems) { |
|
69 |
$file =~ s/\s.*$//; # nuke everything after the first space (#comment) |
|
70 |
next if (!$file); # skip null entries |
|
71 |
|
|
72 |
if (open (FILE, $file)) { # open the file for reading |
|
73 |
|
|
74 |
my $found_word = ''; |
|
75 |
|
|
76 |
while (my $file_line = <FILE>) { # and go through the file line by line |
|
77 |
if ($file_line =~ /($evilwordsregexp)/i) { # found an evil word |
|
78 |
$found_word = $1; |
|
79 |
last; |
|
80 |
} |
|
81 |
} |
|
82 |
|
|
83 |
close (FILE); |
|
84 |
|
|
85 |
if ($found_word) { |
|
86 |
ok(0,"$file: found SPELLING ERROR $found_word --WARNING"); |
|
87 |
} else { |
|
88 |
ok(1,"$file does not contain registered spelling errors"); |
|
89 |
} |
|
90 |
} else { |
|
91 |
ok(0,"could not open $file for spellcheck --WARNING"); |
|
92 |
} |
|
93 |
} |
|
94 |
|
|
95 |
exit 0; |
t/011pod.t | ||
---|---|---|
1 |
# -*- Mode: perl; indent-tabs-mode: nil -*- |
|
2 |
# |
|
3 |
# The contents of this file are subject to the Mozilla Public |
|
4 |
# License Version 1.1 (the "License"); you may not use this file |
|
5 |
# except in compliance with the License. You may obtain a copy of |
|
6 |
# the License at http://www.mozilla.org/MPL/ |
|
7 |
# |
|
8 |
# Software distributed under the License is distributed on an "AS |
|
9 |
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
|
10 |
# implied. See the License for the specific language governing |
|
11 |
# rights and limitations under the License. |
|
12 |
# |
|
13 |
# The Original Code are the Bugzilla Tests. |
|
14 |
# |
|
15 |
# Contributor(s): Frédéric Buclin <LpSolit@gmail.com> |
|
16 |
|
|
17 |
|
|
18 |
################## |
|
19 |
#Bugzilla Test 11# |
|
20 |
##POD validation## |
|
21 |
|
|
22 |
use strict; |
|
23 |
|
|
24 |
use lib 't'; |
|
25 |
|
|
26 |
use Support::Files; |
|
27 |
use Pod::Checker; |
|
28 |
|
|
29 |
use Test::More tests => scalar(@Support::Files::testitems); |
|
30 |
|
|
31 |
# Capture the TESTOUT from Test::More or Test::Builder for printing errors. |
|
32 |
# This will handle verbosity for us automatically. |
|
33 |
my $fh; |
|
34 |
{ |
|
35 |
local $^W = 0; # Don't complain about non-existent filehandles |
|
36 |
if (-e \*Test::More::TESTOUT) { |
|
37 |
$fh = \*Test::More::TESTOUT; |
|
38 |
} elsif (-e \*Test::Builder::TESTOUT) { |
|
39 |
$fh = \*Test::Builder::TESTOUT; |
|
40 |
} else { |
|
41 |
$fh = \*STDOUT; |
|
42 |
} |
|
43 |
} |
|
44 |
|
|
45 |
my @testitems = @Support::Files::testitems; |
|
46 |
|
|
47 |
foreach my $file (@testitems) { |
|
48 |
$file =~ s/\s.*$//; # nuke everything after the first space (#comment) |
|
49 |
next if (!$file); # skip null entries |
|
50 |
my $error_count = podchecker($file, $fh); |
|
51 |
if ($error_count < 0) { |
|
52 |
ok(1,"$file does not contain any POD"); |
|
53 |
} elsif ($error_count == 0) { |
|
54 |
ok(1,"$file has correct POD syntax"); |
|
55 |
} else { |
|
56 |
ok(0,"$file has incorrect POD syntax --ERROR"); |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
60 |
exit 0; |
t/README | ||
---|---|---|
1 |
Directory for automated test scripts. |
t/README.de | ||
---|---|---|
1 |
Lx-Office Testumgebung |
|
2 |
|
|
3 |
Mit der hier beschriebenen Testumgebung ist es m?glich, Lx Office |
|
4 |
automatisiert zu testen. Automatische Tests haben den gro?en |
|
5 |
Vorteil, das verschiedene Standardtests nicht immer wieder von |
|
6 |
Hand durchgespielt werden m?ssen, sondern einmal in einem Skript |
|
7 |
verschriftet immer wieder verwendet werden k?nnen. |
|
8 |
Weitere Informationen k?nnen im Wiki nachgelesen und erg?nzt werden: |
|
9 |
http://wiki.lx-system.de/index.php/Automatisiertes_Testen_von_Modulen |
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
Aufbau der Testumgebung |
|
14 |
Im Verzeichnis t/ finden sich alle testrelevanten Skripte.Der |
|
15 |
Aufruf der Tests folgt ?ber |
|
16 |
#perl t/lx-office.t |
|
17 |
|
|
18 |
lx-office.t ruft alle Einzeltests der Reihe nach auf und fasst sie |
|
19 |
?bersichtlich zusammen. Die Einzeltests befinden sich in einem |
|
20 |
Unterordner von t/. Jeder Unterorder enth?lt eine Datei AllTests.t, |
|
21 |
die wiederrum alle einzelnen Tests des Unterordners aufruft. |
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
t/lxtest.conf t/lxtest.conf.default |
|
26 |
F?r die einzelnen Tests werden verschiedene Packetvariablen (globals) |
|
27 |
zur Verf?gung gestellt, um die Testskripte einfach auf |
|
28 |
unterschiedliche Installationen anpassen zu k?nnen und um sich auf |
|
29 |
die selbe Test-Datenbank und denselben Test-Benutzer beziehen zu k?nnen. |
|
30 |
|
|
31 |
Die Datei t/lxtest.conf.default muss zun?chst nach t/lxtest.conf |
|
32 |
kopiert werden. Dann ist die Datei t/lxtest.conf auf die lokalen |
|
33 |
Gegebenheiten anzupassen. Besnders die f?r Selenium n?tigen |
|
34 |
Einstellungen bed?rfen einer ?berarbeitung. |
|
35 |
|
|
36 |
Definiert werden die Variablen in der Datei t/lxtest.conf. |
|
37 |
Aufgerufen werden die Variablen $lxtest->{VARIABLE}. |
|
38 |
Es ist ratsam, die vorhandenen Tests zu untersuchen, um sich ein Bild |
|
39 |
von den M?glichkeiten zu machen. |
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
Selenium |
|
44 |
Selenium ist eine Testsuite, mit der man Browserinteraktionen |
|
45 |
simulieren und die Ergebnisse auswerten kann. Der unschlagbare |
|
46 |
Vorteil von Selenium f?r das Testen von Lx ist es, dass es |
|
47 |
m?glich wird, eine Test-Datenbank in einfachen Schritten |
|
48 |
erstellen zu k?nnen. Um Seleniumtests durchf?hren zu k?nnen, |
|
49 |
ist es n?tig, das Packet Selenium Remote Control (Selenium RC) |
|
50 |
lokal zu installieren (Java Runtime ebenfalls erforderlich). |
|
51 |
Selenium RC gibt es unter: |
|
52 |
http://www.openqa.org/selenium-rc/ |
|
53 |
|
|
54 |
F?r den Betrieb von Selenium ist eine lokale Workstation mit |
|
55 |
Browserumgebung n?tig. |
|
56 |
|
|
57 |
Der Aufruf von selenium erfolgt unter Windows bspw. so: |
|
58 |
C:\java -jar "C:\selenium-remote-control-0.9.0 |
|
59 |
\server\selenium-server.jar" |
|
60 |
|
|
61 |
Unter Linux bspw. so: |
|
62 |
<FIXME> |
|
63 |
|
|
64 |
Die lokalen Einstellungen sind unbedingt in der |
|
65 |
t/lxtest.conf nachzutragen! Weitere Infos unter |
|
66 |
http://www.openqa.org/selenium-rc/ |
|
67 |
|
|
68 |
Dann reicht ein Start von |
|
69 |
#perl t/lx-office.t |
|
70 |
um dem Testskript bei der Arbeit zuzuschauen. |
|
71 |
|
|
72 |
Leider ist es n?tig, auf dem Seleniumserver nach jedem Aufruf |
|
73 |
des Testskripts das Sicherheitszertifikat von LINET Services zu |
|
74 |
akzeptieren, was etwas nervig ist. |
|
75 |
|
|
76 |
|
|
77 |
t/selenium/ |
|
78 |
Der Ordner selenium beinhaltet alle einzelnen selenium Testskripte. |
|
79 |
Aufgerufen werden die Skripte ?ber t/selenium/AllTests.t . |
|
80 |
Neue Tests m?ssen in dieser Datei angemeldet werden. |
|
81 |
Ziel ist es eine Demodatenbank von Lx mit Daten zu f?llen und die |
|
82 |
Abh?ngigkeiten untereinander zu pr?fen. Dazu sind die |
|
83 |
individuellen Testskripte nummeriert (001NAME.t bis 999NAME.t) um |
|
84 |
sie der Reihe nach abzuarbeiten. |
|
85 |
|
|
86 |
Die folgenden Skripte sind bereits installiert: |
|
87 |
|
|
88 |
001CreateTestDatabase.t Erzeugt eine neue Testdatenbank |
|
89 |
002CreateTestUser.t Erzeugt einen neuen Testbenutzer |
|
90 |
... |
|
91 |
... |
|
92 |
998DeleteTestUser.t L?scht den Testbenutzer |
|
93 |
999DeleteTestDatabase.t L?scht die Testdatenbank |
|
94 |
|
|
95 |
Dazwischen befinden sich die Skripte, um eine Demodatenbank |
|
96 |
aufzubauen und zu pr?fen. |
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
t/backend/ |
|
101 |
In diesem Ordner befinden sich Backend Testskripte. |
|
102 |
|
|
103 |
|
|
104 |
|
|
105 |
t/frontend/ |
|
106 |
In diesem Ordner befinden sich Frontend Testskripte, die nicht |
|
107 |
unter selenium getestet werden. |
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
Was wenn ein Test fehlschl?gt? |
|
112 |
Das Fehlschlagen von Tests kann verschiedene Gr?nde haben. |
|
113 |
1. Der Test selbst ist fehlerhaft. |
|
114 |
2. Es haben sich Lx Screens ver?ndert, so das der Test von |
|
115 |
falschen Voraussetzungen ausgeht |
|
116 |
3. Die zu testende Funktion ist fehlerhaft |
|
117 |
|
|
118 |
Nachdem 1. und 2. ausgeschlossen wurden, sollte zu 3. ein Bugreport |
|
119 |
angelegt werden. |
|
120 |
Bugreports unter https://lx-office.linet-services.de/bugzilla/ |
|
121 |
anlegen. |
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
Eigene Tests |
|
126 |
Eigene testskripte k?nnen einfach in die Testumgebung eingebunden |
|
127 |
werden. Die vorhandenen Skripte k?nnen als Anleitung dienen. |
|
128 |
Bei Selenium Tests ist es am leichtesten, mit Firefox und der |
|
129 |
Selenium IDE Extension Testpfade einfach aufzuzeichnen. |
|
130 |
( http://www.openqa.org/selenium-ide/ ) |
|
131 |
Dann werden die Selenium IDE Testaufzeichnungen in Perl |
|
132 |
umgewandelt und angepasst. Fertige Skripte werden mit einer |
|
133 |
laufenden Nummer versehen und in den Ordner t/selenium/ kopiert. |
|
134 |
Dann wird das Skript in der Datei t/selenium/AllTests.t eingef?gt. |
|
135 |
Ein erster Probelauf mit |
|
136 |
#perl t/selenium/AllTests.t sollte den Test absolvieren. |
|
137 |
(Dabei kann es n?tig sein, andere Tests auszukommentieren, weil |
|
138 |
selenium Tests mitunter lange Laufzeiten haben k?nnen, oder weil die Demodatenbank |
|
139 |
und der Benutzer am Ende zu Debugging Zwecken nicht gel?scht werden |
|
140 |
sollen.) |
|
141 |
|
|
142 |
|
t/Support/Files.pm | ||
---|---|---|
1 |
# -*- Mode: perl; indent-tabs-mode: nil -*- |
|
2 |
# |
|
3 |
# The contents of this file are subject to the Mozilla Public |
|
4 |
# License Version 1.1 (the "License"); you may not use this file |
|
5 |
# except in compliance with the License. You may obtain a copy of |
|
6 |
# the License at http://www.mozilla.org/MPL/ |
|
7 |
# |
|
8 |
# Software distributed under the License is distributed on an "AS |
|
9 |
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
|
10 |
# implied. See the License for the specific language governing |
|
11 |
# rights and limitations under the License. |
|
12 |
# |
|
13 |
# The Original Code are the Bugzilla Tests. |
|
14 |
# |
|
15 |
# The Initial Developer of the Original Code is Zach Lipton |
|
16 |
# Portions created by Zach Lipton are |
|
17 |
# Copyright (C) 2001 Zach Lipton. All |
|
18 |
# Rights Reserved. |
|
19 |
# |
|
20 |
# Contributor(s): Zach Lipton <zach@zachlipton.com> |
|
21 |
# Joel Peshkin <bugreport@peshkin.net> |
|
22 |
|
|
23 |
|
|
24 |
package Support::Files; |
|
25 |
|
|
26 |
use File::Find; |
|
27 |
|
|
28 |
# exclude_deps is a hash of arrays listing the files to be excluded |
|
29 |
# if a module is not available |
|
30 |
# |
|
31 |
@additional_files = (); |
|
32 |
%exclude_deps = ( |
|
33 |
'XML::Twig' => ['importxml.pl'], |
|
34 |
'Net::LDAP' => ['Bugzilla/Auth/Verify/LDAP.pm'], |
|
35 |
'Email::Reply' => ['email_in.pl'], |
|
36 |
'Email::MIME::Attachment::Stripper' => ['email_in.pl'] |
|
37 |
); |
|
38 |
|
|
39 |
|
|
40 |
@files = glob('*'); |
|
41 |
find(sub { push(@files, $File::Find::name) if $_ =~ /\.pm$/;}, 'SL'); |
|
42 |
|
|
43 |
sub have_pkg { |
|
44 |
my ($pkg) = @_; |
|
45 |
my ($msg, $vnum, $vstr); |
|
46 |
no strict 'refs'; |
|
47 |
eval { my $p; ($p = $pkg . ".pm") =~ s!::!/!g; require $p; }; |
|
48 |
return !($@); |
|
49 |
} |
|
50 |
|
|
51 |
@exclude_files = (); |
|
52 |
foreach $dep (keys(%exclude_deps)) { |
|
53 |
if (!have_pkg($dep)) { |
|
54 |
push @exclude_files, @{$exclude_deps{$dep}}; |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
58 |
sub isTestingFile { |
|
59 |
my ($file) = @_; |
|
60 |
my $exclude; |
|
61 |
foreach $exclude (@exclude_files) { |
|
62 |
if ($file eq $exclude) { return undef; } # get rid of excluded files. |
|
63 |
} |
|
64 |
|
|
65 |
if ($file =~ /\.cgi$|\.pl$|\.pm$/) { |
|
66 |
return 1; |
|
67 |
} |
|
68 |
my $additional; |
|
69 |
foreach $additional (@additional_files) { |
|
70 |
if ($file eq $additional) { return 1; } |
|
71 |
} |
|
72 |
return undef; |
|
73 |
} |
|
74 |
|
|
75 |
foreach $currentfile (@files) { |
|
76 |
if (isTestingFile($currentfile)) { |
|
77 |
push(@testitems,$currentfile); |
|
78 |
} |
|
79 |
} |
|
80 |
|
|
81 |
|
|
82 |
1; |
t/Support/Systemexec.pm | ||
---|---|---|
1 |
# -*- Mode: perl; indent-tabs-mode: nil -*- |
|
2 |
|
|
3 |
package Support::Systemexec; |
|
4 |
require Exporter; |
|
5 |
@ISA = qw(Exporter); |
|
6 |
@EXPORT = qw(system exec); |
|
7 |
@EXPORT_OK = qw(); |
|
8 |
sub system($$@) { |
|
9 |
1; |
|
10 |
} |
|
11 |
sub exec($$@) { |
|
12 |
1; |
|
13 |
} |
|
14 |
1; |
t/Support/Templates.pm | ||
---|---|---|
1 |
# -*- Mode: perl; indent-tabs-mode: nil -*- |
|
2 |
# |
|
3 |
# The contents of this file are subject to the Mozilla Public |
|
4 |
# License Version 1.1 (the "License"); you may not use this file |
|
5 |
# except in compliance with the License. You may obtain a copy of |
|
6 |
# the License at http://www.mozilla.org/MPL/ |
|
7 |
# |
|
8 |
# Software distributed under the License is distributed on an "AS |
|
9 |
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
|
10 |
# implied. See the License for the specific language governing |
|
11 |
# rights and limitations under the License. |
|
12 |
# |
|
13 |
# The Original Code are the Bugzilla tests. |
|
14 |
# |
|
15 |
# The Initial Developer of the Original Code is Jacob Steenhagen. |
|
16 |
# Portions created by Jacob Steenhagen are |
|
17 |
# Copyright (C) 2001 Jacob Steenhagen. All |
|
18 |
# Rights Reserved. |
|
19 |
# |
|
20 |
# Contributor(s): Jacob Steenhagen <jake@bugzilla.org> |
|
21 |
# David D. Kilzer <ddkilzer@kilzer.net> |
|
22 |
# Tobias Burnus <burnus@net-b.de> |
|
23 |
# |
|
24 |
|
|
25 |
package Support::Templates; |
|
26 |
|
|
27 |
use strict; |
|
28 |
|
|
29 |
use lib 't'; |
|
30 |
use base qw(Exporter); |
|
31 |
@Support::Templates::EXPORT = |
|
32 |
qw(@languages @include_paths %include_path @referenced_files |
|
33 |
%actual_files $num_actual_files); |
|
34 |
use vars qw(@languages @include_paths %include_path @referenced_files |
|
35 |
%actual_files $num_actual_files); |
|
36 |
|
|
37 |
use Support::Files; |
|
38 |
|
|
39 |
use File::Find; |
|
40 |
use File::Spec; |
|
41 |
|
|
42 |
# The available template languages |
|
43 |
@languages = (); |
|
44 |
|
|
45 |
# The colon separated includepath per language |
|
46 |
%include_path = (); |
|
47 |
|
|
48 |
# All include paths |
|
49 |
@include_paths = (); |
|
50 |
|
|
51 |
# Files which are referenced in the cgi files |
|
52 |
@referenced_files = (); |
|
53 |
|
|
54 |
# All files sorted by include_path |
|
55 |
%actual_files = (); |
|
56 |
|
|
57 |
# total number of actual_files |
|
58 |
$num_actual_files = 0; |
|
59 |
|
|
60 |
# Scan for the template available languages and include paths |
|
61 |
#{ |
|
62 |
# opendir(DIR, "templates/webpages") || die "Can't open 'templates': $!"; |
|
63 |
# my @files = grep { /^[a-z-]+$/i } readdir(DIR); |
|
64 |
# closedir DIR; |
|
65 |
# |
|
66 |
# foreach my $langdir (@files) { |
|
67 |
# next if($langdir =~ /^CVS$/i); |
|
68 |
# |
|
69 |
# my $path = File::Spec->catdir('templates', $langdir, 'custom'); |
|
70 |
# my @dirs = (); |
|
71 |
# push(@dirs, $path) if(-d $path); |
|
72 |
# $path = File::Spec->catdir('templates', $langdir, 'extension'); |
|
73 |
# push(@dirs, $path) if(-d $path); |
|
74 |
# $path = File::Spec->catdir('templates', $langdir, 'default'); |
|
75 |
# push(@dirs, $path) if(-d $path); |
|
76 |
# |
|
77 |
# next if(scalar(@dirs) == 0); |
|
78 |
# push(@languages, $langdir); |
|
79 |
# push(@include_paths, @dirs); |
|
80 |
# $include_path{$langdir} = join(":",@dirs); |
|
81 |
# } |
|
82 |
#} |
|
83 |
|
|
84 |
my @files; |
|
85 |
|
|
86 |
# Local subroutine used with File::Find |
|
87 |
sub find_templates { |
|
88 |
# Prune CVS directories |
|
89 |
if (-d $_ && $_ eq 'CVS') { |
|
90 |
$File::Find::prune = 1; |
|
91 |
return; |
|
92 |
} |
|
93 |
|
|
94 |
# Only include files ending in '.html' |
|
95 |
if (-f $_ && $_ =~ m/\.html$/i) { |
|
96 |
my $filename; |
|
97 |
my $local_dir = File::Spec->abs2rel($File::Find::dir, |
|
98 |
$File::Find::topdir); |
|
99 |
|
|
100 |
# File::Spec 3.13 and newer return "." instead of "" if both |
|
101 |
# arguments of abs2rel() are identical. |
|
102 |
$local_dir = "" if ($local_dir eq "."); |
|
103 |
|
|
104 |
if ($local_dir) { |
|
105 |
$filename = File::Spec->catfile($local_dir, $_); |
|
106 |
} else { |
|
107 |
$filename = $_; |
|
108 |
} |
|
109 |
|
|
110 |
push(@files, $filename); |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
# Scan the given template include path for templates |
|
115 |
sub find_actual_files { |
|
116 |
my $include_path = $_[0]; |
|
117 |
@files = (); |
|
118 |
find(\&find_templates, $include_path); |
|
119 |
return @files; |
|
120 |
} |
|
121 |
|
|
122 |
@include_paths = qw(templates/webpages); |
|
123 |
|
|
124 |
foreach my $include_path (@include_paths) { |
|
125 |
$actual_files{$include_path} = [ find_actual_files($include_path) ]; |
|
126 |
$num_actual_files += scalar(@{$actual_files{$include_path}}); |
|
127 |
} |
|
128 |
|
|
129 |
# Scan Bugzilla's perl code looking for templates used and put them |
|
130 |
# in the @referenced_files array to be used by the 004template.t test. |
|
131 |
my %seen; |
|
132 |
|
|
133 |
foreach my $file (@Support::Files::testitems) { |
|
134 |
open (FILE, $file); |
|
135 |
my @lines = <FILE>; |
|
136 |
close (FILE); |
|
137 |
foreach my $line (@lines) { |
|
138 |
# if ($line =~ m/template->process\(\"(.+?)\", .+?\)/) { |
|
139 |
if ($line =~ m/->parse_html_template\((['"])(.+?)\1/) { |
|
140 |
my $template = $2; |
|
141 |
# Ignore templates with $ in the name, since they're |
|
142 |
# probably vars, not real files |
|
143 |
next if $template =~ m/\$/; |
|
144 |
next if $seen{$template}; |
|
145 |
push (@referenced_files, $template); |
|
146 |
$seen{$template} = 1; |
|
147 |
} |
|
148 |
} |
|
149 |
} |
|
150 |
|
|
151 |
1; |
t/backend/README.backend | ||
---|---|---|
1 |
This folder contais the backend testscrips for Lx. |
|
2 |
The Lx backend is the module libery under SL. |
|
3 |
Backend tests don't need selenium, and are only able |
|
4 |
to test local installations. |
t/demolx/AllTests.t | ||
---|---|---|
1 |
#===================================================================== |
|
2 |
# LX-Office ERP |
|
3 |
# Copyright (C) 2006 |
|
4 |
# Web http://www.lx-office.org |
|
5 |
# |
|
6 |
#===================================================================== |
|
7 |
# |
|
8 |
# Author: Udo Spallek |
|
9 |
# Email: udono@gmx.net |
|
10 |
# |
|
11 |
# This program is free software; you can redistribute it and/or modify |
|
12 |
# it under the terms of the GNU General Public License as published by |
|
13 |
# the Free Software Foundation; either version 2 of the License, or |
|
14 |
# (at your option) any later version. |
|
15 |
# |
|
16 |
# This program is distributed in the hope that it will be useful, |
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
# GNU General Public License for more details. |
|
20 |
# You should have received a copy of the GNU General Public License |
|
21 |
# along with this program; if not, write to the Free Software |
|
22 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
23 |
#====================================================================== |
|
24 |
# |
|
25 |
# Selenium Main Caller |
|
26 |
# Call all Selenium scripts from here. To use Selenium tests in |
|
27 |
# Lx-Office you need to Install Selenium Remote Control. Take a look at |
|
28 |
# the README Document for further informatinons on installing Selenium |
|
29 |
# and testing Lx-Office and of course writing your own testcases. |
|
30 |
# |
|
31 |
####################################################################### |
|
32 |
no strict; |
|
33 |
push @INC, ['/t/selenium']; |
|
34 |
use vars qw( $lxdebug $lxtest $sel ); |
|
35 |
use strict; |
|
36 |
use Carp; |
|
37 |
|
|
38 |
use Test::WWW::Selenium; |
|
39 |
use Test::More; |
|
40 |
use IO::Socket; |
|
41 |
|
|
42 |
eval { require('t/lxtest.conf'); }; |
|
43 |
if ($@) { |
|
44 |
diag("No test configuration found in t/lxtest.conf.\n |
|
45 |
Maybe you forget to copy t/lxtest.conf.default to t/lxtest.conf. Exit test...\n"); |
|
46 |
exit 0; |
|
47 |
}; |
|
48 |
|
|
49 |
sub server_is_running { |
|
50 |
return IO::Socket::INET->new(PeerAddr => $ENV{SRC_HOST} || $lxtest->{seleniumhost}, |
|
51 |
PeerPort => $ENV{SRC_PORT} || $lxtest->{seleniumport}, |
|
52 |
); |
|
53 |
} |
|
54 |
if (server_is_running) { |
|
55 |
plan tests => 204; # Need to be cutomized |
|
56 |
} |
|
57 |
else { |
|
58 |
plan skip_all => "No selenium server found! " |
|
59 |
."Maybe you forgot to start it or " |
|
60 |
."the preferences in t/lxtest.conf doesen't fit to your system"; |
|
61 |
# exit 0; |
|
62 |
} |
|
63 |
|
|
64 |
diag('Pretests and initialisation'); |
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
$lxtest->{test_id} = time; # create individual ids by unixtime |
|
69 |
$lxtest->{testuserlogin} = $lxtest->{testlogin} . $lxtest->{test_id}; |
|
70 |
$lxtest->{testuserpasswd} = $lxtest->{test_id}; |
|
71 |
$lxtest->{db} = $lxtest->{db} . $lxtest->{test_id}; |
|
72 |
|
|
73 |
ok(defined $lxtest->{rpw}, "Get root password"); |
|
74 |
|
|
75 |
ok(defined $lxtest->{dbhost}, "found dbhost in config"); |
|
76 |
ok(defined $lxtest->{dbport}, "found dbport in config"); |
|
77 |
ok(defined $lxtest->{dbuser}, "found dbuser in config"); |
|
78 |
ok(defined $lxtest->{dbpasswd}, "found dbpasswd in config"); |
|
79 |
|
|
80 |
$lxtest->{lxadmin} = $lxtest->{lxbaseurl} . "admin.pl?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter"; |
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
eval { $sel = Test::WWW::Selenium->new( |
|
87 |
host => $lxtest->{seleniumhost}, |
|
88 |
port => $lxtest->{seleniumport}, |
|
89 |
browser => $lxtest->{seleniumbrowser}, |
|
90 |
browser_url => $lxtest->{lxadmin}, |
|
91 |
auto_stop => '0', |
|
92 |
); |
|
93 |
}; |
|
94 |
if ($@) { |
|
95 |
diag("No Selenium Server running, or wrong preferences\n\n"); |
|
96 |
exit 0; |
|
97 |
} |
|
98 |
|
|
99 |
ok(defined $sel, 'Creating Selenium Object'); |
|
100 |
|
|
101 |
diag('Starting Selenium tests...'); |
|
102 |
|
|
103 |
opendir(SCRIPTS, 't/selenium/testscripts'); |
|
104 |
my @testscripts = sort readdir(SCRIPTS); |
|
105 |
|
|
106 |
foreach my $script (@testscripts){ |
|
107 |
my $file = "t/selenium/testscripts/" . $script; |
|
108 |
require_ok($file) if ( $script =~ /^\d\d\d.*\.t$/ ); |
|
109 |
} |
|
110 |
exit 1; |
|
111 |
|
|
112 |
$sel=''; # Destroy selenium object |
|
113 |
|
|
114 |
exit 1; |
|
115 |
|
t/demolx/README | ||
---|---|---|
1 |
This directory contains all selenium testscripts for lx-office. |
|
2 |
Selenium testscrips are the prefered way to test the higher lx |
|
3 |
functionalities. For the selenium tests you need to install and |
|
4 |
run a local selenium server on a machine whitch is able to start |
|
5 |
a browser session. See README for more informations. |
|
6 |
|
|
7 |
|
t/demolx/cleanup.pl | ||
---|---|---|
1 |
#===================================================================== |
|
2 |
# LX-Office ERP |
|
3 |
# Copyright (C) 2006 |
|
4 |
# Web http://www.lx-office.org |
|
5 |
# |
|
6 |
#===================================================================== |
|
7 |
# |
|
8 |
# Author: Udo Spallek |
|
9 |
# Email: udono@gmx.net |
|
10 |
# |
|
11 |
# This program is free software; you can redistribute it and/or modify |
|
12 |
# it under the terms of the GNU General Public License as published by |
|
13 |
# the Free Software Foundation; either version 2 of the License, or |
|
14 |
# (at your option) any later version. |
|
15 |
# |
|
16 |
# This program is distributed in the hope that it will be useful, |
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19 |
# GNU General Public License for more details. |
|
20 |
# You should have received a copy of the GNU General Public License |
|
21 |
# along with this program; if not, write to the Free Software |
|
22 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
23 |
#====================================================================== |
|
24 |
# |
|
25 |
# Selenium Cleanup Script |
|
26 |
# To clean up all the messy databases and users while debugging testcases |
|
27 |
# |
|
28 |
####################################################################### |
|
29 |
no strict; |
|
30 |
push @INC, ['/t/selenium']; |
|
31 |
use vars qw( $lxdebug $lxtest $sel ); |
|
32 |
use strict; |
|
33 |
use Carp; |
|
34 |
|
|
35 |
use WWW::Selenium; |
|
36 |
use IO::Socket; |
|
37 |
|
|
38 |
my $cleanedupdb = ''; |
|
39 |
my $cleanedupusers = ''; |
|
40 |
|
|
41 |
eval { require('t/lxtest.conf'); }; |
|
42 |
if ($@) { |
|
43 |
print "No test configuration found in t/lxtest.conf.\n |
|
44 |
Maybe you forget to copy t/lxtest.conf.default to t/lxtest.conf. Exit test...\n"; |
|
45 |
exit 0; |
|
46 |
}; |
|
47 |
|
|
48 |
sub server_is_running { |
|
49 |
return IO::Socket::INET->new(PeerAddr => $ENV{SRC_HOST} || $lxtest->{seleniumhost}, |
|
50 |
PeerPort => $ENV{SRC_PORT} || $lxtest->{seleniumport}, |
|
51 |
); |
|
52 |
} |
|
53 |
if (server_is_running) { |
|
54 |
} |
|
55 |
else { |
|
56 |
exit 0; |
|
57 |
} |
|
58 |
|
|
59 |
$lxtest->{testuserlogin} = $lxtest->{testlogin}; |
|
60 |
$lxtest->{db} = $lxtest->{db}; |
|
61 |
|
|
62 |
$lxtest->{lxadmin} = $lxtest->{lxbaseurl} . "admin.pl?rpw=$lxtest->{rpw}&nextsub=list_users&action=Weiter"; |
|
63 |
|
|
64 |
eval { $sel = WWW::Selenium->new( |
|
65 |
host => $lxtest->{seleniumhost}, |
|
66 |
port => $lxtest->{seleniumport}, |
|
67 |
browser => $lxtest->{seleniumbrowser}, |
|
68 |
browser_url => $lxtest->{lxadmin}, |
|
69 |
auto_stop => '0', |
|
70 |
); |
|
71 |
}; |
|
72 |
if ($@) { |
|
73 |
print "No Selenium Server running, or wrong preferences\n\n"; |
|
74 |
exit 0; |
|
75 |
} |
|
76 |
|
|
77 |
|
|
78 |
print "\nStarting Testdebugging Cleanup...\n"; |
|
79 |
|
|
80 |
|
|
81 |
### Delete user |
|
82 |
|
|
83 |
$sel->start; |
|
84 |
print "Cleanup all users '$lxtest->{testuserlogin}*'\n"; |
|
85 |
$sel->open($lxtest->{lxadmin}); |
|
86 |
|
|
87 |
my @links= $sel->get_all_links(); |
|
88 |
my $testuserlogin = $lxtest->{testuserlogin}; |
|
89 |
|
|
90 |
foreach my $link (@links) { |
|
91 |
|
|
92 |
if ($link =~ /$testuserlogin\d\d\d\d\d\d\d\d\d\d/){ |
|
93 |
$sel->click("link=$lxtest->{testuserlogin}11*"); |
|
94 |
$sel->wait_for_page_to_load($lxtest->{timeout}); |
|
95 |
$sel->click("//input[(\@name=\"action\") and (\@value=\"L?schen\")]"); |
|
96 |
$sel->wait_for_page_to_load($lxtest->{timeout}); |
|
97 |
$cleanedupusers .= " $link\n"; |
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
print "Lock the system\n"; |
|
102 |
$sel->click("//input[(\@name=\"action\") and (\@value=\"System sperren\")]"); |
|
103 |
$sel->wait_for_page_to_load($lxtest->{timeout}); |
|
104 |
|
|
105 |
print "Cleanup all test databasees: '$lxtest->{db}*'\n"; |
|
106 |
|
|
107 |
$sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbankadministration\")]"); |
|
108 |
$sel->wait_for_page_to_load($lxtest->{timeout}); |
|
109 |
$sel->type("dbhost", $lxtest->{dbhost}); |
|
110 |
$sel->type("dbport", $lxtest->{dbport}); |
|
111 |
$sel->type("dbuser", $lxtest->{dbuser}); |
|
112 |
$sel->type("dbpasswd", $lxtest->{dbpasswd}); |
|
113 |
|
|
114 |
$sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbank l?schen\")]"); |
|
115 |
$sel->wait_for_page_to_load($lxtest->{timeoutlong}); |
|
116 |
|
|
117 |
my $field = $sel->get_body_text(); |
|
118 |
my $database= $lxtest->{db}; |
|
119 |
my @fields = split(' ', $field); |
|
120 |
|
|
121 |
|
|
122 |
foreach my $field (@fields) { |
|
123 |
|
|
124 |
if ($field =~ /$database\d\d\d\d\d\d\d\d\d\d/){ |
|
125 |
$sel->open($lxtest->{lxadmin}); |
|
126 |
$sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbankadministration\")]"); |
|
127 |
$sel->wait_for_page_to_load($lxtest->{timeout}); |
|
128 |
$sel->type("dbhost", $lxtest->{dbhost}); |
|
129 |
$sel->type("dbport", $lxtest->{dbport}); |
|
130 |
$sel->type("dbuser", $lxtest->{dbuser}); |
|
131 |
$sel->type("dbpasswd", $lxtest->{dbpasswd}); |
|
132 |
|
|
133 |
$sel->click("//input[(\@name=\"action\") and (\@value=\"Datenbank l?schen\")]"); |
|
134 |
$sel->wait_for_page_to_load($lxtest->{timeoutlong}); |
|
135 |
$sel->check("name=db value=$field"); |
|
136 |
$sel->click("//input[(\@name=\"action\") and (\@value=\"Weiter\")]"); |
|
137 |
$cleanedupdb .= " $field\n"; |
|
138 |
|
|
139 |
} |
|
140 |
} |
|
141 |
|
|
142 |
$sel->open($lxtest->{lxadmin}); |
|
143 |
print "Unlock the system\n"; |
|
144 |
|
|
145 |
$sel->click("//input[(\@name=\"action\") and (\@value=\"System entsperren\")]"); |
|
146 |
$sel->wait_for_page_to_load($lxtest->{timeout}); |
|
147 |
|
|
148 |
$cleanedupdb = "none.\n" if ($cleanedupdb eq ''); |
|
149 |
$cleanedupusers = "none.\n" if ($cleanedupusers eq ''); |
|
150 |
|
|
151 |
print "Ready. \nReport:\n--- Cleaned up Users:\n$cleanedupusers---Cleaned up Databases:\n$cleanedupdb"; |
|
152 |
|
|
153 |
$sel->stop; |
|
154 |
|
|
155 |
exit 1; |
|
156 |
|
|
157 |
|
t/demolx/testscripts/001CreateTestDatabase.t | ||
---|---|---|
1 |
### Create Database |
|
2 |
|
|
3 |
$sel->open_ok($lxtest->{lxadmin}); |
|
4 |
$sel->title_is("Lx-Office ERP Administration -"); |
|
5 |
|
|
6 |
diag('Lock the system'); |
|
7 |
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"System sperren\")]"); |
|
8 |
$sel->wait_for_page_to_load_ok($lxtest->{timeout}); |
|
9 |
|
|
10 |
diag("Create test database '$lxtest->{db}'"); |
|
11 |
$sel->title_is("Lx-Office ERP Administration -"); |
|
12 |
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Datenbankadministration\")]"); |
|
13 |
$sel->wait_for_page_to_load_ok($lxtest->{timeout}); |
|
14 |
$sel->title_is("Lx-Office ERP / Datenbankadministration -"); |
|
15 |
$sel->type_ok("dbuser", $lxtest->{dbuser}); |
|
16 |
$sel->type_ok("dbpasswd", $lxtest->{dbpasswd}); |
|
17 |
$sel->type_ok("dbuser", $lxtest->{dbuser}); |
|
18 |
$sel->type_ok("dbhost", $lxtest->{dbhost}); |
|
19 |
$sel->type_ok("dbport", $lxtest->{dbport}); |
|
20 |
$sel->type_ok("dbdefault", $lxtest->{dbdefault}); |
|
21 |
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Datenbank anlegen\")]"); |
|
22 |
$sel->wait_for_page_to_load_ok($lxtest->{timeout}); |
|
23 |
$sel->title_is("Lx-Office ERP Datenbankadministration / Datenbank anlegen -"); |
|
24 |
$sel->type_ok("db", $lxtest->{db}); |
|
25 |
$sel->select_ok("encoding", "label=ISO 8859-1"); |
|
26 |
$sel->click_ok("//input[(\@name=\"chart\") and (\@value=\"Germany-DATEV-SKR03EU\")]"); |
|
27 |
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Weiter\")]"); |
|
28 |
$sel->wait_for_page_to_load_ok($lxtest->{timeoutlong}); |
|
29 |
$sel->title_is("Lx-Office ERP Datenbankadministration / Datenbank anlegen -"); |
|
30 |
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"Weiter\")]"); |
|
31 |
$sel->wait_for_page_to_load_ok($lxtest->{timeout}); |
|
32 |
$sel->title_is("Lx-Office ERP Administration -"); |
|
33 |
|
|
34 |
diag('Unlock the system'); |
|
35 |
$sel->click_ok("//input[(\@name=\"action\") and (\@value=\"System entsperren\")]"); |
|
36 |
$sel->wait_for_page_to_load_ok($lxtest->{timeout}); |
|
37 |
$sel->title_is("Lx-Office ERP Administration -"); |
t/demolx/testscripts/002CreateTestUser.t | ||
---|---|---|
1 |
|
|
2 |
### Create new user |
|
3 |
diag("Create test user '$lxtest->{testuserlogin}'"); |
|
4 |
$sel->open_ok($lxtest->{lxadmin}); |
|
5 |
$sel->title_is("Lx-Office ERP Administration -"); |
|
6 |
$sel->click_ok("action"); |
|
7 |
$sel->wait_for_page_to_load_ok($lxtest->{timeout}); |
|
8 |
$sel->title_is("Lx-Office ERP Administration / Benutzer erfassen -"); |
|
9 |
$sel->type_ok("login", $lxtest->{testuserlogin}); |
|
10 |
$sel->type_ok("password", $lxtest->{testuserpasswd}); |
|
11 |
$sel->type_ok("name", "Selenium"); |
Auch abrufbar als: Unified diff
Automatisierte Syntaxtests, Framework für spätere Modultests.
Selenium Tests nach old verschoben, deprecated.