From 914c56f424742187477b90604acfe7de93dbb5c0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 14 Apr 2011 12:53:21 +0200 Subject: [PATCH] Testscript um auf globale Variablen zu testen, die bei der Umstellung auf lx_office.conf vergessen wurden. --- t/structure/globals.t | 63 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 t/structure/globals.t diff --git a/t/structure/globals.t b/t/structure/globals.t new file mode 100644 index 000000000..b1b351f7a --- /dev/null +++ b/t/structure/globals.t @@ -0,0 +1,63 @@ +#!/usr/bin/perl + +use strict; +use lib 't'; +use Support::Files; + +my (@globals, $testcount); + +BEGIN { + @globals = qw(lxdebug auth myconfig form cgi lx_office_conf locale); + $testcount = scalar(@Support::Files::testitems); +} + +use Test::More tests => $testcount; + +# Capture the TESTOUT from Test::More or Test::Builder for printing errors. +# This will handle verbosity for us automatically. +my $fh; +{ + local $^W = 0; # Don't complain about non-existent filehandles + if (-e \*Test::More::TESTOUT) { + $fh = \*Test::More::TESTOUT; + } elsif (-e \*Test::Builder::TESTOUT) { + $fh = \*Test::Builder::TESTOUT; + } else { + $fh = \*STDOUT; + } +} + +my @testitems = @Support::Files::testitems; + +# at last, here we actually run the test... +my $evilwordsregexp = join('|', @globals); + +foreach my $file (@testitems) { + $file =~ s/\s.*$//; # nuke everything after the first space (#comment) + next if (!$file); # skip null entries + + if (open (FILE, $file)) { # open the file for reading + + my $found_word = ''; + + while (my $file_line = ) { # and go through the file line by line + if ($file_line =~ /([\$%@](?:main)?::(?!$evilwordsregexp)\w+\b)/i) { # found an evil word + $found_word = $1; + last; + } + } + + close (FILE); + + if ($found_word) { + ok(0,"$file: found UNREGISTERED GLOBAL $found_word --WARNING"); + } else { + ok(1,"$file does only contain registered globals"); + } + } else { + ok(0,"could not open $file for globals check --WARNING"); + } +} + +exit 0; + -- 2.20.1