"alle" E-Mail-Adressen per Anhaken als Empfänger hinzufügen können
[kivitendo-erp.git] / t / structure / globals.t
1 #!/usr/bin/perl
2
3 use strict;
4 use lib 't';
5 use Support::Files;
6 use Support::CanonialGlobals ();
7
8 my (@globals, $testcount);
9
10 BEGIN {
11   @globals = map { s/[^a-z_]//g; $_ } @Support::CanonialGlobals::globals;
12   $testcount = scalar(@Support::Files::testitems);
13 }
14
15
16 use Test::More tests => $testcount;
17
18 # Capture the TESTOUT from Test::More or Test::Builder for printing errors.
19 # This will handle verbosity for us automatically.
20 my $fh;
21 {
22     local $^W = 0;  # Don't complain about non-existent filehandles
23     if (-e \*Test::More::TESTOUT) {
24         $fh = \*Test::More::TESTOUT;
25     } elsif (-e \*Test::Builder::TESTOUT) {
26         $fh = \*Test::Builder::TESTOUT;
27     } else {
28         $fh = \*STDOUT;
29     }
30 }
31
32 my @testitems = @Support::Files::testitems;
33
34 # at last, here we actually run the test...
35 my $evilwordsregexp = join('|', @globals);
36
37 foreach my $file (@testitems) {
38     $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
39     next if (!$file); # skip null entries
40
41     if (open (FILE, $file)) { # open the file for reading
42
43         my $found_word = '';
44
45         while (my $file_line = <FILE>) { # and go through the file line by line
46             if ($file_line =~ /([\$%@](?:main)?::(?!$evilwordsregexp)\w+\b)/i) { # found an evil word
47                 $found_word = $1;
48                 last;
49             }
50         }
51
52         close (FILE);
53
54         if ($found_word) {
55             ok(0,"$file: found UNREGISTERED GLOBAL $found_word --WARNING");
56         } else {
57             ok(1,$file);
58         }
59     } else {
60         ok(0,"could not open $file for globals check --WARNING");
61     }
62 }
63
64 exit 0;
65