Boost logo

Boost-Commit :

From: srajko_at_[hidden]
Date: 2007-06-13 00:01:28


Author: srajko
Date: 2007-06-13 00:01:25 EDT (Wed, 13 Jun 2007)
New Revision: 7020
URL: http://svn.boost.org/trac/boost/changeset/7020

Log:
make template processor work on non-windows systems, tests use test_exec_monitor and test Jamfile is generated based on results

Added:
   sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/Jamfile.v2.py
      - copied, changed from r7007, /sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/Jamfile.v2
   sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/test_nothing/
   sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/test_nothing.cpp
      - copied, changed from r7007, /sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/test.cpp
   sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/test_nothing_n.cpp (contents, props changed)
Removed:
   sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/Jamfile.v2
   sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/test.cpp
Text files modified:
   sandbox/template_under_construction/make_template.py | 17 ++++++++++++
   sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/Jamfile.v2.py | 17 ++++++++-----
   sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/test_nothing.cpp | 50 ++++++++--------------------------------
   3 files changed, 36 insertions(+), 48 deletions(-)

Modified: sandbox/template_under_construction/make_template.py
==============================================================================
--- sandbox/template_under_construction/make_template.py (original)
+++ sandbox/template_under_construction/make_template.py 2007-06-13 00:01:25 EDT (Wed, 13 Jun 2007)
@@ -249,13 +249,24 @@
         
         cwd = os.getcwd()
         os.chdir(self.directory)
- for root, dirs, files in os.walk(''):
+ for root, dirs, files in os.walk('.'):
+ # strip the . from the root
+ rest = list()
+ rest_of_root = root
+ while rest_of_root != '.':
+ rest.insert(0, os.path.basename(rest_of_root))
+ rest_of_root = os.path.dirname(rest_of_root)
+ root = ''
+ for item in rest:
+ root = os.path.join(root, item)
             log.line(root)
 
             self.__dirs_clear__ = list()
             self.__files_clear__ = list()
 
             for name in files:
+ if name.startswith('.'):
+ continue
                 pathname = (os.path.join(root, name))
                 if name.endswith('.py'):
                     content = self.read_content(os.path.join(root, name))
@@ -417,6 +428,10 @@
     def files_in(self, directory):
         return self.__scan__(self.file_list + self.python_list, directory)
 
+# def file_contents_in(self, directory):
+# files = self.__scan__(self.file_list + self.python_list, directory)
+
+
     def directories_in(self, directory):
         return self.__scan__(self.directory_list, directory)
     

Deleted: sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/Jamfile.v2
==============================================================================
--- sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/Jamfile.v2 2007-06-13 00:01:25 EDT (Wed, 13 Jun 2007)
+++ (empty file)
@@ -1,20 +0,0 @@
-# Copyright 2007 Stjepan Rajko.
-# Distributed under the Boost Software License, Version 1.0.
-# (See accompanying file LICENSE_1_0.txt or copy at
-# http://www.boost.org/LICENSE_1_0.txt)
-
-$template_start$
-$template_python_copyright$
-
-import testing ;
-
-project
- : requirements
- <include>../../..
- <library>/boost/test//boost_unit_test_framework/<link>static
- <define>BOOST_ALL_NO_LIB=1
- ;
-
-test-suite $template_library$
- : [ run test.cpp ]
- ;

Copied: sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/Jamfile.v2.py (from r7007, /sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/Jamfile.v2)
==============================================================================
--- /sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/Jamfile.v2 (original)
+++ sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/Jamfile.v2.py 2007-06-13 00:01:25 EDT (Wed, 13 Jun 2007)
@@ -1,20 +1,23 @@
+# template file
+
 # Copyright 2007 Stjepan Rajko.
 # Distributed under the Boost Software License, Version 1.0.
 # (See accompanying file LICENSE_1_0.txt or copy at
 # http://www.boost.org/LICENSE_1_0.txt)
 
-$template_start$
-$template_python_copyright$
+template.append_content("""$template_python_copyright$
 
 import testing ;
 
 project
     : requirements
       <include>../../..
- <library>/boost/test//boost_unit_test_framework/<link>static
       <define>BOOST_ALL_NO_LIB=1
     ;
-
-test-suite $template_library$
- : [ run test.cpp ]
- ;
+
+""")
+
+for item in results.files_in(template.replace_name(
+ '$template_library$/libs/$template_library$/test')):
+ if item.endswith('.cpp'):
+ template.append_content('run ' + item + ' ;\n')

