[gnuplot-iostream] 04/07: Add autopkgtest.
Anton Gladky
gladk at moszumanska.debian.org
Sat Sep 6 15:44:20 UTC 2014
This is an automated email from the git hooks/post-receive script.
gladk pushed a commit to branch master
in repository gnuplot-iostream.
commit 2f4decd0011409aa9656eabede70bf527b4ecb5f
Author: Anton Gladky <gladk at debian.org>
Date: Sat Sep 6 17:31:31 2014 +0200
Add autopkgtest.
---
debian/control | 1 +
debian/tests/build1 | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++
debian/tests/build2 | 62 +++++++++++++++++++++++++++++++++++++++++
debian/tests/control | 2 ++
4 files changed, 143 insertions(+)
diff --git a/debian/control b/debian/control
index 5401747..fca4122 100644
--- a/debian/control
+++ b/debian/control
@@ -14,6 +14,7 @@ Build-Depends:
libboost-iostreams-dev,
libboost-system-dev
Homepage: http://www.stahlke.org/dan/gnuplot-iostream/
+XS-Testsuite: autopkgtest
Vcs-Git: git://anonscm.debian.org/debian-science/packages/gnuplot-iostream.git
Vcs-Browser: http://anonscm.debian.org/gitweb/?p=debian-science/packages/gnuplot-iostream.git
diff --git a/debian/tests/build1 b/debian/tests/build1
new file mode 100755
index 0000000..b7f3322
--- /dev/null
+++ b/debian/tests/build1
@@ -0,0 +1,78 @@
+#!/bin/sh
+# autopkgtest for gnuplot-iostream
+# 2014/09/06
+#
+# (C) 2014 Anton Gladky
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+
+cat <<EOF > demo.cc
+// Demo of vector plot.
+// Compile it with:
+// g++ -o example-vector example-vector.cc -lboost_iostreams -lboost_system -lboost_filesystem
+
+#include <vector>
+#include <cmath>
+#include <boost/tuple/tuple.hpp>
+
+#include "gnuplot-iostream.h"
+
+int main() {
+ Gnuplot gp;
+ // Create a script which can be manually fed into gnuplot later:
+ // Gnuplot gp(">script.gp");
+ // Create script and also feed to gnuplot:
+ // Gnuplot gp("tee plot.gp | gnuplot -persist");
+ // Or choose any of those options at runtime by setting the GNUPLOT_IOSTREAM_CMD
+ // environment variable.
+
+ // Gnuplot vectors (i.e. arrows) require four columns: (x,y,dx,dy)
+ std::vector<boost::tuple<double, double, double, double> > pts_A;
+
+ // You can also use a separate container for each column, like so:
+ std::vector<double> pts_B_x;
+ std::vector<double> pts_B_y;
+ std::vector<double> pts_B_dx;
+ std::vector<double> pts_B_dy;
+
+ // You could also use:
+ // std::vector<std::vector<double> >
+ // boost::tuple of four std::vector's
+ // std::vector of std::tuple (if you have C++11)
+ // arma::mat (with the Armadillo library)
+ // blitz::Array<blitz::TinyVector<double, 4>, 1> (with the Blitz++ library)
+ // ... or anything of that sort
+
+ for(double alpha=0; alpha<1; alpha+=1.0/24.0) {
+ double theta = alpha*2.0*3.14159;
+ pts_A.push_back(boost::make_tuple(
+ cos(theta),
+ sin(theta),
+ -cos(theta)*0.1,
+ -sin(theta)*0.1
+ ));
+
+ pts_B_x .push_back( cos(theta)*0.8);
+ pts_B_y .push_back( sin(theta)*0.8);
+ pts_B_dx.push_back( sin(theta)*0.1);
+ pts_B_dy.push_back(-cos(theta)*0.1);
+ }
+
+ // Don't forget to put "\n" at the end of each line!
+ gp << "set xrange [-2:2]\nset yrange [-2:2]\n";
+ // '-' means read from stdin. The send1d() function sends data to gnuplot's stdin.
+ gp << "plot '-' with vectors title 'pts_A', '-' with vectors title 'pts_B'\n";
+ gp.send1d(pts_A);
+ gp.send1d(boost::make_tuple(pts_B_x, pts_B_y, pts_B_dx, pts_B_dy));
+}
+EOF
+
+g++ -o demo demo.cc -lboost_iostreams -lboost_system -lboost_filesystem
+echo "build: OK"
+[ -x demo ]
+./demo
+echo "run: OK"
diff --git a/debian/tests/build2 b/debian/tests/build2
new file mode 100755
index 0000000..3f88ff3
--- /dev/null
+++ b/debian/tests/build2
@@ -0,0 +1,62 @@
+#!/bin/sh
+# autopkgtest for gnuplot-iostream
+# 2014/09/06
+#
+# (C) 2014 Anton Gladky
+
+set -e
+
+WORKDIR=$(mktemp -d)
+trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
+cd $WORKDIR
+
+cat <<EOF > demo.cc
+// Demo of sending data via temporary files. The default is to send data to gnuplot directly
+// through stdin.
+//
+// Compile it with:
+// g++ -o example-tmpfile example-tmpfile.cc -lboost_iostreams -lboost_system -lboost_filesystem
+
+#include <map>
+#include <vector>
+#include <cmath>
+
+#include "gnuplot-iostream.h"
+
+int main() {
+ Gnuplot gp;
+
+ std::vector<std::pair<double, double> > xy_pts_A;
+ for(double x=-2; x<2; x+=0.01) {
+ double y = x*x*x;
+ xy_pts_A.push_back(std::make_pair(x, y));
+ }
+
+ std::vector<std::pair<double, double> > xy_pts_B;
+ for(double alpha=0; alpha<1; alpha+=1.0/24.0) {
+ double theta = alpha*2.0*3.14159;
+ xy_pts_B.push_back(std::make_pair(cos(theta), sin(theta)));
+ }
+
+ gp << "set xrange [-2:2]\nset yrange [-2:2]\n";
+ // Data will be sent via a temporary file. These are erased when you call
+ // gp.clearTmpfiles() or when gp goes out of scope. If you pass a filename
+ // (e.g. "gp.file1d(pts, 'mydata.dat')"), then the named file will be created
+ // and won't be deleted (this is useful when creating a script).
+ gp << "plot" << gp.file1d(xy_pts_A) << "with lines title 'cubic',"
+ << gp.file1d(xy_pts_B) << "with points title 'circle'" << std::endl;
+
+#ifdef _WIN32
+ // For Windows, prompt for a keystroke before the Gnuplot object goes out of scope so that
+ // the gnuplot window doesn't get closed.
+ std::cout << "Press enter to exit." << std::endl;
+ std::cin.get();
+#endif
+}
+EOF
+
+g++ -o demo demo.cc -lboost_iostreams -lboost_system -lboost_filesystem
+echo "build: OK"
+[ -x demo ]
+./demo
+echo "run: OK"
diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..3a0fe0b
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,2 @@
+Tests: build1 build2
+Depends: libgnuplot-iostream-dev, libboost-iostreams-dev, libboost-system-dev, libboost-filesystem-dev, build-essential
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/gnuplot-iostream.git
More information about the debian-science-commits
mailing list