>From 99ae26b451f055969be8873aa2cff72f422eeb61 Mon Sep 17 00:00:00 2001 From: Matthias Paulmier Date: Fri, 7 Sep 2018 18:24:21 +0200 Subject: [PATCH 4/4] Modify all tests to use the Test::Simple lib All tests now use the Test::Simple library. We keep the distinction between pl (pure perl) and plt (perl + Test::Simple) in case someone wants to write a perl tests without this lib. - t/pm/*: All tests now use the plt extension and the Test::Simple library. --- t/list-of-tests.mk | 12 +++++----- t/pm/{Condition-t.pl => Condition-t.plt} | 12 ++++++---- t/pm/{Condition.pl => Condition.plt} | 16 ++++++------- ...sjConditions-t.pl => DisjConditions-t.plt} | 12 ++++++---- .../{DisjConditions.pl => DisjConditions.plt} | 14 ++++++----- t/pm/{General.pl => General.plt} | 10 ++++---- t/pm/{Wrap.pl => Wrap.plt} | 23 ++++++++++++------- 7 files changed, 55 insertions(+), 44 deletions(-) rename t/pm/{Condition-t.pl => Condition-t.plt} (96%) rename t/pm/{Condition.pl => Condition.plt} (95%) rename t/pm/{DisjConditions-t.pl => DisjConditions-t.plt} (97%) rename t/pm/{DisjConditions.pl => DisjConditions.plt} (97%) rename t/pm/{General.pl => General.plt} (84%) rename t/pm/{Wrap.pl => Wrap.plt} (77%) diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk index 7cc0e6585..c1ad773a9 100644 --- a/t/list-of-tests.mk +++ b/t/list-of-tests.mk @@ -35,13 +35,13 @@ t/remake-am-pr10111.sh \ t/remake-m4-pr10111.sh perl_TESTS = \ -t/pm/Condition.pl \ -t/pm/Condition-t.pl \ -t/pm/DisjConditions.pl \ -t/pm/DisjConditions-t.pl \ -t/pm/General.pl \ +t/pm/Condition.plt \ +t/pm/Condition-t.plt \ +t/pm/DisjConditions.plt \ +t/pm/DisjConditions-t.plt \ +t/pm/General.plt \ t/pm/Version.plt \ -t/pm/Wrap.pl +t/pm/Wrap.plt perf_TESTS = \ t/perf/cond.sh \ diff --git a/t/pm/Condition-t.pl b/t/pm/Condition-t.plt similarity index 96% rename from t/pm/Condition-t.pl rename to t/pm/Condition-t.plt index 18d30eaf0..364230d82 100644 --- a/t/pm/Condition-t.pl +++ b/t/pm/Condition-t.plt @@ -1,3 +1,4 @@ +# -*- mode:perl -*- # Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify @@ -28,6 +29,7 @@ BEGIN { } } use Automake::Condition qw/TRUE FALSE/; +use Test::Simple tests => 5; sub test_basics () { @@ -303,8 +305,8 @@ sub test_merge () return 0; } -exit (test_basics - || test_true_when - || test_reduce_and - || test_reduce_or - || test_merge); +ok (test_basics == 0, 'Test basic conditions'); +ok (test_true_when == 0, 'Test implied conditions when declaring a new one'); +ok (test_reduce_and == 0, 'Test "and" reduction'); +ok (test_reduce_or == 0, 'Test "or" reduction'); +ok (test_merge == 0, 'Test the merge method'); diff --git a/t/pm/Condition.pl b/t/pm/Condition.plt similarity index 95% rename from t/pm/Condition.pl rename to t/pm/Condition.plt index 58f89b3ae..c019b5fdc 100644 --- a/t/pm/Condition.pl +++ b/t/pm/Condition.plt @@ -1,3 +1,4 @@ +# -*- mode:perl -*- # Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify @@ -14,6 +15,7 @@ # along with this program. If not, see . use Automake::Condition qw/TRUE FALSE/; +use Test::Simple tests => 6; sub test_basics () { @@ -262,7 +264,6 @@ sub test_bad_declarations () my $cond1 = new Automake::Condition ('TRUE'); eval { new Automake::Condition ($cond1) }; - warn $@ if $@; $failed = 1 unless $@; $@ = ''; @@ -271,14 +272,13 @@ sub test_bad_declarations () my $cond2 = new Automake::Condition ("COND1_TRUE"); eval { new Automake::Condition ("$cond2") }; - warn $@ if $@; $failed = 1 unless $@; return $failed; } -exit (test_basics - || test_true_when - || test_reduce_and - || test_reduce_or - || test_merge - || test_bad_declarations); +ok (test_basics == 0, 'Test basic conditions'); +ok (test_true_when == 0, 'Test implied conditions when declaring a new one'); +ok (test_reduce_and == 0, 'Test "and" reduction'); +ok (test_reduce_or == 0, 'Test "or" reduction'); +ok (test_merge == 0, 'Test the merge method'); +ok (test_bad_declarations == 0, 'Test bad condition declarations'); diff --git a/t/pm/DisjConditions-t.pl b/t/pm/DisjConditions-t.plt similarity index 97% rename from t/pm/DisjConditions-t.pl rename to t/pm/DisjConditions-t.plt index 33c6c2d75..976d7a82e 100644 --- a/t/pm/DisjConditions-t.pl +++ b/t/pm/DisjConditions-t.plt @@ -1,3 +1,4 @@ +# -*- mode:perl -*- # Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify @@ -29,6 +30,7 @@ BEGIN { } use Automake::Condition qw/TRUE FALSE/; use Automake::DisjConditions; +use Test::Simple tests => 5; sub test_basics () { @@ -437,8 +439,8 @@ sub test_ambig () return $failed; } -exit (test_basics - || test_invert - || test_simplify - || test_sub_conditions - || test_ambig); +ok (test_basics == 0, 'Basic tests'); +ok (test_invert == 0, 'Test inverts'); +ok (test_simplify == 0, 'Test condition simplifications'); +ok (test_sub_conditions == 0, 'Test sub conditions'); +ok (test_ambig == 0, 'Test ambiguous conditions'); diff --git a/t/pm/DisjConditions.pl b/t/pm/DisjConditions.plt similarity index 97% rename from t/pm/DisjConditions.pl rename to t/pm/DisjConditions.plt index bdcafd2bb..c5ec25be0 100644 --- a/t/pm/DisjConditions.pl +++ b/t/pm/DisjConditions.plt @@ -1,3 +1,4 @@ +# -*- mode:perl -*- # Copyright (C) 2001-2018 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify @@ -15,6 +16,7 @@ use Automake::Condition qw/TRUE FALSE/; use Automake::DisjConditions; +use Test::Simple tests => 6; sub test_basics () { @@ -403,9 +405,9 @@ sub test_bad_declarations return $failed; } -exit (test_basics - || test_invert - || test_simplify - || test_sub_conditions - || test_ambig - || test_bad_declarations); +ok (test_basics == 0, 'Basic tests'); +ok (test_invert == 0, 'Test inverts'); +ok (test_simplify == 0, 'Test condition simplifications'); +ok (test_sub_conditions == 0, 'Test sub conditions'); +ok (test_ambig == 0, 'Test ambiguous conditions'); +ok (test_bad_declarations == 0, 'Test wrong condition declarations'); diff --git a/t/pm/General.pl b/t/pm/General.plt similarity index 84% rename from t/pm/General.pl rename to t/pm/General.plt index 0caefe7cf..645886d9c 100644 --- a/t/pm/General.pl +++ b/t/pm/General.plt @@ -1,3 +1,4 @@ +# -*- mode:perl -*- # Copyright (C) 2018 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify @@ -14,14 +15,11 @@ # along with this program. If not, see . use Automake::General; - -my $failed = 0; +use Test::Simple tests => 2; # Check 'none'. my $none_positive = none { $_[0] < 0 } (1, 7, 3, 8, 9); -$failed = 1 if ($none_positive == 0); +ok ($none_positive != 0, 'Test none on positive values'); my $none_gt_8 = none { $_[0] >= 8 } (1, 7, 3, 8, 9); -$failed = 1 if ($none_gt_8 == 1); - -exit $failed; +ok ($none_gt_8 == 0, 'Test none on values > 8'); diff --git a/t/pm/Wrap.pl b/t/pm/Wrap.plt similarity index 77% rename from t/pm/Wrap.pl rename to t/pm/Wrap.plt index 995569a4f..fdfdab3bf 100644 --- a/t/pm/Wrap.pl +++ b/t/pm/Wrap.plt @@ -1,3 +1,4 @@ +# -*- mode:perl -*- # Copyright (C) 2003-2018 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify @@ -14,8 +15,7 @@ # along with this program. If not, see . use Automake::Wrap qw/wrap makefile_wrap/; - -my $failed = 0; +use Test::Simple tests => 9; sub test_wrap { @@ -25,20 +25,21 @@ sub test_wrap if ($out ne $exp_out) { print STDERR "For: @$in\nGot:\n$out\nInstead of:\n$exp_out\n---\n"; - ++$failed; + return 1; } + return 0; } sub test_makefile_wrap { my ($in, $exp_out) = @_; - my $out = &makefile_wrap (@$in); if ($out ne $exp_out) { print STDERR "For: @$in\nGot:\n$out\nInstead of:\n$exp_out\n---\n"; - ++$failed; + return 1; } + return 0; } my @tests = ( @@ -89,7 +90,13 @@ my @makefile_tests = ( \tunlike in the second line "]); -test_wrap (@{$_}) foreach @tests; -test_makefile_wrap (@{$_}) foreach @makefile_tests; +ok (test_wrap (@{$tests[0]}) == 0, 'test_wrap 0'); +ok (test_wrap (@{$tests[1]}) == 0, 'test_wrap 1'); +ok (test_wrap (@{$tests[2]}) == 0, 'test_wrap 2'); +ok (test_wrap (@{$tests[3]}) == 0, 'test_wrap 3'); +ok (test_wrap (@{$tests[4]}) == 0, 'test_wrap 4'); -exit $failed; +ok (test_makefile_wrap (@{$makefile_tests[0]}) == 0, 'test_makefile_wrap 0'); +ok (test_makefile_wrap (@{$makefile_tests[1]}) == 0, 'test_makefile_wrap 1'); +ok (test_makefile_wrap (@{$makefile_tests[2]}) == 0, 'test_makefile_wrap 2'); +ok (test_makefile_wrap (@{$makefile_tests[3]}) == 0, 'test_makefile_wrap 3'); -- 2.18.0