Deleted: sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/test.cpp
==============================================================================
--- sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/test.cpp 2007-06-13 00:01:25 EDT (Wed, 13 Jun 2007)
+++ (empty file)
@@ -1,52 +0,0 @@
-// Copyright 2007 Stjepan Rajko.
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-$template_start$
-$template_cpp_copyright$
-
-#include <boost/test/unit_test.hpp>
-using boost::unit_test::test_suite;
-
-#include <boost/$template_library$.hpp>
-
-class test_class
-{
-public:
- void test_nothing()
- {
- boost::$template_library$::$template_library$<int> object;
- int x = 0;
- BOOST_CHECK_EQUAL(object.get_nothing_count(),0);
- object.nothing(x);
- BOOST_CHECK_EQUAL(object.get_nothing_count(),1);
- }
- void test_nothing_n()
- {
- boost::$template_library$::$template_library$<int> object;
- int x = 0;
- BOOST_CHECK_EQUAL(object.get_call_count(),0);
- object.nothing(x,4);
- BOOST_CHECK_EQUAL(object.get_call_count(),1);
- BOOST_CHECK_EQUAL(object.get_nothing_count(),4);
- }
-};
-
-test_suite *$template_library$_test()
-{
- test_suite *suite = BOOST_TEST_SUITE("$template_library$ suite");
-
- boost::shared_ptr<test_class> instance( new test_class() );
- suite->add (BOOST_CLASS_TEST_CASE( &test_class::test_nothing, instance));
- suite->add (BOOST_CLASS_TEST_CASE( &test_class::test_nothing_n, instance));
- return suite;
-}
-
-#define BOOST_TEST_MAIN
-boost::unit_test::test_suite* init_unit_test_suite(int, char* [] )
-{
- test_suite * test = BOOST_TEST_SUITE("_Boost_Library_ test");
- test->add($template_library$_test());
- return test;
-}
\ No newline at end of file

Copied: sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/test_nothing.cpp (from r7007, /sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/test.cpp)
==============================================================================
--- /sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/test.cpp (original)
+++ sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/test_nothing.cpp 2007-06-13 00:01:25 EDT (Wed, 13 Jun 2007)
@@ -6,47 +6,17 @@
 $template_start$
 $template_cpp_copyright$
 
-#include <boost/test/unit_test.hpp>
-using boost::unit_test::test_suite;
-
 #include <boost/$template_library$.hpp>
 
-class test_class
+#include <boost/test/included/test_exec_monitor.hpp>
+
+int test_main(int, char* [])
 {
-public:
- void test_nothing()
- {
- boost::$template_library$::$template_library$<int> object;
- int x = 0;
- BOOST_CHECK_EQUAL(object.get_nothing_count(),0);
- object.nothing(x);
- BOOST_CHECK_EQUAL(object.get_nothing_count(),1);
- }
- void test_nothing_n()
- {
- boost::$template_library$::$template_library$<int> object;
- int x = 0;
- BOOST_CHECK_EQUAL(object.get_call_count(),0);
- object.nothing(x,4);
- BOOST_CHECK_EQUAL(object.get_call_count(),1);
- BOOST_CHECK_EQUAL(object.get_nothing_count(),4);
- }
+ boost::$template_library$::$template_library$<int> object;
+ int x = 0;
+ BOOST_CHECK_EQUAL(object.get_nothing_count(),0);
+ object.nothing(x);
+ BOOST_CHECK_EQUAL(object.get_nothing_count(),1);
+
+ return 0;
 };
-
-test_suite *$template_library$_test()
-{
- test_suite *suite = BOOST_TEST_SUITE("$template_library$ suite");
-
- boost::shared_ptr<test_class> instance( new test_class() );
- suite->add (BOOST_CLASS_TEST_CASE( &test_class::test_nothing, instance));
- suite->add (BOOST_CLASS_TEST_CASE( &test_class::test_nothing_n, instance));
- return suite;
-}
-
-#define BOOST_TEST_MAIN
-boost::unit_test::test_suite* init_unit_test_suite(int, char* [] )
-{
- test_suite * test = BOOST_TEST_SUITE("_Boost_Library_ test");
- test->add($template_library$_test());
- return test;
-}
\ No newline at end of file

Added: sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/test_nothing_n.cpp
==============================================================================
--- (empty file)
+++ sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/test/test_nothing_n.cpp 2007-06-13 00:01:25 EDT (Wed, 13 Jun 2007)
@@ -0,0 +1,23 @@
+// Copyright 2007 Stjepan Rajko.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+$template_start$
+$template_cpp_copyright$
+
+#include <boost/$template_library$.hpp>
+
+#include <boost/test/included/test_exec_monitor.hpp>
+
+int test_main(int, char* [])
+{
+ boost::$template_library$::$template_library$<int> object;
+ int x = 0;
+ BOOST_CHECK_EQUAL(object.get_call_count(),0);
+ object.nothing(x,4);
+ BOOST_CHECK_EQUAL(object.get_call_count(),1);
+ BOOST_CHECK_EQUAL(object.get_nothing_count(),4);
+
+ return 0;
+};


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk