aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2014-12-25 20:15:22 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2014-12-26 01:17:52 +0200
commitadd57c075c6f747a81c142ab48d59106de822664 (patch)
treec15f94acdf135954e2f63ac7657c57cdd134ed75 /tests
parentd51e1365118ce87016a39bd94437e31b35b8d307 (diff)
downloadgrecs-add57c075c6f747a81c142ab48d59106de822664.tar.gz
grecs-add57c075c6f747a81c142ab48d59106de822664.tar.bz2
Add globbing pattern support to #include and #include_once
* doc/grecs-syntax.texi: Document changes to the #include statement. * doc/grecs_config.5: Likewise. * src/preproc.c (include_glob, include_pos) (include_once): New statics. (pp_list_find): Return 0 if list is NULL. (incl_copy): New statics. (source_lookup): Use incl_copy as the copy function. (pop_source): If more glob expansions are available, push next one onto input stack. (isglob): New static. (parse_include): Support globbing patterns. * tests/Makefile.am: Add new testes. * tests/testsuite.at: Likewise. * tests/incl00.at: New test case. * tests/incl01.at: New test case. * tests/incl02.at: New test case. * tests/incl03.at: New test case.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am6
-rw-r--r--tests/incl00.at39
-rw-r--r--tests/incl01.at41
-rw-r--r--tests/incl02.at51
-rw-r--r--tests/incl03.at45
-rw-r--r--tests/testsuite.at8
6 files changed, 188 insertions, 2 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 76cfbfe..d6b9d3e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,5 +1,5 @@
# This file is part of grecs - Gray's Extensible Configuration System
-# Copyright (C) 2007, 2009-2012 Sergey Poznyakoff
+# Copyright (C) 2007, 2009-2014 Sergey Poznyakoff
#
# Grecs is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -83,6 +83,10 @@ TESTSUITE_AT = \
glob05.at\
grecs00.at\
enum.at\
+ incl00.at\
+ incl01.at\
+ incl02.at\
+ incl03.at\
join.at\
locus00.at\
locus01.at\
diff --git a/tests/incl00.at b/tests/incl00.at
new file mode 100644
index 0000000..bb99fd2
--- /dev/null
+++ b/tests/incl00.at
@@ -0,0 +1,39 @@
+# This file is part of grecs -*- Autotest -*-
+# Copyright (C) 2014 Sergey Poznyakoff
+#
+# Grecs 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.
+#
+# Grecs 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 Grecs. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([Include path])
+AT_KEYWORDS([include incl00])
+
+AT_CHECK([
+mkdir include
+AT_DATA([include/1.inc],[this true;
+])
+
+AT_DATA([test.cf],[
+before 1;
+#include <1.inc>
+after 1;
+])
+
+gcffmt -I`pwd`/include ./test.cf
+],
+[0],
+[.before: "1"
+.this: "true"
+.after: "1"
+])
+
+AT_CLEANUP
diff --git a/tests/incl01.at b/tests/incl01.at
new file mode 100644
index 0000000..0be469b
--- /dev/null
+++ b/tests/incl01.at
@@ -0,0 +1,41 @@
+# This file is part of grecs -*- Autotest -*-
+# Copyright (C) 2014 Sergey Poznyakoff
+#
+# Grecs 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.
+#
+# Grecs 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 Grecs. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([Recursive inclusion])
+AT_KEYWORDS([include incl01])
+
+AT_CHECK([
+AT_DATA([a.inc],[this true;
+#include "b.inc"
+])
+
+AT_DATA([b.inc],[#include "a.inc"
+])
+
+AT_DATA([test.cf],[before 1;
+#include "a.inc"
+after 1;
+])
+
+gcffmt ./test.cf
+],
+[1],
+[],
+[./b.inc:1: Recursive inclusion
+./test.cf:2: `./a.inc' already included here
+])
+
+AT_CLEANUP
diff --git a/tests/incl02.at b/tests/incl02.at
new file mode 100644
index 0000000..edf83c3
--- /dev/null
+++ b/tests/incl02.at
@@ -0,0 +1,51 @@
+# This file is part of grecs -*- Autotest -*-
+# Copyright (C) 2014 Sergey Poznyakoff
+#
+# Grecs 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.
+#
+# Grecs 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 Grecs. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([Include once])
+AT_KEYWORDS([include incl02])
+
+AT_CHECK([
+AT_DATA([a.inc],[a true;
+])
+
+AT_DATA([test1.cf],[before 1;
+#include "a.inc"
+#include "a.inc"
+after 1;
+])
+
+AT_DATA([test2.cf],[before 1;
+#include_once "a.inc"
+#include_once "a.inc"
+after 1;
+])
+
+gcffmt ./test1.cf
+echo ==
+gcffmt ./test2.cf
+],
+[0],
+[.before: "1"
+.a: "true"
+.a: "true"
+.after: "1"
+==
+.before: "1"
+.a: "true"
+.after: "1"
+])
+
+AT_CLEANUP
diff --git a/tests/incl03.at b/tests/incl03.at
new file mode 100644
index 0000000..201222f
--- /dev/null
+++ b/tests/incl03.at
@@ -0,0 +1,45 @@
+# This file is part of grecs -*- Autotest -*-
+# Copyright (C) 2014 Sergey Poznyakoff
+#
+# Grecs 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.
+#
+# Grecs 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 Grecs. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([Wildcard inclusion])
+AT_KEYWORDS([include incl03])
+
+AT_CHECK([
+AT_DATA([i1.inc],[i1 included;
+])
+
+AT_DATA([i2.inc],[i2 included;
+])
+
+AT_DATA([i3.inc],[i3 included;
+])
+
+AT_DATA([test.cf],[before 1;
+#include "i*.inc"
+after 1;
+])
+
+gcffmt ./test.cf
+],
+[0],
+[.before: "1"
+.i1: "included"
+.i2: "included"
+.i3: "included"
+.after: "1"
+])
+
+AT_CLEANUP
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 2d42d4d..eaad2f1 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -1,5 +1,5 @@
# This file is part of grecs - Gray's Extensible Configuration System -*- Autotest -*-
-# Copyright (C) 2007, 2009-2012 Sergey Poznyakoff
+# Copyright (C) 2007, 2009-2014 Sergey Poznyakoff
#
# Grecs is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -79,6 +79,12 @@ AT_BANNER([Sort])
m4_include([sort00.at])
m4_include([sort01.at])
+AT_BANNER([Include])
+m4_include([incl00.at])
+m4_include([incl01.at])
+m4_include([incl02.at])
+m4_include([incl03.at])
+
m4_ifdef([ENABLE_BIND_PARSER],[
AT_BANNER([BIND Parser])
m4_include([parser-bind.at])

Return to:

Send suggestions and report system problems to the System administrator.