]> git.donarmstrong.com Git - debhelper.git/blobdiff - t/buildsystems/buildsystem_tests
New short switches for buildsystem stuff, drop envvars
[debhelper.git] / t / buildsystems / buildsystem_tests
index a2b451a96699f77a7079c1100da94bc0df053235..031828b7bcc28f38a48d04b55d81da6eedad0cb8 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-use Test::More tests => 224;
+use Test::More tests => 227;
 
 use strict;
 use warnings;
@@ -63,12 +63,15 @@ 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"),
     "file", "_rel2rel no1" );
 is( $BS_CLASS->_rel2rel("path/dir/file", "path/my"),
     "../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" );
 
 ### Test Buildsystem class path API methods under different configurations
 sub test_buildsystem_paths_api {
@@ -126,24 +129,24 @@ $bs = $BS_CLASS->new(builddir => undef, sourcedir => "autoconf");
 %tmp = (
        "get_sourcedir()" => "autoconf",
        "get_sourcepath(a/b)" => "autoconf/a/b",
-       "get_builddir()" => "autoconf/$default_builddir",
-       "get_buildpath()" => "autoconf/$default_builddir",
-       "get_buildpath(a/b)" =>  "autoconf/$default_builddir/a/b",
-       "get_source_rel2builddir()" => "..",
-       "get_source_rel2builddir(a/b)" => "../a/b",
-       "get_build_rel2sourcedir()" => "$default_builddir",
-       "get_build_rel2sourcedir(a/b)" => "$default_builddir/a/b",
+       "get_builddir()" => "$default_builddir",
+       "get_buildpath()" => "$default_builddir",
+       "get_buildpath(a/b)" =>  "$default_builddir/a/b",
+       "get_source_rel2builddir()" => "../autoconf",
+       "get_source_rel2builddir(a/b)" => "../autoconf/a/b",
+       "get_build_rel2sourcedir()" => "../$default_builddir",
+       "get_build_rel2sourcedir(a/b)" => "../$default_builddir/a/b",
 );
 test_buildsystem_paths_api($bs, "default builddir, sourcedir=autoconf", \%tmp);
 
-# Enforced out of source tree building
+# Enforce "hard" out of source tree building
 # sourcedir=builddir=autoconf hence default builddir is implied
-$bs = $BS_CLASS->new(builddir => "./autoconf", sourcedir => "autoconf/");
+$bs = $BS_CLASS->new(builddir => "autoconf", sourcedir => "autoconf/");
 $bs->enforce_out_of_source_building();
-test_buildsystem_paths_api($bs, "out of source enforced, sourcedir=autoconf/", \%tmp);
+test_buildsystem_paths_api($bs, "hard out of source enforced, sourcedir=builddir", \%tmp);
 
 # sourcedir=autoconf (builddir should be dropped)
-$bs = $BS_CLASS->new(builddir => ".", sourcedir => "autoconf");
+$bs = $BS_CLASS->new(builddir => "autoconf", sourcedir => "autoconf");
 %tmp = (
        "get_sourcedir()" => "autoconf",
        "get_sourcepath(a/b)" => "autoconf/a/b",
@@ -157,13 +160,18 @@ $bs = $BS_CLASS->new(builddir => ".", sourcedir => "autoconf");
 );
 test_buildsystem_paths_api($bs, "no builddir, sourcedir=autoconf", \%tmp);
 
+# Enforce "soft" 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);
+
 # builddir=bld/dir, sourcedir=autoconf. Should be the same as sourcedir=autoconf.
 $bs = $BS_CLASS->new(builddir => "bld/dir", sourcedir => "autoconf");
 $bs->enforce_in_source_building();
 test_buildsystem_paths_api($bs, "in source enforced, sourcedir=autoconf", \%tmp);
 
-# builddir=../bld/dir (relative to the sourcedir)
-$bs = $BS_CLASS->new(builddir => "../bld/dir/", sourcedir => "autoconf");
+# builddir=../bld/dir (relative to the curdir)
+$bs = $BS_CLASS->new(builddir => "bld/dir/", sourcedir => "autoconf");
 %tmp = (
        "get_sourcedir()" => "autoconf",
        "get_sourcepath(a/b)" => "autoconf/a/b",
@@ -177,10 +185,6 @@ $bs = $BS_CLASS->new(builddir => "../bld/dir/", sourcedir => "autoconf");
 );
 test_buildsystem_paths_api($bs, "builddir=../bld/dir, sourcedir=autoconf", \%tmp);
 
-# Builddir relative to the pwd (same path as above).
-$bs = $BS_CLASS->new(builddir => "./bld/dir", sourcedir => "autoconf");
-test_buildsystem_paths_api($bs, "builddir=./bld/dir, sourcedir=autoconf", \%tmp);
-
 ### Test if all buildsystems can be loaded
 @bs = load_all_buildsystems([ $INC[0] ]);
 @tmp = map { $_->NAME() } @bs;
@@ -220,7 +224,7 @@ $tmpdir = tempdir("tmp.XXXXXX");
 $builddir = "$tmpdir/builddir";
 mkdir $builddir;
 %tmp = (
-       builddir => 'builddir',
+       builddir => "$tmpdir/builddir",
        sourcedir => $tmpdir
 );
 
@@ -349,16 +353,16 @@ if (defined \$bs) {
 EOF
 }
 
-is_deeply( process_stdout("DH_AUTO_OPTIONS='--builddirectory=bld\\ dir --sourcedirectory autoconf' $^X -- -",
+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' ],
-    "dh_auto_options w/space, autoconf autoselection and sourcedir/builddir" );
+    "autoconf autoselection and sourcedir/builddir" );
 
-is_deeply( process_stdout("$^X -- - -cautoconf -d autoconf", get_load_bs_source("autoconf", "build")),
+is_deeply( process_stdout("$^X -- - -Sautoconf -D autoconf", get_load_bs_source("autoconf", "build")),
     [ 'NAME=autoconf', 'builddir=undef', 'makecmd=make', 'sourcedir=autoconf' ],
     "forced autoconf and sourcedir" );
 
-is_deeply( process_stdout("$^X -- - -b -cautoconf", get_load_bs_source("autoconf", "build")),
+is_deeply( process_stdout("$^X -- - -B -Sautoconf", get_load_bs_source("autoconf", "build")),
     [ 'NAME=autoconf', "builddir=$default_builddir", 'makecmd=make', 'sourcedir=.' ],
     "forced autoconf and default build directory" );
 
@@ -370,12 +374,12 @@ sub dh_auto_do_autoconf {
 
        my (@lines, @extra_args);
        my $buildpath = $sourcedir;
-       my @dh_auto_args = ("-d", $sourcedir);
-       my $dh_auto_str = "-d $sourcedir";
+       my @dh_auto_args = ("-D", $sourcedir);
+       my $dh_auto_str = "-D $sourcedir";
        if ($builddir) {
-               push @dh_auto_args, "-b", $builddir;
-               $dh_auto_str .= " -b $builddir";
-               $buildpath .= "/$builddir";
+               push @dh_auto_args, "-B", $builddir;
+               $dh_auto_str .= " -B $builddir";
+               $buildpath = $builddir;
        }
 
        my $do_dh_auto = sub {