aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-05-23 13:08:08 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-05-23 13:08:08 +0300
commitbd19f38853dad5a89abada6ee5e7a23c65173894 (patch)
tree57b53cdceeb69db1bb51e8df48eb4f007c6ecb97 /tests
parent3ad426f88d274535d7e04e12add72534034ac075 (diff)
downloadpies-bd19f38853dad5a89abada6ee5e7a23c65173894.tar.gz
pies-bd19f38853dad5a89abada6ee5e7a23c65173894.tar.bz2
Revise dependency handling. Correctly display cyclic dependencies.
* src/comp.c (component_log_dep): Remove. (report_cyclic_dependency): New function. (comp_array_remove): New function. (component_build_depmap): Remove erroneous components both from the component table and dependency map. (components_dump_depmap): Avoid trailing whitespace in the output. * src/depmap.c (depmap_clear_all): Remove. (depmap_remove): New function. * src/pies.h (CF_REMOVE): New flag. (depmap_clear_all): Remove prototype. (depmap_remove): New prototype. * tests/Makefile.am: Add new test. * tests/atlocal.in (trimws): New function. * tests/cyclic.at: New test. * tests/testsuite.at: Include new test.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/atlocal.in6
-rw-r--r--tests/cyclic.at114
-rw-r--r--tests/testsuite.at2
4 files changed, 122 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5ef3796..6c387cb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -42,4 +42,5 @@ TESTSUITE_AT = \
testsuite.at\
control.at\
+ cyclic.at\
respawn.at\
redirect.at\
diff --git a/tests/atlocal.in b/tests/atlocal.in
index 2ba1462..9069bbd 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -1,6 +1,10 @@
# @configure_input@ -*- shell-script -*-
# Configurable variable values for GNU Pies test suite.
-# Copyright (C) 2016-2017 Sergey Poznyakoff
+# Copyright (C) 2016-2019 Sergey Poznyakoff
PATH=@abs_builddir@:@abs_top_builddir@/src:$srcdir:$PATH
XFAILFILE=$abs_builddir/.badversion
+
+trimws() {
+ sed 's/[ ][ ]*$//'
+}
diff --git a/tests/cyclic.at b/tests/cyclic.at
new file mode 100644
index 0000000..27da22e
--- /dev/null
+++ b/tests/cyclic.at
@@ -0,0 +1,114 @@
+# This file is part of GNU pies testsuite. -*- Autotest -*-
+# Copyright (C) 2019 Sergey Poznyakoff
+#
+# GNU pies is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU pies is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU pies. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([Detecting cyclic dependencies])
+AT_CHECK([
+PIES_XFAIL_CHECK
+# The following matrices describe the test.conf configuration file below.
+#
+# Dependency matrix:
+# 0 1 2 3 4 5 6 7
+# 0 X X
+# 1 X
+# 2 X
+# 3 X
+# 4 X
+# 5
+# 6 X
+# 7
+#
+# Transitive closure:
+# 0 1 2 3 4 5 6 7
+# 0 X X X X X
+# 1 X
+# 2 X X X X X
+# 3 X X X X X
+# 4 X X X X X
+# 5
+# 6 X
+# 7
+#
+# Legend:
+# 0: a
+# 1: b
+# 2: c
+# 3: d
+# 4: e
+# 5: f
+# 6: g
+# 7: h
+
+AT_DATA([test.conf],
+[component a {
+ command "a";
+ prerequisites (b,d);
+}
+
+component b {
+ command "b";
+ prerequisites (b);
+}
+
+component c {
+ command "c";
+ prerequisites (e);
+}
+
+component d {
+ command "d";
+ prerequisites (c);
+}
+
+component e {
+ command "e";
+ prerequisites (a);
+}
+
+component f {
+ command "f";
+}
+
+component g {
+ command "g";
+ prerequisites (h);
+}
+
+component h {
+ command "h";
+}
+])
+
+pies --config-file test.conf --dump-depmap | trimws
+],
+[0],
+[Dependency map:
+ 0 1 2
+ 0
+ 1 X
+ 2
+
+Legend:
+ 0: f
+ 1: g
+ 2: h
+],
+[pies: component a depends on itself
+pies: a -> d -> c -> e -> a
+pies: component b depends on itself
+pies: b -> b
+])
+
+AT_CLEANUP
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 152b77f..7f4e7b8 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -59,4 +59,6 @@ AT_BANNER([Initial])
m4_include([version.at])
m4_include([control.at])
+AT_BANNER([Dependencies])
+m4_include([cyclic.at])
AT_BANNER([Components])
m4_include([respawn.at])

Return to:

Send suggestions and report system problems to the System administrator.