summaryrefslogtreecommitdiffabout
path: root/tests
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-13 07:21:43 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-05-13 07:33:34 (GMT)
commitde3fbe3e8d4dd2a89f7755906d76055784c437cc (patch) (side-by-side diff)
tree65356dd7b5a9010499550c468e960c93515a7e15 /tests
parentf569a6f2628b9ddef4dfb4424aff2dad644a8f19 (diff)
downloadwydawca-de3fbe3e8d4dd2a89f7755906d76055784c437cc.tar.gz
wydawca-de3fbe3e8d4dd2a89f7755906d76055784c437cc.tar.bz2
Drop gnulib.
* bootstrap: Rewrite. * bootstrap.conf: Remove. * configure.ac: Remove gl_EARLY/gl_INIT * src/backup.c: New file. * src/txtacc.c (txtacc_finish): Make sure a new entry is appended only once to the list. * (all sources): Use grecs memory allocation functions. * src/wydawca.h" Include fnmatch.h and regex.h (backup_type): New enum. (simple_backup_suffix): New extern. (find_backup_file_name): New proto. * tests/bkupname.c: New file. * tests/backup00.at: New file. * tests/backup01.at: New file. * tests/backup02.at: New file. * tests/backup03.at: New file. * tests/Makefile.am: Add new tests. * tests/testsuite.at: Add new tests. * grecs: Update.
Diffstat (limited to 'tests') (more/less context) (ignore whitespace changes)
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/Makefile.am14
-rw-r--r--tests/backup01.at33
-rw-r--r--tests/backup02.at43
-rw-r--r--tests/backup03.at41
-rw-r--r--tests/bkupname.c79
-rw-r--r--tests/testsuite.at4
7 files changed, 211 insertions, 4 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
index 7c8bd6b..1df6b71 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -9,3 +9,4 @@ dest
wstest
wsbatch
pushck
+bkupname
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b174fcd..cc52dbf 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -24,7 +24,7 @@ SUBDIRS = etc
## ------------ ##
$(srcdir)/package.m4: $(top_srcdir)/configure.ac
- { \
+ $(AM_V_GEN){ \
echo '# Signature of the current package.'; \
echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \
echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \
@@ -40,6 +40,10 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
## ------------ ##
TESTSUITE_AT = \
+ backup00.at\
+ backup01.at\
+ backup02.at\
+ backup03.at\
check-fail.at\
check-notify.at\
check-ok.at\
@@ -73,9 +77,11 @@ check-local: atconfig atlocal $(TESTSUITE)
#installcheck-local:
# $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
-check_PROGRAMS = wstest wsbatch pushck
-INCLUDES = -I$(top_srcdir)/grecs/src -I$(top_srcdir)/gnu -I../gnu -I$(top_srcdir)/src
-LDADD=../grecs/src/libgrecs.a ../gnu/libgnu.a
+check_PROGRAMS = wstest wsbatch pushck bkupname
+INCLUDES = -I$(top_srcdir)/grecs/src -I$(top_srcdir)/src
+LDADD=../grecs/src/libgrecs.a
pushck_LDADD=../src/pushd.o
+bkupname_LDADD=../src/backup.o ../grecs/src/libgrecs.a
+
diff --git a/tests/backup01.at b/tests/backup01.at
new file mode 100644
index 0000000..7cf4f93
--- a/dev/null
+++ b/tests/backup01.at
@@ -0,0 +1,33 @@
+# This file is part of wydawca testsuite -*- Autotest -*-
+# Copyright (C) 2009, 2010 Sergey Poznyakoff
+#
+# Wydawca 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.
+#
+# Wydawca 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 Wydawca. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP(simple backups)
+AT_KEYWORDS([backup backup01 simple_backups])
+
+AT_CHECK([bkupname -simple a],
+[0],
+[a~
+])
+
+AT_CHECK([
+touch a
+bkupname -simple a
+],
+[0],
+[a~
+])
+
+AT_CLEANUP
diff --git a/tests/backup02.at b/tests/backup02.at
new file mode 100644
index 0000000..b5bcc54
--- a/dev/null
+++ b/tests/backup02.at
@@ -0,0 +1,43 @@
+# This file is part of wydawca testsuite -*- Autotest -*-
+# Copyright (C) 2009, 2010 Sergey Poznyakoff
+#
+# Wydawca 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.
+#
+# Wydawca 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 Wydawca. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP(numbered backups)
+AT_KEYWORDS([backup backup02 numbered_backups])
+
+AT_CHECK([bkupname -numbered a],
+[0],
+[a.~1~
+])
+
+AT_CHECK([
+touch a.~1~
+bkupname -numbered a
+],
+[0],
+[a.~2~
+])
+
+AT_CHECK([
+touch a.~99~
+bkupname -numbered a
+],
+[0],
+[a.~100~
+])
+
+
+
+AT_CLEANUP
diff --git a/tests/backup03.at b/tests/backup03.at
new file mode 100644
index 0000000..947c145
--- a/dev/null
+++ b/tests/backup03.at
@@ -0,0 +1,41 @@
+# This file is part of wydawca testsuite -*- Autotest -*-
+# Copyright (C) 2009, 2010 Sergey Poznyakoff
+#
+# Wydawca 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.
+#
+# Wydawca 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 Wydawca. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP(numbered existing backups)
+AT_KEYWORDS([backup backup03 numbered_existing_backups])
+
+AT_CHECK([bkupname -existing a],
+[0],
+[a~
+])
+
+AT_CHECK([
+touch a.~1~
+bkupname -existing a
+],
+[0],
+[a.~2~
+])
+
+AT_CHECK([
+touch a.~99~
+bkupname -existing a
+],
+[0],
+[a.~100~
+])
+
+AT_CLEANUP
diff --git a/tests/bkupname.c b/tests/bkupname.c
new file mode 100644
index 0000000..6187146
--- a/dev/null
+++ b/tests/bkupname.c
@@ -0,0 +1,79 @@
+/* wordsplit - a word splitter
+ Copyright (C) 2009, 2010 Sergey Poznyakoff
+
+ This program 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 of the License, or (at your
+ option) any later version.
+
+ This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include "wydawca.h"
+
+char *progname;
+
+void
+usage (int code)
+{
+ FILE *fp = code ? stderr : stdout;
+
+ fprintf (fp, "usage: %s [-no] [-simple] [-existing] [-numbered] [-suffix=S] FILE\n",
+ progname);
+ exit (code);
+}
+
+int
+main (int argc, char **argv)
+{
+ enum backup_type type = numbered_backups;
+ char *file = NULL;
+ char *backup;
+
+ progname = argv[0];
+ while (--argc)
+ {
+ char *arg = *++argv;
+ if (strcmp (arg, "-no") == 0)
+ type = no_backups;
+ else if (strcmp (arg, "-simple") == 0)
+ type = simple_backups;
+ else if (strcmp (arg, "-existing") == 0)
+ type = numbered_existing_backups;
+ else if (strcmp (arg, "-numbered") == 0)
+ type = numbered_backups;
+ else if (strncmp (arg, "-suffix=", 8) == 0)
+ simple_backup_suffix = arg + 8;
+ else if (arg[0] == '-')
+ usage (2);
+ else
+ {
+ if (argc != 1)
+ usage (2);
+ file = arg;
+ }
+ }
+
+ if (!file)
+ usage (2);
+ backup = find_backup_file_name (file, type);
+ if (!backup)
+ {
+ if (errno)
+ {
+ perror (file);
+ exit (1);
+ }
+ printf ("no backup\n");
+ }
+ else
+ printf ("%s\n", backup);
+ free (backup);
+ exit (0);
+}
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 240ab5d..2318762 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -24,6 +24,10 @@ AT_TESTED([wydawca])
m4_include([version.at])
m4_include([wordsplit.at])
m4_include([pushdir.at])
+m4_include([backup00.at])
+m4_include([backup01.at])
+m4_include([backup02.at])
+m4_include([backup03.at])
m4_include([upload-dry.at])
m4_include([upload.at])

Return to:

Send suggestions and report system problems to the System administrator.