]> git.donarmstrong.com Git - debhelper.git/blobdiff - t/buildsystems/buildsystem_tests
Support absolute paths for builddir.
[debhelper.git] / t / buildsystems / buildsystem_tests
index 031828b7bcc28f38a48d04b55d81da6eedad0cb8..c432d3ecf9cf2bc989fbaaf7f38f2e934a2fe8db 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-use Test::More tests => 227;
+use Test::More tests => 230;
 
 use strict;
 use warnings;
@@ -57,21 +57,27 @@ sub process_stdout {
 }
 
 ### Test Buildsystem class API methods
-is( $BS_CLASS->_canonpath("path/to/the/./nowhere/../../somewhere"),
-    "path/to/somewhere", "_canonpath no1" );
-is( $BS_CLASS->_canonpath("path/to/../forward/../../somewhere"),
-    "somewhere","_canonpath no2" );
-is( $BS_CLASS->_canonpath("path/to/../../../somewhere"),
-    "../somewhere","_canonpath no3" );
-is( $BS_CLASS->_canonpath("./"), ".", "_canonpath no4" );
-is( $BS_CLASS->_rel2rel("path/my/file", "path/my"),
+is( $BS_CLASS->canonpath("path/to/the/./nowhere/../../somewhere"),
+    "path/to/somewhere", "canonpath no1" );
+is( $BS_CLASS->canonpath("path/to/../forward/../../somewhere"),
+    "somewhere","canonpath no2" );
+is( $BS_CLASS->canonpath("path/to/../../../somewhere"),
+    "../somewhere","canonpath no3" );
+is( $BS_CLASS->canonpath("./"), ".", "canonpath no4" );
+is( $BS_CLASS->canonpath("/absolute/path/./somewhere/../to/nowhere"),
+    "/absolute/path/to/nowhere", "canonpath no5" );
+is( $BS_CLASS->_rel2rel("path/my/file", "path/my", "/tmp"),
     "file", "_rel2rel no1" );
-is( $BS_CLASS->_rel2rel("path/dir/file", "path/my"),
+is( $BS_CLASS->_rel2rel("path/dir/file", "path/my", "/tmp"),
     "../dir/file", "_rel2rel no2" );
 is( $BS_CLASS->_rel2rel("file", "/root/path/my", "/root"),
-    "../../file", "_rel2rel no3" );
-is( $BS_CLASS->_rel2rel(".", "."), ".", "_rel2rel no4" );
-is( $BS_CLASS->_rel2rel("path", "path/"), ".", "_rel2rel no5" );
+    "/root/file", "_rel2rel abs no3" );
+is( $BS_CLASS->_rel2rel(".", ".", "/tmp"), ".", "_rel2rel no4" );
+is( $BS_CLASS->_rel2rel("path", "path/", "/tmp"), ".", "_rel2rel no5" );
+is( $BS_CLASS->_rel2rel("/absolute/path", "anybase", "/tmp"),
+    "/absolute/path", "_rel2rel abs no6");
+is( $BS_CLASS->_rel2rel("relative/path", "/absolute/base", "/tmp"),
+    "/tmp/relative/path", "_rel2rel abs no7");
 
 ### Test Buildsystem class path API methods under different configurations
 sub test_buildsystem_paths_api {
@@ -139,7 +145,7 @@ $bs = $BS_CLASS->new(builddir => undef, sourcedir => "autoconf");
 );
 test_buildsystem_paths_api($bs, "default builddir, sourcedir=autoconf", \%tmp);
 
-# Enforce "hard" out of source tree building
+# Enforce out of source tree building
 # sourcedir=builddir=autoconf hence default builddir is implied
 $bs = $BS_CLASS->new(builddir => "autoconf", sourcedir => "autoconf/");
 $bs->enforce_out_of_source_building();
@@ -160,10 +166,10 @@ $bs = $BS_CLASS->new(builddir => "autoconf", sourcedir => "autoconf");
 );
 test_buildsystem_paths_api($bs, "no builddir, sourcedir=autoconf", \%tmp);
 
-# Enforce "soft" out of source tree building when
+# Prefer out of source tree building when
 # sourcedir=builddir=autoconf hence builddir should be dropped.
-$bs->enforce_out_of_source_building("autoconf");
-test_buildsystem_paths_api($bs, "soft out of source enforced, sourcedir=builddir", \%tmp);
+$bs->prefer_out_of_source_building(builddir => "autoconf");
+test_buildsystem_paths_api($bs, "out of source prefered, sourcedir=builddir", \%tmp);
 
 # builddir=bld/dir, sourcedir=autoconf. Should be the same as sourcedir=autoconf.
 $bs = $BS_CLASS->new(builddir => "bld/dir", sourcedir => "autoconf");
@@ -353,17 +359,18 @@ if (defined \$bs) {
 EOF
 }
 
+$tmp = Cwd::getcwd();
 is_deeply( process_stdout("$^X -- - --builddirectory='autoconf/bld dir' --sourcedirectory autoconf",
                           get_load_bs_source(undef, "configure")),
-    [ 'NAME=autoconf', 'builddir=autoconf/bld dir', 'makecmd=make', 'sourcedir=autoconf' ],
+    [ 'NAME=autoconf', 'builddir=autoconf/bld dir', "cwd=$tmp",  'makecmd=make', 'sourcedir=autoconf' ],
     "autoconf autoselection and sourcedir/builddir" );
 
 is_deeply( process_stdout("$^X -- - -Sautoconf -D autoconf", get_load_bs_source("autoconf", "build")),
-    [ 'NAME=autoconf', 'builddir=undef', 'makecmd=make', 'sourcedir=autoconf' ],
+    [ 'NAME=autoconf', 'builddir=undef', "cwd=$tmp", 'makecmd=make', 'sourcedir=autoconf' ],
     "forced autoconf and sourcedir" );
 
 is_deeply( process_stdout("$^X -- - -B -Sautoconf", get_load_bs_source("autoconf", "build")),
-    [ 'NAME=autoconf', "builddir=$default_builddir", 'makecmd=make', 'sourcedir=.' ],
+    [ 'NAME=autoconf', "builddir=$default_builddir", "cwd=$tmp", 'makecmd=make', 'sourcedir=.' ],
     "forced autoconf and default build directory" );
 
 # Build the autoconf test package