aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorMu Qiao <qiaomuf@gentoo.org>2011-06-28 22:43:50 +0800
committerMu Qiao <qiaomuf@gentoo.org>2011-07-18 23:23:53 +0800
commit3bd66c03c5ad80c17b442bdd7a66c563bc6557ab (patch)
tree2df96140e6a2087c9459786402b2338f71cf6686 /utils
parentParser: support literal '$' in double quoted string (diff)
downloadlibbash-3bd66c03c5ad80c17b442bdd7a66c563bc6557ab.tar.gz
libbash-3bd66c03c5ad80c17b442bdd7a66c563bc6557ab.tar.bz2
libbash-3bd66c03c5ad80c17b442bdd7a66c563bc6557ab.zip
Build: use bash to verify test scripts
We keep the old style for some tests that behave differently depending on different bash versions.
Diffstat (limited to 'utils')
-rw-r--r--utils/bash.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/utils/bash.cpp b/utils/bash.cpp
new file mode 100644
index 0000000..efb51f9
--- /dev/null
+++ b/utils/bash.cpp
@@ -0,0 +1,63 @@
+/*
+ Please use git log for copyright holder and year information
+
+ This file is part of libbash.
+
+ libbash 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 2 of the License, or
+ (at your option) any later version.
+
+ libbash 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 libbash. If not, see <http://www.gnu.org/licenses/>.
+*/
+///
+/// \file bash_runner.cpp
+/// \brief a program to write variables in a script into standard output
+///
+
+#include <algorithm>
+#include <iostream>
+#include <map>
+
+#include <gtest/gtest.h>
+#include <boost/spirit/include/karma.hpp>
+#include <boost/fusion/include/std_pair.hpp>
+
+#include "libbash.h"
+#include "test.h"
+
+static const std::vector<std::string> special_variables
+{
+ "IFS", "*", "0", "-"
+};
+
+int main(int argc, char** argv)
+{
+ if(argc != 2)
+ {
+ std::cerr<<"Please provide your script as an argument"<<std::endl;
+ exit(EXIT_FAILURE);
+ }
+
+ std::unordered_map<std::string, std::vector<std::string>> variables{
+ {"srcdir", std::vector<std::string>({get_src_dir()})}
+ };
+ std::vector<std::string> functions;
+ try
+ {
+ libbash::interpret(argv[1], variables, functions);
+ }
+ catch(libbash::interpreter_exception& e)
+ {
+ std::cerr << e.what() << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ return 0;
+}