source: trunk/essentials/sys-devel/automake-1.7/tests/cond12.test

Last change on this file was 3120, checked in by bird, 18 years ago

automake 1.7.9

File size: 3.6 KB
Line 
1#! /bin/sh
2# Copyright (C) 2001, 2002 Free Software Foundation, Inc.
3#
4# This file is part of GNU Automake.
5#
6# GNU Automake is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2, or (at your option)
9# any later version.
10#
11# GNU Automake is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with autoconf; see the file COPYING. If not, write to
18# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19# Boston, MA 02111-1307, USA.
20
21# Test behavior of variable_conditions_reduce()
22# This checks the result of variable_conditions_reduce() for a wide variety
23# of cases.
24
25. ./defs || exit 1
26
27# FIXME: probably ought to let use override this like we do in `defs'.
28amfile=../../automake
29
30sed 1q $amfile >>automake_tmp
31cat << 'END' >> automake_tmp
32my $failed = 0;
33sub check_reduce($$) {
34 my ($inref, $outref) = @_;
35 my @result = sort &Automake::variable_conditions_reduce(@$inref);
36 my $correct = 1;
37 $correct = 0 if (join(",", @result) ne join(",", @$outref));
38
39 if (! $correct) {
40 print '"'.join(",", @$inref) . '" => "' .
41 join(",", @result) . '" expected "' .
42 join(",", @$outref) . '"' . "\n";
43 $failed = 1;
44 }
45}
46
47# If no conditions are given, TRUE should be returned
48check_reduce([""], ["TRUE"]);
49# A single condition should be passed through unchanged
50check_reduce(["FOO"], ["FOO"]);
51check_reduce(["FALSE"], ["FALSE"]);
52check_reduce(["TRUE"], ["TRUE"]);
53
54# TRUE and false should be discarded and overwhelm the result, respectively
55check_reduce(["FOO", "TRUE"], ["FOO"]);
56check_reduce(["FOO", "FALSE"], ["FALSE"]);
57
58# Repetitions should be removed
59check_reduce(["FOO", "FOO"], ["FOO"]);
60check_reduce(["TRUE", "FOO", "FOO"], ["FOO"]);
61check_reduce(["FOO", "TRUE", "FOO"], ["FOO"]);
62check_reduce(["FOO", "FOO", "TRUE"], ["FOO"]);
63
64# Two different conditions should be preserved, but TRUEs should be removed
65check_reduce(["FOO", "BAR"], ["BAR,FOO"]);
66check_reduce(["TRUE", "FOO", "BAR"], ["BAR,FOO"]);
67check_reduce(["FOO", "TRUE", "BAR"], ["BAR,FOO"]);
68check_reduce(["FOO", "BAR", "TRUE"], ["BAR,FOO"]);
69
70# A condition implied by another condition should be removed.
71check_reduce(["FOO BAR", "BAR"], ["FOO BAR"]);
72check_reduce(["BAR", "FOO BAR"], ["FOO BAR"]);
73check_reduce(["TRUE", "FOO BAR", "BAR"], ["FOO BAR"]);
74check_reduce(["FOO BAR", "TRUE", "BAR"], ["FOO BAR"]);
75check_reduce(["FOO BAR", "BAR", "TRUE"], ["FOO BAR"]);
76
77check_reduce(["BAR FOO", "BAR"], ["BAR FOO"]);
78check_reduce(["BAR", "BAR FOO"], ["BAR FOO"]);
79check_reduce(["TRUE", "BAR FOO", "BAR"], ["BAR FOO"]);
80check_reduce(["BAR FOO", "TRUE", "BAR"], ["BAR FOO"]);
81check_reduce(["BAR FOO", "BAR", "TRUE"], ["BAR FOO"]);
82
83# Check that reduction happens even when there are two conditionals to remove.
84check_reduce(["FOO", "FOO BAR", "BAR"], ["FOO BAR"]);
85check_reduce(["FOO", "FOO BAR", "BAZ", "FOO BAZ"], ["FOO BAR", "FOO BAZ"]);
86check_reduce(["FOO", "FOO BAR", "BAZ", "FOO BAZ", "FOO BAZ BAR"], ["FOO BAZ BAR"]);
87
88# Duplicated conditionals should be removed.
89check_reduce(["FOO", "BAR", "BAR"], ["BAR,FOO"]);
90
91# Equivalent conditionals in different forms should be reduced: which one is
92# left is unfortunately order dependent.
93check_reduce(["BAR FOO", "FOO BAR"], ["FOO BAR"]);
94check_reduce(["FOO BAR", "BAR FOO"], ["BAR FOO"]);
95
96exit $failed;
97END
98cat $amfile >>automake_tmp
99chmod +x automake_tmp
100
101./automake_tmp
Note: See TracBrowser for help on using the repository browser.