Boost logo

Boost-Commit :

From: srajko_at_[hidden]
Date: 2007-06-25 14:33:23


Author: srajko
Date: 2007-06-25 14:33:22 EDT (Mon, 25 Jun 2007)
New Revision: 7143
URL: http://svn.boost.org/trac/boost/changeset/7143

Log:
add python script testing, change sandbox example so it's not using boost.test

Added:
   sandbox/template_under_construction/file_template/libs/file_template/test/test.py (contents, props changed)
Removed:
   sandbox/template_under_construction/file_template/libs/file_template/test/test.sh
Text files modified:
   sandbox/template_under_construction/file_template/libs/file_template/build/xcodeide/file_template.xcodeproj/project.pbxproj | 2 ++
   sandbox/template_under_construction/file_template/libs/file_template/doc/sandbox.qbk | 11 ++++++++++-
   sandbox/template_under_construction/file_template/libs/file_template/doc/templates.qbk | 15 ++++++++++++++-
   sandbox/template_under_construction/file_template/libs/file_template/test/bjam_sandbox_test.sh | 2 +-
   sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_command_line/my_library/libs/my_library/example/Jamfile | 1 -
   sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_command_line/my_library/libs/my_library/example/example.cpp | 20 ++++++++------------
   sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_global_htmlfiles/my_library/libs/my_library/example/Jamfile | 1 -
   sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_global_htmlfiles/my_library/libs/my_library/example/example.cpp | 20 ++++++++------------
   sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_ide/my_library/libs/my_library/example/Jamfile | 1 -
   sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_ide/my_library/libs/my_library/example/example.cpp | 20 ++++++++------------
   sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/example/Jamfile | 1 -
   sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/example/example.cpp | 20 ++++++++------------
   12 files changed, 59 insertions(+), 55 deletions(-)

Modified: sandbox/template_under_construction/file_template/libs/file_template/build/xcodeide/file_template.xcodeproj/project.pbxproj
==============================================================================
--- sandbox/template_under_construction/file_template/libs/file_template/build/xcodeide/file_template.xcodeproj/project.pbxproj (original)
+++ sandbox/template_under_construction/file_template/libs/file_template/build/xcodeide/file_template.xcodeproj/project.pbxproj 2007-06-25 14:33:22 EDT (Mon, 25 Jun 2007)
@@ -97,12 +97,14 @@
                 08F006150C2B888F00093576 /* sandbox.py */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.script.python; path = sandbox.py; sourceTree = "<group>"; };
                 08F006160C2B890E00093576 /* project.pbxproj.py */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.script.python; name = project.pbxproj.py; path = $template_library$.xcodeproj/project.pbxproj.py; sourceTree = "<group>"; };
                 08F062730C283EA9005301DA /* file_template.py */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.script.python; name = file_template.py; path = ../../../../../file_template.py; sourceTree = SOURCE_ROOT; };
