From 758ce0bb1fbb505aa05f2dd3ac85d7d084b94312 Mon Sep 17 00:00:00 2001 From: Modestas Vainius Date: Wed, 18 Nov 2009 14:16:41 -0500 Subject: Improve build system auto-selection process This patch alters semantics of check_auto_buildable() a bit. Now it can also indicate if the source has already been partitially built with the build system and if so, such build system may be auto-selected over a less specific its parent (in the inheritance tree) even if the latter is earlier in the @BUILDSYSTEMS array. However, this still leaves a requirement that a derivative build system must not do anything that may break packages of the parent build system. Otherwise, introduction of a new derivative build system might break packages which already had that build system implemented via overrides... Signed-off-by: Modestas Vainius --- t/buildsystems/buildsystem_tests | 55 +++++++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 21 deletions(-) (limited to 't') diff --git a/t/buildsystems/buildsystem_tests b/t/buildsystems/buildsystem_tests index 0465a93b..487fd2be 100755 --- a/t/buildsystems/buildsystem_tests +++ b/t/buildsystems/buildsystem_tests @@ -1,6 +1,6 @@ #!/usr/bin/perl -use Test::More tests => 277; +use Test::More tests => 292; use strict; use warnings; @@ -229,14 +229,8 @@ sub test_check_auto_buildable { } elsif (exists $expected->{default}) { $e = $expected->{default}; } - if ($e) { - ok( $bs->check_auto_buildable($step), - $bs->NAME() . "($config): check_auto_buildable($step)" ); - } - else { - ok( ! $bs->check_auto_buildable($step), - $bs->NAME() . "($config): ! check_auto_buildable($step)" ); - } + is( $bs->check_auto_buildable($step), $e, + $bs->NAME() . "($config): check_auto_buildable($step) == $e" ); } } @@ -262,17 +256,18 @@ touch "$tmpdir/configure", 0755; test_check_auto_buildable($bs{autoconf}, "configure", { configure => 1 }); touch "$tmpdir/CMakeLists.txt"; -test_check_auto_buildable($bs{cmake}, "CMakeLists.txt", { configure => 1 }); +test_check_auto_buildable($bs{cmake}, "CMakeLists.txt", 1); touch "$tmpdir/Makefile.PL"; -test_check_auto_buildable($bs{perl_mm}, "Makefile.PL", - { configure => 1, install => 1 }); +test_check_auto_buildable($bs{perl_mm}, "Makefile.PL", { configure => 1 }); # With Makefile touch "$builddir/Makefile"; -test_check_auto_buildable($bs, "Makefile", { configure => 0, default => 1 }); +test_check_auto_buildable($bs, "Makefile", 1); test_check_auto_buildable($bs{autoconf}, "configure+Makefile", { configure => 1 }); test_check_auto_buildable($bs{cmake}, "CMakeLists.txt+Makefile", 1); +touch "$builddir/CMakeCache.txt"; # strong evidence that cmake was run +test_check_auto_buildable($bs{cmake}, "CMakeCache.txt+Makefile", 2); # Makefile.PL forces in-source #(see note in check_auto_buildable() why always 1 here) @@ -298,18 +293,20 @@ cleandir($tmpdir); ### Now test if it can autoselect a proper buildsystem for a typical package sub test_autoselection { - my $system=shift; + my $testname=shift; my $expected=shift; + my %args=@_; for my $step (@STEPS) { my $bs = load_buildsystem(undef, $step, @_); my $e = $expected; $e = $expected->{$step} if ref $expected; if (defined $bs) { - is( $bs->NAME(), $e, "autoselection($system): $step=".((defined $e)?$e:'undef') ); + is( $bs->NAME(), $e, "autoselection($testname): $step=".((defined $e)?$e:'undef') ); } else { - is ( undef, $e, "autoselection($system): $step=".((defined $e)?$e:'undef') ); + is ( undef, $e, "autoselection($testname): $step=".((defined $e)?$e:'undef') ); } + &{$args{"code_$step"}}() if exists $args{"code_$step"}; } } @@ -329,8 +326,7 @@ cleandir $tmpdir; # Makefile touch "$builddir/Makefile"; -test_autoselection("makefile", { build => "makefile", test => "makefile", - install => "makefile", clean => "makefile" }, %tmp); +test_autoselection("makefile", "makefile", %tmp); cleandir $tmpdir; # Python Distutils @@ -345,11 +341,28 @@ test_autoselection("perl_build", "perl_build", %tmp); cleandir $tmpdir; # CMake +touch "$tmpdir/CMakeLists.txt"; +$tmp = sub { + touch "$builddir/Makefile"; +}; +test_autoselection("cmake without CMakeCache.txt", + { configure => "cmake", build => "makefile", + test => "makefile", install => "makefile", clean => "makefile" }, %tmp, + code_configure => $tmp); +cleandir $tmpdir; + +touch "$tmpdir/CMakeLists.txt"; +$tmp = sub { + touch "$builddir/Makefile"; + touch "$builddir/CMakeCache.txt"; +}; +test_autoselection("cmake with CMakeCache.txt", + "cmake", %tmp, code_configure => $tmp); +cleandir $tmpdir; + touch "$tmpdir/CMakeLists.txt"; touch "$builddir/Makefile"; -test_autoselection("cmake", - { configure => "cmake", build => "makefile", - test => "makefile", install => "makefile", clean => "makefile" }, %tmp); +test_autoselection("cmake and existing Makefile", "makefile", %tmp); cleandir $tmpdir; ### Test Buildsystem::rmdir_builddir() -- cgit v1.2.3