From 360bc41d24e2d39aa4ac9df94e0c6e69bff7f615 Mon Sep 17 00:00:00 2001 From: Roman Bovsunivskiy Date: Mon, 22 Feb 2010 17:38:03 +0000 Subject: [PATCH] build_tests and run_tests should work now --- fwbuilder3.pro | 2 +- src/compiler_lib/unit_tests/tests_main.pro | 4 +- src/gui/unit_tests/unit_tests.cpp | 86 ---------------------- src/gui/unit_tests/unit_tests.pro | 31 +++----- src/gui/unit_tests/unit_tests.sh | 11 +++ 5 files changed, 24 insertions(+), 110 deletions(-) delete mode 100644 src/gui/unit_tests/unit_tests.cpp create mode 100755 src/gui/unit_tests/unit_tests.sh diff --git a/fwbuilder3.pro b/fwbuilder3.pro index 672d92fb3..336e36d53 100644 --- a/fwbuilder3.pro +++ b/fwbuilder3.pro @@ -7,7 +7,7 @@ SUBDIRS = src doc DOLLAR = $ -build_tests.commands = ./unit_tests.sh make +build_tests.commands = ./unit_tests.sh make build build_tests.depends = all run_tests.commands = ./unit_tests.sh make run diff --git a/src/compiler_lib/unit_tests/tests_main.pro b/src/compiler_lib/unit_tests/tests_main.pro index c6f042a41..c039eddfb 100644 --- a/src/compiler_lib/unit_tests/tests_main.pro +++ b/src/compiler_lib/unit_tests/tests_main.pro @@ -59,6 +59,8 @@ run.commands = echo "Running tests..." && \ echo "OK" || { echo "FAILED"; exit 1; } run.depends = all -QMAKE_EXTRA_TARGETS += run +build.depends = all + +QMAKE_EXTRA_TARGETS += run build diff --git a/src/gui/unit_tests/unit_tests.cpp b/src/gui/unit_tests/unit_tests.cpp deleted file mode 100644 index 07a082b2f..000000000 --- a/src/gui/unit_tests/unit_tests.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - - Firewall Builder - - Copyright (C) 2003 NetCitadel, LLC - - Author: Vadim Kurland vadim@fwbuilder.org - - $Id$ - - This program is free software which we release under the GNU General Public - License. You may redistribute and/or modify this program under the terms - of that license as published by the Free Software Foundation; either - version 2 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. - - To get a copy of the GNU General Public License, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ - - -#include "../../../config.h" -#include "../global.h" -#include "../RCS.h" - -#include -#include -#include - -#include - -using namespace std; -using namespace libfwbuilder; - -QApplication *app = NULL; -int fwbdebug = 0; - -QString test_file = "zu.fwb"; -QString rlog_unit_test_log_file = "rlog_unit_test.log"; - -int main( int argc, char ** argv ) -{ - app = new QApplication( argc, argv ); - QWidget w; - app->setMainWidget(&w); - w.show(); - - RCS *rcs = new RCS(test_file); - - QString reverse_engineered_rlog; - - QValueList::iterator i; - for (i=rcs->begin(); i!=rcs->end(); ++i) - { - reverse_engineered_rlog += "---------------------------------\n"; - reverse_engineered_rlog += "revision: " + (*i).rev + "\n"; - reverse_engineered_rlog += "date: " + (*i).date + "\n"; - reverse_engineered_rlog += "author: " + (*i).author + "\n"; - reverse_engineered_rlog += "locked by: " + (*i).locked_by + "\n"; - reverse_engineered_rlog += "log: " + (*i).log + "\n"; - } - - QFile rlog_test_file(rlog_unit_test_log_file); - if (rlog_test_file.open( IO_ReadOnly )) - { - QTextStream strm( &rlog_test_file ); - QString test_str = strm.read(); - rlog_test_file.close(); - - if (test_str != reverse_engineered_rlog) - { - cout << reverse_engineered_rlog; - -// cout << "################################################################" << endl; - -// cout << test_str << endl; - } - - } - -} diff --git a/src/gui/unit_tests/unit_tests.pro b/src/gui/unit_tests/unit_tests.pro index 5d90d326d..bf91524ee 100644 --- a/src/gui/unit_tests/unit_tests.pro +++ b/src/gui/unit_tests/unit_tests.pro @@ -1,25 +1,12 @@ DOLLAR = $ -run.commands = echo "Running tests..." && \ - display=:1; \ - Xvfb $${DOLLAR}$${DOLLAR}display & \ - pid=$${DOLLAR}$${DOLLAR}!; \ - for directory in `find . -maxdepth 1 -type d -regex \'\./[A-Za-z0-9\-\_]*\'`; \ - do \ - home=`pwd`; \ - cd $${DOLLAR}$${DOLLAR}directory; \ - qmake -spec $${DOLLAR}$${DOLLAR}QMAKESPEC; \ - DISPLAY=$${DOLLAR}$${DOLLAR}display make run || { kill $${DOLLAR}$${DOLLAR}pid; exit 1; }; \ - cd $${DOLLAR}$${DOLLAR}home; \ - done; \ - kill $${DOLLAR}$${DOLLAR}pid; +build.commands = echo "Building tests..."; \ + ./unit_tests.sh make -clean.commands = for directory in `find . -maxdepth 1 -type d -regex \'\./[A-Za-z0-9\-\_]*\'`; \ - do \ - cd $${DOLLAR}$${DOLLAR}directory; \ - [ ! -e Makefile ] && qmake -spec $${DOLLAR}$${DOLLAR}QMAKESPEC; \ - make clean; \ - cd -; \ - done - -QMAKE_EXTRA_TARGETS += run clean +run.commands = echo "Running tests..."; \ + ./unit_tests.sh make run + +clean.commands = echo "Cleaning tests..."; \ + ./unit_tests.sh make clean + +QMAKE_EXTRA_TARGETS += run clean build diff --git a/src/gui/unit_tests/unit_tests.sh b/src/gui/unit_tests/unit_tests.sh new file mode 100755 index 000000000..5cc974137 --- /dev/null +++ b/src/gui/unit_tests/unit_tests.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +commands=$@ + +for directory in `find . -maxdepth 1 -type d -regex '\./[A-Za-z0-9\-\_]*'` +do + cd $directory + [ ! -e Makefile ] && qmake -spec $QMAKESPEC + $commands + cd - +done; \ No newline at end of file