chiark / gitweb /
test for editor()
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 23 Jan 2011 20:46:54 +0000 (20:46 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 23 Jan 2011 20:46:54 +0000 (20:46 +0000)
.bzrignore
tests/Makefile.am
tests/dummy-editor [new file with mode: 0755]
tests/t-editor.cc [new file with mode: 0644]

index c8cd148..b797c13 100644 (file)
@@ -32,3 +32,4 @@ tests/t-pager
 debian/vcs
 
 config.cache
+tests/t-editor
index eb2ee7a..92308d5 100644 (file)
 # 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
-noinst_PROGRAMS=t-version t-execute t-ltfilename t-utils t-xml t-pager
+noinst_PROGRAMS=t-version t-execute t-ltfilename t-utils t-xml t-pager t-editor
 dist_noinst_SCRIPTS=t-help t-errors \
        t-bzr t-cvs t-svn t-git t-hg t-darcs t-p4 \
-       bzr-clone git-clone hg-clone
+       bzr-clone git-clone hg-clone \
+       dummy-editor
 t_version_SOURCES=t-version.cc
 t_execute_SOURCES=t-execute.cc
 t_ltfilename_SOURCES=t-ltfilename.cc
 t_utils_SOURCES=t-utils.cc
 t_xml_SOURCES=t-xml.cc
 t_pager_SOURCES=t-pager.cc
+t_editor_SOURCES=t-editor.cc
 LDADD=../src/libvcs.a
 AM_CXXFLAGS=-I${top_srcdir}/src
 TESTS_ENVIRONMENT=TESTLOG=true \
-       PATH=`cd ../src && pwd`:$$PATH \
+       PATH=`cd ../src && pwd`:${srcdir}:$$PATH \
        top_srcdir=`cd ${top_srcdir} && pwd`
-TESTS=t-version t-execute t-ltfilename t-utils t-xml t-pager \
+TESTS=t-version t-execute t-ltfilename t-utils t-xml t-pager t-editor \
        t-help t-errors \
        t-bzr t-cvs t-svn t-git t-hg t-darcs t-p4 \
        bzr-clone git-clone hg-clone
diff --git a/tests/dummy-editor b/tests/dummy-editor
new file mode 100755 (executable)
index 0000000..1e2eb57
--- /dev/null
@@ -0,0 +1,6 @@
+#! /bin/sh
+set -e
+path="$1"
+grep "abra" "${path}" > /dev/null
+echo cadabra > "${path}"
+exit 0
diff --git a/tests/t-editor.cc b/tests/t-editor.cc
new file mode 100644 (file)
index 0000000..bc79e93
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * This file is part of VCS
+ * Copyright (C) 2011 Richard Kettlewell
+ *
+ * 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 "vcs.h"
+
+int main(void) {
+  putenv(xstrdup("EDITOR=dummy-editor"));
+  putenv(xstrdup("VISUAL=dummy-editor"));
+  vector<string> f;
+  f.push_back("abra");
+  assert(editor(f) == 0);
+  assert(f.size() == 1);
+  assert(f[0] == "cadabra");
+  return 0;
+}
+
+/*
+Local Variables:
+mode:c++
+c-basic-offset:2
+comment-column:40
+fill-column:79
+indent-tabs-mode:nil
+End:
+*/