summaryrefslogtreecommitdiffstats
path: root/t/buildsystems/06-buildsystem-mkdir-rmdir.t
blob: c13b25361b86fd7411bd3017ac8188db1e62d3e7 (plain)
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
#!/usr/bin/perl

use strict;
use warnings;
use Cwd;
use Test::More tests => 6;

use File::Temp qw(tempdir);
use File::Basename qw(dirname);
use lib dirname(dirname(__FILE__));
use File::Path qw(make_path);
use Test::DH;
use Debian::Debhelper::Dh_Lib qw(!dirname);
use Debian::Debhelper::Buildsystem;

chdir(dirname($0)) or die("chdir: $!");
my $TEMP_DIR = tempdir('tmp.XXXXXXX', CLEANUP => 1);
my $sourcedir = $TEMP_DIR;
my $builddir = "${TEMP_DIR}/build";
my $BS_CLASS = 'Debian::Debhelper::Buildsystem';

# Tests

do_rmdir_builddir($sourcedir, $builddir);
ok ( ! -e $builddir, "testing rmdir_builddir() 1: builddir parent '$builddir' deleted" );
ok ( -d $sourcedir, "testing rmdir_builddir() 1: sourcedir '$sourcedir' remains" );

$builddir = "$sourcedir/bld";
do_rmdir_builddir($sourcedir, "$builddir/dir");
ok ( ! -e $builddir, "testing rmdir_builddir() 2: builddir parent '$builddir' deleted" );
ok ( -d $sourcedir, "testing rmdir_builddir() 2: sourcedir '$sourcedir' remains" );

$builddir = "$sourcedir/bld";

make_path($builddir, "$builddir/dir");
create_empty_file("$builddir/afile");
create_empty_file("$builddir/dir/afile2");
do_rmdir_builddir($sourcedir, "$builddir/dir");
ok ( ! -e "$builddir/dir", "testing rmdir_builddir() 3: builddir '$builddir/dir' not empty, but deleted" );
ok ( -d $builddir, "testing rmdir_builddir() 3: builddir parent '$builddir' not empty, remains" );


### Test Buildsystem::rmdir_builddir()
sub do_rmdir_builddir {
	my ($sourcedir, $builddir) = @_;
	my $system;
	$system = $BS_CLASS->new(builddir => $builddir, sourcedir => $sourcedir);
	$system->mkdir_builddir();
	$system->rmdir_builddir();
}