~ubuntu-branches/ubuntu/intrepid/bugzilla/intrepid

« back to all changes in this revision

Viewing changes to t/001compile.t

  • Committer: Bazaar Package Importer
  • Author(s): Raphael Bossek
  • Date: 2008-06-27 22:34:34 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080627223434-0ib57vstn43bb4a3
Tags: 3.0.4.1-1
* Update of French, Russian and German translations. (closes: #488251)
* Added Bulgarian and Belarusian translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
31
 
use Support::Files;
32
 
 
33
 
use Test::More tests => scalar(@Support::Files::testitems);
34
 
 
35
 
# Need this to get the available driver information
36
 
use DBI;
37
 
my @DBI_drivers = DBI->available_drivers;
38
 
 
39
 
# Bugzilla requires Perl 5.8.0 now.  Checksetup will tell you this if you run it, but
40
 
# it tests it in a polite/passive way that won't make it fail at compile time.  We'll
41
 
# slip in a compile-time failure if it's missing here so a tinderbox on < 5.8 won't
42
 
# pass and mistakenly let people think Bugzilla works on any perl below 5.8.
43
 
require 5.008;
44
 
 
45
 
# Capture the TESTOUT from Test::More or Test::Builder for printing errors.
46
 
# This will handle verbosity for us automatically.
47
 
my $fh;
48
 
{
49
 
    local $^W = 0;  # Don't complain about non-existent filehandles
50
 
    if (-e \*Test::More::TESTOUT) {
51
 
        $fh = \*Test::More::TESTOUT;
52
 
    } elsif (-e \*Test::Builder::TESTOUT) {
53
 
        $fh = \*Test::Builder::TESTOUT;
54
 
    } else {
55
 
        $fh = \*STDOUT;
56
 
    }
57
 
}
58
 
 
59
 
my @testitems = @Support::Files::testitems;
60
 
my $perlapp = "\"$^X\"";
61
 
 
62
 
# Test the scripts by compiling them
63
 
 
64
 
foreach my $file (@testitems) {
65
 
    $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
66
 
    next if (!$file); # skip null entries
67
 
 
68
 
    # Skip mod_perl.pl in all cases. It doesn't compile correctly from the command line.
69
 
    if ($file eq 'mod_perl.pl') {
70
 
        ok(1, "Skipping mod_perl.pl");
71
 
        next;
72
 
    }
73
 
 
74
 
    # Check that we have a DBI module to support the DB, if this is a database
75
 
    # module (but not Schema)
76
 
    if ($file =~ m#Bugzilla/DB/([^/]+)\.pm$# && $file ne "Bugzilla/DB/Schema.pm") {
77
 
        if (!grep(lc($_) =~ /$1/i, @DBI_drivers)) {
78
 
            ok(1,$file." - Skipping, as the DBD module not installed");
79
 
            next;
80
 
        }
81
 
    }
82
 
 
83
 
    open (FILE,$file);
84
 
    my $bang = <FILE>;
85
 
    close (FILE);
86
 
    my $T = "";
87
 
    if ($bang =~ m/#!\S*perl\s+-.*T/) {
88
 
        $T = "T";
89
 
    }
90
 
    my $command = "$perlapp -c$T $file 2>&1";
91
 
    my $loginfo=`$command`;
92
 
    #print '@@'.$loginfo.'##';
93
 
    if ($loginfo =~ /syntax ok$/im) {
94
 
        if ($loginfo ne "$file syntax OK\n") {
95
 
            ok(0,$file." --WARNING");
96
 
            print $fh $loginfo;
97
 
        } else {
98
 
            ok(1,$file);
99
 
        }
100
 
    } else {
101
 
        ok(0,$file." --ERROR");
102
 
        print $fh $loginfo;
103
 
    }
104
 
}      
105
 
 
106
 
exit 0;