summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorModestas Vainius <modestas@vainius.eu>2009-06-30 00:06:29 +0300
committerModestas Vainius <modestas@vainius.eu>2009-06-30 00:53:07 +0300
commitb90485a4fdfa023848e83c34a6db2fa12905201e (patch)
tree0bd85c33caf41b2de3e4a7242e87f113a3e394b1
parenta6ed7fc6ac9d45733c03e935d1a6e5ec08871944 (diff)
More verbose rmdir_builddir() and more its tests
Signed-off-by: Modestas Vainius <modestas@vainius.eu>
-rw-r--r--Debian/Debhelper/Buildsystem.pm4
-rwxr-xr-xt/buildsystems/buildsystem_tests34
2 files changed, 35 insertions, 3 deletions
diff --git a/Debian/Debhelper/Buildsystem.pm b/Debian/Debhelper/Buildsystem.pm
index 494d229..6eca336 100644
--- a/Debian/Debhelper/Buildsystem.pm
+++ b/Debian/Debhelper/Buildsystem.pm
@@ -338,7 +338,9 @@ sub rmdir_builddir {
# empty parent directories until the source directory level.
if (not File::Spec->file_name_is_absolute($buildpath)) {
while (($peek=pop(@spdir)) && $peek ne '.' && $peek ne '..') {
- last if ! rmdir($this->get_sourcepath(File::Spec->catdir(@spdir, $peek)));
+ my $dir = $this->get_sourcepath(File::Spec->catdir(@spdir, $peek));
+ verbose_print("rmdir $dir");
+ last if ! rmdir($dir);
}
}
}
diff --git a/t/buildsystems/buildsystem_tests b/t/buildsystems/buildsystem_tests
index c432d3e..7e9b4bf 100755
--- a/t/buildsystems/buildsystem_tests
+++ b/t/buildsystems/buildsystem_tests
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-use Test::More tests => 230;
+use Test::More tests => 236;
use strict;
use warnings;
@@ -338,6 +338,36 @@ test_autoselection("cmake",
test => "makefile", install => "makefile", clean => "makefile" }, %tmp);
cleandir $tmpdir;
+### Test Buildsystem::rmdir_builddir()
+sub do_rmdir_builddir {
+ my $builddir=shift;
+ my $system;
+ $system = $BS_CLASS->new(builddir => $builddir, sourcedir => $tmpdir);
+ $system->mkdir_builddir();
+ $system->rmdir_builddir();
+}
+
+$builddir = "$tmpdir/builddir";
+do_rmdir_builddir($builddir);
+ok ( ! -e $builddir, "testing rmdir_builddir() 1: builddir parent '$builddir' deleted" );
+ok ( -d $tmpdir, "testing rmdir_builddir() 1: sourcedir '$tmpdir' remains" );
+
+$builddir = "$tmpdir/bld";
+do_rmdir_builddir("$builddir/dir");
+ok ( ! -e $builddir, "testing rmdir_builddir() 2: builddir parent '$builddir' deleted" );
+ok ( -d $tmpdir, "testing rmdir_builddir() 2: sourcedir '$tmpdir' remains" );
+
+$builddir = "$tmpdir/bld";
+mkdir "$builddir";
+touch "$builddir/afile";
+mkdir "$builddir/dir";
+touch "$builddir/dir/afile2";
+do_rmdir_builddir("$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" );
+
+cleandir $tmpdir;
+
### Test buildsystems_init() and commandline/env argument handling
sub get_load_bs_source {
my ($system, $step)=@_;
@@ -433,7 +463,7 @@ sub dh_auto_do_autoconf {
dh_auto_do_autoconf('autoconf');
dh_auto_do_autoconf('autoconf', 'bld/dir', configure_args => [ "--extra-autoconf-configure-arg" ]);
-ok ( ! -e 'autoconf/bld', "autoconf/bld got deleted too" );
+ok ( ! -e 'bld', "bld got deleted too" );
END {
system("rm", "-rf", $tmpdir);