From bd19f38853dad5a89abada6ee5e7a23c65173894 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Thu, 23 May 2019 13:08:08 +0300 Subject: 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. --- tests/Makefile.am | 1 + tests/atlocal.in | 6 ++- tests/cyclic.at | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/testsuite.at | 2 + 4 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 tests/cyclic.at (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 5ef3796..6c387cb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -41,6 +41,7 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac TESTSUITE_AT = \ testsuite.at\ control.at\ + cyclic.at\ respawn.at\ redirect.at\ ret-exec.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 . + +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 @@ -58,6 +58,8 @@ AT_TESTED([pies]) 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]) m4_include([redirect.at]) -- cgit v1.2.1