1# This file is part of GNU pies testsuite. -*- autotest -*-
2# Copyright (C) 2019-2020 Sergey Poznyakoff
3#
4# GNU pies is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# GNU pies is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with GNU pies.  If not, see <http://www.gnu.org/licenses/>.
16
17AT_SETUP([Detecting cyclic dependencies])
18
19AT_CHECK([
20PIES_XFAIL_CHECK
21# The following matrices describe the test.conf configuration file below.
22#
23# Dependency matrix:
24#     0  1  2  3  4  5  6  7
25#  0     X     X
26#  1     X
27#  2              X
28#  3        X
29#  4  X
30#  5
31#  6                       X
32#  7
33#
34# Transitive closure:
35#     0  1  2  3  4  5  6  7
36#  0  X  X  X  X  X
37#  1     X
38#  2  X  X  X  X  X
39#  3  X  X  X  X  X
40#  4  X  X  X  X  X
41#  5
42#  6                       X
43#  7
44#
45# Legend:
46#  0: a
47#  1: b
48#  2: c
49#  3: d
50#  4: e
51#  5: f
52#  6: g
53#  7: h
54
55AT_DATA([test.conf],
56[component a {
57   command "a";
58   prerequisites (b,d);
59}
60
61component b {
62   command "b";
63   prerequisites (b);
64}
65
66component c {
67   command "c";
68   prerequisites (e);
69}
70
71component d {
72   command "d";
73   prerequisites (c);
74}
75
76component e {
77   command "e";
78   prerequisites (a);
79}
80
81component f {
82   command "f";
83}
84
85component g {
86   command "g";
87   prerequisites (h);
88}
89
90component h {
91   command "h";
92}
93])
94
95pies --config-file test.conf --dump-depmap | trimws
96],
97[0],
98[Dependency map:
99    0  1  2
100 0
101 1        X
102 2
103
104Legend:
105 0: f
106 1: g
107 2: h
108],
109[pies: cyclic dependencies detected:
110pies: a -> d -> c -> e -> a
111pies: b -> b
112])
113
114AT_CHECK([
115AT_DATA([test.conf],[
116component a {
117	command "a";
118	prerequisites (b,c);
119}
120component b {
121	command "b";
122	prerequisites (c);
123}
124component c {
125	command "c";
126	prerequisites (d);
127}
128component d {
129	command "d";
130	prerequisites (a);
131}
132])
133pies --config-file test.conf --dump-depmap | trimws
134],
135[0],
136[No components defined
137],
138[pies: cyclic dependencies detected:
139pies: a -> c -> d -> a
140pies: a -> b -> c -> d -> a
141])
142
143AT_CLEANUP
144