public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/libbash:master commit in: scripts/, /, test/
@ 2011-04-02 15:50 Petteri Räty
  0 siblings, 0 replies; 2+ messages in thread
From: Petteri Räty @ 2011-04-02 15:50 UTC (permalink / raw
  To: gentoo-commits

commit:     b7e8f0d374b8dea54247d191fa4257ec0812c900
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Sat Apr  2 05:52:22 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Apr  2 15:46:51 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=b7e8f0d3

Implement a custom test for variable retrieval

*.ebuild under ./scripts will be parsed and compared with
./*.ebuild.result by calling diff. No output should be generated
by diff if everything goes fine.

---
 .gitignore                    |    1 +
 Makefile.am                   |   18 ++++++++++---
 scripts/var_def.ebuild.result |   10 +++++++
 test/script_compiler.sh       |   11 ++++++++
 test/variable_printer.cpp     |   57 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 93 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index 4bf6402..18020e7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,7 @@ missing
 Makefile
 autom4te.cache
 cppunittests
+variable_printer
 libbash.g
 libbash.tokens
 bashast.tokens

diff --git a/Makefile.am b/Makefile.am
index b6b2616..e14c26a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,7 @@ include doxygen.am
 
 ACLOCAL_AMFLAGS = -I m4
 
-TEST_EXTENSIONS= .gunit
+TEST_EXTENSIONS= .gunit .ebuild
 GUNIT_LOG_COMPILER = $(srcdir)/bashast/gunit/runtests.sh
 AM_GUNIT_LOG_FLAGS = @antlr_cp@:.
 GUNIT_TESTS = bashast/gunit/arith_main.gunit \
@@ -46,7 +46,11 @@ GUNIT_TESTS = bashast/gunit/arith_main.gunit \
 			  bashast/gunit/simp_command.gunit \
 			  bashast/gunit/simp_prog.gunit
 
-TESTS = $(GUNIT_TESTS)
+EBUILD_LOG_COMPILER = $(srcdir)/test/script_compiler.sh
+EBUILD_TESTS = scripts/var_def.ebuild
+EBUILD_RESULT = scripts/var_def.ebuild.result
+
+TESTS = $(GUNIT_TESTS) $(EBUILD_TESTS)
 # these get cleaned so only add autogenerated stuff or modify CLEANFILES
 check_JAVA = bashast/bashastLexer.java bashast/bashastParser.java
 AM_JAVACFLAGS = -classpath @antlr_cp@
@@ -72,7 +76,7 @@ endif
 
 if HAVE_GTEST
 TESTS += cppunittests
-check_PROGRAMS = cppunittests
+check_PROGRAMS = cppunittests variable_printer
 
 cppunittests_SOURCES =  test/run_tests.cpp \
 						src/core/tests/symbols_test.cpp \
@@ -87,6 +91,9 @@ cppunittests_LDADD = libcppbash.la \
 					 $(BOOST_SYSTEM_LIB) \
 					 $(BOOST_FILESYSTEM_LIB)
 cppunittests_LDFLAGS = -static
+
+variable_printer_SOURCES = test/variable_printer.cpp
+variable_printer_LDADD = libcppbash.la
 endif
 
 GENERATED_PARSER_C = libbashLexer.c libbashParser.c
@@ -136,8 +143,11 @@ libcppbash_la_CFLAGS = $(AM_CFLAGS) $(HIDDEN_FLAGS)
 
 EXTRA_DIST = bashast/bashast.g \
 			 bashast/libbashWalker.g \
+			 $(EBUILD_TESTS) \
+			 $(EBUILD_RESULT) \
 			 $(GUNIT_TESTS) \
-			 $(GUNIT_LOG_COMPILER)
+			 $(GUNIT_LOG_COMPILER) \
+			 $(EBUILD_LOG_COMPILER)
 
 coding_standard.pdf: coding_standard/coding_standard.tex
 	$(AM_V_GEN)@PDFLATEX@ coding_standard/coding_standard.tex 2&>1 > /dev/null

diff --git a/scripts/var_def.ebuild.result b/scripts/var_def.ebuild.result
new file mode 100644
index 0000000..6a3a0b8
--- /dev/null
+++ b/scripts/var_def.ebuild.result
@@ -0,0 +1,10 @@
+DESCRIPTION=SunPinyin is a SLM (Statistical Language Model) based IME
+EAPI=1
+HOMEPAGE=http://sunpinyin.googlecode.com
+IUSE=abc
+KEYWORDS=~amd64 ~x86
+LICENSE=LGPL-2.1 CDDL
+RDEPEND=dev-db/sqlite:3
+SLOT=0
+SRC_URI=http://open-gram.googlecode.com/files/dict.utf8.tar.bz2
+		http://open-gram.googlecode.com/files/lm_sc.t3g.arpa.tar.bz2

diff --git a/test/script_compiler.sh b/test/script_compiler.sh
new file mode 100755
index 0000000..d409673
--- /dev/null
+++ b/test/script_compiler.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+declare -i error=0
+
+for script in $@
+do
+    ./variable_printer $script | diff -u $script.result -
+    error+=$?
+done
+
+exit $error

diff --git a/test/variable_printer.cpp b/test/variable_printer.cpp
new file mode 100644
index 0000000..ab2b4cb
--- /dev/null
+++ b/test/variable_printer.cpp
@@ -0,0 +1,57 @@
+/*
+   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 variable_printer.cpp
+/// \author Mu Qiao
+/// \brief a program to write variables in a script into standard output
+///
+
+#include <algorithm>
+#include <iostream>
+#include <vector>
+
+#include <boost/range/adaptor/map.hpp>
+#include <boost/range/algorithm/for_each.hpp>
+#include <boost/range/algorithm/sort.hpp>
+#include <gtest/gtest.h>
+
+#include "libbash.h"
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+  if(argc != 2)
+  {
+    cerr<<"Please provide your script as an argument"<<endl;
+    exit(EXIT_FAILURE);
+  }
+
+  unordered_map<string, string> variables;
+  libbash::interpret(argv[1], variables);
+
+  auto keys = variables | boost::adaptors::map_keys;
+  vector<string> names(keys.begin(), keys.end());
+  auto sorted = boost::sort(names);
+  boost::for_each(boost::sort(names), [&](const string& key){
+    cout << key << '=' << variables[key] << endl;
+  });
+
+  return 0;
+}



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] proj/libbash:master commit in: scripts/, /, test/
@ 2011-04-26 11:02 Petteri Räty
  0 siblings, 0 replies; 2+ messages in thread
From: Petteri Räty @ 2011-04-26 11:02 UTC (permalink / raw
  To: gentoo-commits

commit:     f00e6f72d20808accabb22cf49c5489f118b7bc5
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 21 08:34:13 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Fri Apr 22 00:38:13 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=f00e6f72

Test: rename *ebuild* to *bash*

The suffix is not proper when we want to distinguish normal shell
scripts from ebuilds. So we rename these tests to make it possible
to use metadata_generator as the compiler for *.ebuild.

---
 Makefile.am                                        |   42 ++++++++++----------
 ...ssignment.ebuild => arithmetic_assignment.bash} |    0
 ...ld.result => arithmetic_assignment.bash.result} |    0
 ...ry_arithmetic.ebuild => binary_arithmetic.bash} |    0
 ...ebuild.result => binary_arithmetic.bash.result} |    0
 ...and_execution.ebuild => command_execution.bash} |    0
 ...ebuild.result => command_execution.bash.result} |    0
 scripts/{function_def.ebuild => function_def.bash} |    0
 ..._def.ebuild.result => function_def.bash.result} |    0
 scripts/{var_def.ebuild => var_def.bash}           |    0
 .../{var_def.ebuild.result => var_def.bash.result} |    0
 .../{var_expansion.ebuild => var_expansion.bash}   |    0
 ...ion.ebuild.result => var_expansion.bash.result} |    0
 test/verify_bashs_test.sh                          |    5 ++
 test/verify_ebuilds_test.sh                        |    5 --
 15 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index c4f2507..03848ed 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,7 @@ include doxygen.am
 
 ACLOCAL_AMFLAGS = -I m4
 
-TEST_EXTENSIONS= .gunit .ebuild
+TEST_EXTENSIONS= .gunit .bash
 GUNIT_LOG_COMPILER = $(srcdir)/bashast/gunit/runtests.sh
 AM_GUNIT_LOG_FLAGS = @antlr_cp@:.
 GUNIT_TESTS = bashast/gunit/arith_main.gunit \
@@ -46,21 +46,21 @@ GUNIT_TESTS = bashast/gunit/arith_main.gunit \
 			  bashast/gunit/simp_command.gunit \
 			  bashast/gunit/simp_prog.gunit
 
-EBUILD_LOG_COMPILER = $(srcdir)/test/script_compiler.sh
-EBUILD_TESTS = scripts/var_def.ebuild \
-			   scripts/var_expansion.ebuild \
-			   scripts/command_execution.ebuild \
-			   scripts/function_def.ebuild \
-			   scripts/arithmetic_assignment.ebuild \
-			   scripts/binary_arithmetic.ebuild
-EBUILD_RESULT = scripts/var_def.ebuild.result \
-				scripts/var_expansion.ebuild.result \
-				scripts/command_execution.ebuild.result \
-				scripts/function_def.ebuild.result \
-				scripts/arithmetic_assignment.ebuild.result \
-				scripts/binary_arithmetic.ebuild.result
-
-TESTS = $(GUNIT_TESTS) $(EBUILD_TESTS)
+BASH_LOG_COMPILER = $(srcdir)/test/script_compiler.sh
+BASH_TESTS = scripts/var_def.bash \
+			 scripts/var_expansion.bash \
+			 scripts/command_execution.bash \
+			 scripts/function_def.bash \
+			 scripts/arithmetic_assignment.bash \
+			 scripts/binary_arithmetic.bash
+BASH_RESULT = scripts/var_def.bash.result \
+			  scripts/var_expansion.bash.result \
+			  scripts/command_execution.bash.result \
+			  scripts/function_def.bash.result \
+			  scripts/arithmetic_assignment.bash.result \
+			  scripts/binary_arithmetic.bash.result
+
+TESTS = $(GUNIT_TESTS) $(BASH_TESTS)
 # these get cleaned so only add autogenerated stuff or modify CLEANFILES
 check_JAVA = bashast/bashastLexer.java bashast/bashastParser.java
 AM_JAVACFLAGS = -classpath @antlr_cp@
@@ -85,7 +85,7 @@ AM_CPPFLAGS = -D_GLIBCXX_DEBUG
 endif
 
 if HAVE_GTEST
-TESTS += cppunittests test/ast_printer_test.sh test/verify_ebuilds_test.sh
+TESTS += cppunittests test/ast_printer_test.sh test/verify_bashs_test.sh
 check_PROGRAMS = cppunittests
 
 cppunittests_SOURCES =  test/run_tests.cpp \
@@ -175,12 +175,12 @@ EXTRA_DIST = bashast/bashast.g \
 			 bashast/features_script/features.sh.ast \
 			 bashast/features_script/features.sh.tokens \
 			 test/ast_printer_test.sh \
-			 test/verify_ebuilds_test.sh \
-			 $(EBUILD_TESTS) \
-			 $(EBUILD_RESULT) \
+			 test/verify_bashs_test.sh \
+			 $(BASH_TESTS) \
+			 $(BASH_RESULT) \
 			 $(GUNIT_TESTS) \
 			 $(GUNIT_LOG_COMPILER) \
-			 $(EBUILD_LOG_COMPILER)
+			 $(BASH_LOG_COMPILER)
 
 coding_standard.pdf: coding_standard/coding_standard.tex
 	$(AM_V_GEN)@PDFLATEX@ coding_standard/coding_standard.tex 2&>1 > /dev/null

diff --git a/scripts/arithmetic_assignment.ebuild b/scripts/arithmetic_assignment.bash
similarity index 100%
rename from scripts/arithmetic_assignment.ebuild
rename to scripts/arithmetic_assignment.bash

diff --git a/scripts/arithmetic_assignment.ebuild.result b/scripts/arithmetic_assignment.bash.result
similarity index 100%
rename from scripts/arithmetic_assignment.ebuild.result
rename to scripts/arithmetic_assignment.bash.result

diff --git a/scripts/binary_arithmetic.ebuild b/scripts/binary_arithmetic.bash
similarity index 100%
rename from scripts/binary_arithmetic.ebuild
rename to scripts/binary_arithmetic.bash

diff --git a/scripts/binary_arithmetic.ebuild.result b/scripts/binary_arithmetic.bash.result
similarity index 100%
rename from scripts/binary_arithmetic.ebuild.result
rename to scripts/binary_arithmetic.bash.result

diff --git a/scripts/command_execution.ebuild b/scripts/command_execution.bash
similarity index 100%
rename from scripts/command_execution.ebuild
rename to scripts/command_execution.bash

diff --git a/scripts/command_execution.ebuild.result b/scripts/command_execution.bash.result
similarity index 100%
rename from scripts/command_execution.ebuild.result
rename to scripts/command_execution.bash.result

diff --git a/scripts/function_def.ebuild b/scripts/function_def.bash
similarity index 100%
rename from scripts/function_def.ebuild
rename to scripts/function_def.bash

diff --git a/scripts/function_def.ebuild.result b/scripts/function_def.bash.result
similarity index 100%
rename from scripts/function_def.ebuild.result
rename to scripts/function_def.bash.result

diff --git a/scripts/var_def.ebuild b/scripts/var_def.bash
similarity index 100%
rename from scripts/var_def.ebuild
rename to scripts/var_def.bash

diff --git a/scripts/var_def.ebuild.result b/scripts/var_def.bash.result
similarity index 100%
rename from scripts/var_def.ebuild.result
rename to scripts/var_def.bash.result

diff --git a/scripts/var_expansion.ebuild b/scripts/var_expansion.bash
similarity index 100%
rename from scripts/var_expansion.ebuild
rename to scripts/var_expansion.bash

diff --git a/scripts/var_expansion.ebuild.result b/scripts/var_expansion.bash.result
similarity index 100%
rename from scripts/var_expansion.ebuild.result
rename to scripts/var_expansion.bash.result

diff --git a/test/verify_bashs_test.sh b/test/verify_bashs_test.sh
new file mode 100755
index 0000000..2c42195
--- /dev/null
+++ b/test/verify_bashs_test.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+num_of_ebuild_files=$(grep 'scripts/.*.bash' $srcdir/Makefile.am | wc -l)
+[[ $num_of_ebuild_files == $(ls $srcdir/scripts/*.bash* | wc -l) ]]
+exit $?

diff --git a/test/verify_ebuilds_test.sh b/test/verify_ebuilds_test.sh
deleted file mode 100755
index 8aa84d6..0000000
--- a/test/verify_ebuilds_test.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-num_of_ebuild_files=$(grep 'scripts/.*.ebuild' $srcdir/Makefile.am | wc -l)
-[[ $num_of_ebuild_files == $(ls $srcdir/scripts/*.ebuild* | wc -l) ]]
-exit $?



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-26 11:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-26 11:02 [gentoo-commits] proj/libbash:master commit in: scripts/, /, test/ Petteri Räty
  -- strict thread matches above, loose matches on Subject: below --
2011-04-02 15:50 Petteri Räty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox