diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-09 12:53:53 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-09 12:53:53 +0000 |
commit | 90169463f86997737ed5b9c0ea2b311cd3b056b7 (patch) | |
tree | 281a0f8d9850ea58cf2a3ddb8bf087fb52520925 /t/buildsystems/06-buildsystem-mkdir-rmdir.t | |
parent | Initial commit. (diff) | |
download | debhelper-upstream/13.15.3.tar.xz debhelper-upstream/13.15.3.zip |
Adding upstream version 13.15.3.upstream/13.15.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 't/buildsystems/06-buildsystem-mkdir-rmdir.t')
-rwxr-xr-x | t/buildsystems/06-buildsystem-mkdir-rmdir.t | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/t/buildsystems/06-buildsystem-mkdir-rmdir.t b/t/buildsystems/06-buildsystem-mkdir-rmdir.t new file mode 100755 index 0000000..c13b253 --- /dev/null +++ b/t/buildsystems/06-buildsystem-mkdir-rmdir.t @@ -0,0 +1,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(); +} + |