start of integration testing
[scpubgit/App-EzPz.git] / lib / App / EzPz / TestSetup.pm
CommitLineData
6b4ac75f 1package App::EzPz::TestSetup;
2
3use IO::All;
4use IPC::System::Simple qw(run);
5use Cwd;
fb960e0e 6use base qw(Exporter);
6b4ac75f 7use strictures 1;
8
9our @EXPORT = qw(create_install create_list);
10
11sub create_install {
12 die "Usage: ezpz-create-test-ezmlm-install ezmlm-source.tgz build-dir install-dir"
13 unless @_ == 3;
14
fb960e0e 15 my ($ezmlm_tarball_path, $build_dir_path, $install_to_path) = @_;
6b4ac75f 16
17 my $ezmlm_tarball = io->file(io->file($ezmlm_tarball_path)->rel2abs);
18
fb960e0e 19 my $cwd = cwd;
6b4ac75f 20
fb960e0e 21 my $build_dir = io->dir(io->dir($build_dir_path)->rel2abs);
22 my $install_to = io->dir(io->dir($install_to_path)->rel2abs);
6b4ac75f 23
24 unless ($build_dir->exists) {
25 $build_dir->mkpath;
26 $build_dir->chdir;
27 run 'tar', 'xzf', $ezmlm_tarball;
fb960e0e 28 chdir($cwd);
6b4ac75f 29 }
30
31 my ($src_dir) = ($build_dir->all_dirs)[0];
32
33 die "No source dir found in ${build_dir}" unless $src_dir;
34
35 foreach my $type (qw(bin etc lib man qmail)) {
36 $src_dir->catfile("conf-${type}")->print($install_to->catdir($type)."\n");
37 }
38
39 $src_dir->chdir;
40
41 run make => 'clean';
42 run 'make';
43 run make => 'man';
44 run './ezmlm-test';
45 $install_to->catdir('bin')->mkpath;
46 run make => 'install';
fb960e0e 47
48 chdir(cwd);
6b4ac75f 49}
50
51sub create_list {
52 die "Usage: ezpz-create-test-ezmlm-list ezmlm-bindir list-base-dir list-name"
53 unless @_ == 3;
54
55 my ($ezmlm_bin_path, $list_base_path, $list_name) = @_;
56
fb960e0e 57 my $ezmlm_bin = io->dir(io->dir($ezmlm_bin_path)->rel2abs);
6b4ac75f 58
fb960e0e 59 my $list_base = io->dir(io->dir($list_base_path)->rel2abs);
6b4ac75f 60
61 run(
62 $ezmlm_bin->catfile('ezmlm-make'),
63 $list_base->catdir($list_name),
64 $list_base->catfile("dot-qmail-for-${list_name}"),
65 $list_name,
66 'example.com'
67 );
fb960e0e 68}
69
701;