File: Makefile.PL

package info (click to toggle)
libtangram-perl 2.04-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 572 kB
  • ctags: 495
  • sloc: perl: 5,061; makefile: 36
file content (106 lines) | stat: -rw-r--r-- 2,263 bytes parent folder | download
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
use ExtUtils::MakeMaker;

eval {use DBI;};
if($@) {
  warn "Couldn't load DBI... Skipping tests.";
  goto NOTESTS;
}

eval {use Set::Object;};
if($@) {
  warn "Couldn't load Set::Object... Skipping tests.";
  goto NOTESTS;
}

use lib '.';
use Tangram::Deploy;

sub yes
{
    print ' (Y/n) ';
    return <STDIN> =~ /^(Y|)$/i;
}

print q{Do you plan to run the regression tests?
(you will need to set up an *EMPTY* database)};

goto NOTESTS unless yes();

my $configured;

if ($ENV{TANGRAM_CONFIG})
{
   print qq{
You have set TANGRAM_CONFIG to $ENV{TANGRAM_CONFIG}.
Should I use it?};
   $configured = yes();
}

if (!$configured && -e 't/CONFIG')
{
   print q{
It looks like there is a 't/CONFIG' file already. It probably contains
connection information from a previous installation. Should I use it?};
   $configured = yes();
}

unless ($configured)
{
   print q{
Please give me the login and password for accessing the test database.
I must be able to create and drop tables in that database.};

   print "\n1) DBI connect string (you can omit the \'DBI:\' part): ";
   my $cs = <STDIN>;
   chop $cs;

   $cs = "DBI:$cs" unless $cs =~ /^DBI\:/i;
   
   print "2) Login: ";
   my $user = <STDIN>;
   chop $user;
   
   print "3) Password: ";
   my $passwd = <STDIN>;
   chop $passwd;

   print <<'MSG';

Thank you. I am going to save this information to 't/CONFIG'.
If you have given me sensitive information, make sure to destroy
the file when the tests have been completed.
MSG

   open CONFIG, '>t/CONFIG' or die "Cannot create 't/CONFIG', reason: $!";
   print CONFIG "$cs\n$user\n$passwd\n";
   close CONFIG;
}

{

    require 't/Springfield.pm';
    print "\nNow I will attempt to connect and prepare the database...";

    local $/;

    if (my $dbh = DBI->connect( $Springfield::cs, $Springfield::user, $Springfield::passwd ))
    {
		do
		{
		  local $dbh->{PrintError};
		  $Springfield::dialect->retreat($Springfield::schema, $dbh);
		};

		$Springfield::dialect->deploy($Springfield::schema, $dbh);
		$dbh->disconnect;
		print "it worked!\nSay 'make test' to run the test suite.\n\n";
    }
}

NOTESTS:

WriteMakefile(
    'NAME'	=> 'Tangram',
    'VERSION_FROM' => 'Tangram.pm', # finds $VERSION
    PREREQ_PM => { 'Set::Object' => 0, DBI => 0 }
);