+ 08F105890C303C6200CEFC5F /* bjam_sandbox_test.sh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.script.sh; name = bjam_sandbox_test.sh; path = ../../test/bjam_sandbox_test.sh; sourceTree = SOURCE_ROOT; };
 /* End PBXFileReference section */
 
 /* Begin PBXGroup section */
                 0818EB840C26438D00DB816F /* test */ = {
                         isa = PBXGroup;
                         children = (
+ 08F105890C303C6200CEFC5F /* bjam_sandbox_test.sh */,
                                 0818EB850C26439C00DB816F /* test.py */,
                         );
                         name = test;

Modified: sandbox/template_under_construction/file_template/libs/file_template/doc/sandbox.qbk
==============================================================================
--- sandbox/template_under_construction/file_template/libs/file_template/doc/sandbox.qbk (original)
+++ sandbox/template_under_construction/file_template/libs/file_template/doc/sandbox.qbk 2007-06-25 14:33:22 EDT (Mon, 25 Jun 2007)
@@ -352,7 +352,16 @@
 [endsect]
 [endsect][/reference]
 
-[section:changes Proposed Changes]
+[section:changes Version History and Proposed Changes]
+
+[heading Version History]
+
+* started supporting Xcode IDE generation
+* the author option and template substitutions changed to authors to match the quickbook syntax
+* changed $template\_cpp\_copyright$ and $template\_py\_copyright$ to just $template\_copyright$.
+
+
+[heading Proposed Changes]
 
 * In the MSVC projects, the Rebuild action is mapped to a =bjam -a= invocation. This causes
 all projects required to be rebuilt, and might not be the most common use case (i.e., if

Modified: sandbox/template_under_construction/file_template/libs/file_template/doc/templates.qbk
==============================================================================
--- sandbox/template_under_construction/file_template/libs/file_template/doc/templates.qbk (original)
+++ sandbox/template_under_construction/file_template/libs/file_template/doc/templates.qbk 2007-06-25 14:33:22 EDT (Mon, 25 Jun 2007)
@@ -309,7 +309,20 @@
 
 [endsect]
 
-[section:changes Proposed changes]
+[section:changes Version History and Proposed changes]
+
+[heading Version History]
+
+[*version 0.94]
+
+* =make_template.py= changed to =file_template.py=
+* `template.all_content_replacement` changed to `template.general_content_replacement`
+* added `template.ignore` function which can ignore any file/directory in the source tree
+ (available as [^ignore=] command line option)
+* added testing
+* made to work on non-windows and on Python 2.3
+
+[heading Proposed Changes]
 
 * a =no-scripts= option should be introduced to disallow processing of
 in-template scripts (in case a template

Modified: sandbox/template_under_construction/file_template/libs/file_template/test/bjam_sandbox_test.sh
==============================================================================
--- sandbox/template_under_construction/file_template/libs/file_template/test/bjam_sandbox_test.sh (original)
+++ sandbox/template_under_construction/file_template/libs/file_template/test/bjam_sandbox_test.sh 2007-06-25 14:33:22 EDT (Mon, 25 Jun 2007)
@@ -4,7 +4,7 @@
 # http://www.boost.org/LICENSE_1_0.txt)
 
 current=`pwd`
-cd results/sandbox_command_line/test/libs/test/doc
+cd results/sandbox_command_line/my_library/libs/my_library/doc
 bjam $*
 cd ../example
 bjam $*

Modified: sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_command_line/my_library/libs/my_library/example/Jamfile
==============================================================================
--- sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_command_line/my_library/libs/my_library/example/Jamfile (original)
+++ sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_command_line/my_library/libs/my_library/example/Jamfile 2007-06-25 14:33:22 EDT (Mon, 25 Jun 2007)
@@ -7,7 +7,6 @@
 project
     : requirements
       <include>../../..
- <library>/boost/test//boost_unit_test_framework/<link>static
       <define>BOOST_ALL_NO_LIB=1
     ;
 

Modified: sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_command_line/my_library/libs/my_library/example/example.cpp
==============================================================================
--- sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_command_line/my_library/libs/my_library/example/example.cpp (original)
+++ sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_command_line/my_library/libs/my_library/example/example.cpp 2007-06-25 14:33:22 EDT (Mon, 25 Jun 2007)
@@ -5,32 +5,28 @@
 
 
 //[ my_library_example
-#include <boost/test/unit_test.hpp>
-using boost::unit_test::test_suite;
 
 #include <boost/my_library.hpp>
+#include <boost/assert.hpp>
 
 void my_library_example()
 {
     boost::my_library::my_library<int> object;
     int x = 0;
 
- BOOST_CHECK_EQUAL(object.get_nothing_count(),0);
+ BOOST_ASSERT(object.get_nothing_count()==0);
     object.nothing(x);
- BOOST_CHECK_EQUAL(object.get_nothing_count(),1);
+ BOOST_ASSERT(object.get_nothing_count()==1);
 
- BOOST_CHECK_EQUAL(object.get_call_count(),1);
+ BOOST_ASSERT(object.get_call_count()==1);
     object.nothing(x,4);
- BOOST_CHECK_EQUAL(object.get_call_count(),2);
- BOOST_CHECK_EQUAL(object.get_nothing_count(),5);
+ BOOST_ASSERT(object.get_call_count()==2);
+ BOOST_ASSERT(object.get_nothing_count()==5);
 
 } // end void my_library_example
 
-test_suite* init_unit_test_suite(int argc, char* argv[])
+int main()
 {
- test_suite* test = BOOST_TEST_SUITE( "RPC test suite" );
- test->add(BOOST_TEST_CASE(&my_library_example));
- return test;
+ my_library_example();
 }
-
 //]

Modified: sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_global_htmlfiles/my_library/libs/my_library/example/Jamfile
==============================================================================
--- sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_global_htmlfiles/my_library/libs/my_library/example/Jamfile (original)
+++ sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_global_htmlfiles/my_library/libs/my_library/example/Jamfile 2007-06-25 14:33:22 EDT (Mon, 25 Jun 2007)
@@ -7,7 +7,6 @@
 project
     : requirements
       <include>../../..
- <library>/boost/test//boost_unit_test_framework/<link>static
       <define>BOOST_ALL_NO_LIB=1
     ;
 

Modified: sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_global_htmlfiles/my_library/libs/my_library/example/example.cpp
==============================================================================
--- sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_global_htmlfiles/my_library/libs/my_library/example/example.cpp (original)
+++ sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_global_htmlfiles/my_library/libs/my_library/example/example.cpp 2007-06-25 14:33:22 EDT (Mon, 25 Jun 2007)
@@ -5,32 +5,28 @@
 
 
 //[ my_library_example
-#include <boost/test/unit_test.hpp>
-using boost::unit_test::test_suite;
 
 #include <boost/my_library.hpp>
+#include <boost/assert.hpp>
 
 void my_library_example()
 {
     boost::my_library::my_library<int> object;
     int x = 0;
 
- BOOST_CHECK_EQUAL(object.get_nothing_count(),0);
+ BOOST_ASSERT(object.get_nothing_count()==0);
     object.nothing(x);
- BOOST_CHECK_EQUAL(object.get_nothing_count(),1);
+ BOOST_ASSERT(object.get_nothing_count()==1);
 
- BOOST_CHECK_EQUAL(object.get_call_count(),1);
+ BOOST_ASSERT(object.get_call_count()==1);
     object.nothing(x,4);
- BOOST_CHECK_EQUAL(object.get_call_count(),2);
- BOOST_CHECK_EQUAL(object.get_nothing_count(),5);
+ BOOST_ASSERT(object.get_call_count()==2);
+ BOOST_ASSERT(object.get_nothing_count()==5);
 
 } // end void my_library_example
 
-test_suite* init_unit_test_suite(int argc, char* argv[])
+int main()
 {
- test_suite* test = BOOST_TEST_SUITE( "RPC test suite" );
- test->add(BOOST_TEST_CASE(&my_library_example));
- return test;
+ my_library_example();
 }
-
 //]

Modified: sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_ide/my_library/libs/my_library/example/Jamfile
==============================================================================
--- sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_ide/my_library/libs/my_library/example/Jamfile (original)
+++ sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_ide/my_library/libs/my_library/example/Jamfile 2007-06-25 14:33:22 EDT (Mon, 25 Jun 2007)
@@ -7,7 +7,6 @@
 project
     : requirements
       <include>../../..
- <library>/boost/test//boost_unit_test_framework/<link>static
       <define>BOOST_ALL_NO_LIB=1
     ;
 

Modified: sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_ide/my_library/libs/my_library/example/example.cpp
==============================================================================
--- sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_ide/my_library/libs/my_library/example/example.cpp (original)
+++ sandbox/template_under_construction/file_template/libs/file_template/test/expected/sandbox_ide/my_library/libs/my_library/example/example.cpp 2007-06-25 14:33:22 EDT (Mon, 25 Jun 2007)
@@ -5,32 +5,28 @@
 
 
 //[ my_library_example
-#include <boost/test/unit_test.hpp>
-using boost::unit_test::test_suite;
 
 #include <boost/my_library.hpp>
+#include <boost/assert.hpp>
 
 void my_library_example()
 {
     boost::my_library::my_library<int> object;
     int x = 0;
 
- BOOST_CHECK_EQUAL(object.get_nothing_count(),0);
+ BOOST_ASSERT(object.get_nothing_count()==0);
     object.nothing(x);
- BOOST_CHECK_EQUAL(object.get_nothing_count(),1);
+ BOOST_ASSERT(object.get_nothing_count()==1);
 
- BOOST_CHECK_EQUAL(object.get_call_count(),1);
+ BOOST_ASSERT(object.get_call_count()==1);
     object.nothing(x,4);
- BOOST_CHECK_EQUAL(object.get_call_count(),2);
- BOOST_CHECK_EQUAL(object.get_nothing_count(),5);
+ BOOST_ASSERT(object.get_call_count()==2);
+ BOOST_ASSERT(object.get_nothing_count()==5);
 
 } // end void my_library_example
 
-test_suite* init_unit_test_suite(int argc, char* argv[])
+int main()
 {
- test_suite* test = BOOST_TEST_SUITE( "RPC test suite" );
- test->add(BOOST_TEST_CASE(&my_library_example));
- return test;
+ my_library_example();
 }
-
 //]

Added: sandbox/template_under_construction/file_template/libs/file_template/test/test.py
==============================================================================
--- (empty file)
+++ sandbox/template_under_construction/file_template/libs/file_template/test/test.py 2007-06-25 14:33:22 EDT (Mon, 25 Jun 2007)
@@ -0,0 +1,100 @@
+# 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)
+
+import os.path
+import sys
+import StringIO
+import os
+import filecmp
+import difflib
+import re
+
+global test_results
+
+def compare(a, b):
+ global test_results
+ dircmp = filecmp.dircmp(a, b, ['RCS', 'CVS', 'tags', '.svn', '.DS_Store'])
+ if len(dircmp.diff_files) or len(dircmp.left_only) or len(dircmp.right_only):
+ test_results += '...comparing ' + a + ' and ' + b + '...\n'
+ for item in dircmp.diff_files:
+ test_results += 'Differing file ' + item + '\n'
+ linesa = open(os.path.join(a, item), "rb").readlines()
+ linesb = open(os.path.join(b, item), "rb").readlines()
+
+ id = re.compile(' [a-fA-F0-9]{24} ')
+ if item == 'project.pbxproj':
+ test_results += 'Compensating for UUID differences.\n'
+ for i in range(0,len(linesa)):
+ linesa[i] = re.sub(id, ' UUIDUUIDUUIDUUIDUUIDUUID ', linesa[i])
+ for i in range(0,len(linesb)):
+ linesb[i] = re.sub(id, ' UUIDUUIDUUIDUUIDUUIDUUID ', linesb[i])
+ id = re.compile(r'\{([a-fA-F0-9]){8}\-[a-fA-F0-9]{4}\-[a-fA-F0-9]{4}\-[a-fA-F0-9]{4}\-[a-fA-F0-9]{12}\}')
+ if item.endswith('.vcproj') or item.endswith('.sln'):
+ test_results += 'Compensating for UUID differences.\n'
+ for i in range(0,len(linesa)):
+ linesa[i] = re.sub(id, '{UUIDUUIDUUIDUUIDUUIDUUID}', linesa[i])
+ for i in range(0,len(linesb)):
+ linesb[i] = re.sub(id, '{UUIDUUIDUUIDUUIDUUIDUUID}', linesb[i])
+
+ for line in difflib.unified_diff(linesb, linesa):
+ test_results += line
+ if len(dircmp.left_only):
+ test_results += 'Extra: ' + str(dircmp.left_only) + '\n'
+ if len(dircmp.right_only):
+ test_results += 'Missing: ' + str(dircmp.right_only) + '\n'
+ for item in dircmp.common_dirs:
+ compare(os.path.join(a, item), os.path.join(b, item))
+
+def run_test (result, expected, input, arguments):
+
+ result=os.path.join('results', result)
+ expected=os.path.join('expected', expected)
+
+ sys.stdin = StringIO.StringIO(input)
+ sys.argv = ['file_template.py', 'destination=' + result] + arguments
+
+ global test_results
+ test_results += '----------------\n'
+ test_results += 'input | file_template.py ' + str(arguments) + '\n'
+ test_results += '----------------\n'
+
+ path = os.path.abspath('../../../..')
+ sys_path = list(sys.path)
+ sys.path.append(path)
+ if sys.modules.has_key('file_template'):
+ del(sys.modules['file_template'])
+ __import__('file_template', globals(), dict())
+ sys.path = sys_path
+
+ compare (result, expected)
+
+print 'Erasing test.results...'
+if os.path.exists('test.results'):
+ os.remove('test.results')
+
+for root, dirs, files in os.walk('results', topdown=False):
+ for name in files:
+ os.remove(os.path.join(root, name))
+ for name in dirs:
+ print os.path.join(root, name)
+ os.rmdir(os.path.join(root, name))
+
+test_results = ''
+
+run_test('simple_type_in', 'simple_template', 'substituted\n', ['simple_template'])
+run_test('simple_command_line', 'simple_template', '', ['simple_template', 'text=substituted'])
+run_test('simple_ignore', 'simple_template_ignored', '', ['simple_template', 'text=substituted', 'ignore=$template_text$'])
+run_test('simple_fignore', 'simple_template_fignored', '', ['simple_template', 'text=substituted', 'fignore=.txt'])
+run_test('sandbox_command_line', 'sandbox_command_line', '', ['../../../../sandbox', 'authors=John Doe', 'library=my_library'])
+run_test('sandbox_global_htmlfiles', 'sandbox_global_htmlfiles', '', ['../../../../sandbox', 'authors=John Doe,Jane H. Dough', 'library=my_library', 'htmlfiles=global'])
+run_test('sandbox_ide', 'sandbox_ide', '', ['../../../../sandbox', 'authors=John Doe,Jane H. Dough,Jan De_Man', 'library=my_library', 'vc8ide=y', 'xcodeide=y'])
+
+print
+print
+print
+print '--------------------------------------------------------'
+print '- Final test.results diff:'
+
+print test_results
\ No newline at end of file

Deleted: sandbox/template_under_construction/file_template/libs/file_template/test/test.sh
==============================================================================
--- sandbox/template_under_construction/file_template/libs/file_template/test/test.sh 2007-06-25 14:33:22 EDT (Mon, 25 Jun 2007)
+++ (empty file)
@@ -1,34 +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)
-
-run_test ()
-{
- result=results/$1
- expected=expected/$2
- input=$3
- shift 3
- echo ---------------- | cat >>test.results
- echo $input \| make_template.py $* | cat >>test.results
- echo ---------------- | cat >>test.results
- echo $input | python2.3 ../../../../make_template.py destination=$result "$@"
- diff -b -r $expected $result | cat >>test.results
-}
-
-rm test.results
-rm -r results
-
-run_test simple_type_in simple_template substituted simple_template
-run_test simple_command_line simple_template "" simple_template text=substituted
-run_test simple_ignore simple_template_ignored "" simple_template text=substituted ignore=\$template_text\$
-run_test simple_fignore simple_template_fignored "" simple_template text=substituted fignore=.txt
-run_test sandbox_command_line sandbox_test "" ../../../../sandbox "author=John Doe,Jane H. Dough" library=test
-
-echo
-echo
-echo
-echo --------------------------------------------------------
-echo - Final test.results diff:
-
-cat test.results

Modified: sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/example/Jamfile
==============================================================================
--- sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/example/Jamfile (original)
+++ sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/example/Jamfile 2007-06-25 14:33:22 EDT (Mon, 25 Jun 2007)
@@ -9,7 +9,6 @@
 project
     : requirements
       <include>../../..
- <library>/boost/test//boost_unit_test_framework/<link>static
       <define>BOOST_ALL_NO_LIB=1
     ;
 

Modified: sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/example/example.cpp
==============================================================================
--- sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/example/example.cpp (original)
+++ sandbox/template_under_construction/sandbox/$template_library$/libs/$template_library$/example/example.cpp 2007-06-25 14:33:22 EDT (Mon, 25 Jun 2007)
@@ -7,32 +7,28 @@
 $template_copyright$
 
 //[ $template_library$_example
-#include <boost/test/unit_test.hpp>
-using boost::unit_test::test_suite;
 
 #include <boost/$template_library$.hpp>
+#include <boost/assert.hpp>
 
 void $template_library$_example()
 {
     boost::$template_library$::$template_library$<int> object;
     int x = 0;
 
- BOOST_CHECK_EQUAL(object.get_nothing_count(),0);
+ BOOST_ASSERT(object.get_nothing_count()==0);
     object.nothing(x);
- BOOST_CHECK_EQUAL(object.get_nothing_count(),1);
+ BOOST_ASSERT(object.get_nothing_count()==1);
 
- BOOST_CHECK_EQUAL(object.get_call_count(),1);
+ BOOST_ASSERT(object.get_call_count()==1);
     object.nothing(x,4);
- BOOST_CHECK_EQUAL(object.get_call_count(),2);
- BOOST_CHECK_EQUAL(object.get_nothing_count(),5);
+ BOOST_ASSERT(object.get_call_count()==2);
+ BOOST_ASSERT(object.get_nothing_count()==5);
 
 } // end void $template_library$_example
 
-test_suite* init_unit_test_suite(int argc, char* argv[])
+int main()
 {
- test_suite* test = BOOST_TEST_SUITE( "RPC test suite" );
- test->add(BOOST_TEST_CASE(&$template_library$_example));
- return test;
+ $template_library$_example();
 }
-
 //]
\ No newline at end of file


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