From 1257c0ce7cc1222f9334efdf4c076fdd73b5e413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Cavelan?= Date: Wed, 24 Jul 2024 13:34:43 +0200 Subject: [PATCH] update the cxxtest contrib package to the latest version --- contrib/cxxtest/README | 2 +- contrib/cxxtest/cxxtest/Descriptions.cpp | 1 + contrib/cxxtest/cxxtest/ErrorFormatter.h | 17 +- contrib/cxxtest/cxxtest/LinkedList.cpp | 2 + contrib/cxxtest/cxxtest/Mock.h | 4 +- contrib/cxxtest/cxxtest/TestSuite.h | 64 +++ contrib/cxxtest/cxxtest/ValueTraits.cpp | 8 +- contrib/cxxtest/cxxtest/XmlFormatter.h | 6 +- contrib/cxxtest/doc/Makefile | 2 +- contrib/cxxtest/doc/epub/README | 42 +- contrib/cxxtest/doc/epub/bin/dbtoepub | 12 +- contrib/cxxtest/doc/epub/docbook.xsl | 184 ++++---- contrib/cxxtest/doc/examples/test_examples.py | 4 +- contrib/cxxtest/doc/guide.txt | 126 +++--- contrib/cxxtest/python/README.txt | 2 +- contrib/cxxtest/python/cxxtest/.gitignore | 1 + contrib/cxxtest/python/cxxtest/cxx_parser.py | 154 +++---- contrib/cxxtest/python/cxxtest/cxxtest_fog.py | 4 +- .../cxxtest/python/cxxtest/cxxtest_parser.py | 4 +- contrib/cxxtest/python/cxxtest/cxxtestgen.py | 12 +- .../python/python3/cxxtest/cxx_parser.py | 156 +++---- .../python/python3/cxxtest/cxxtest_fog.py | 4 +- .../python/python3/cxxtest/cxxtest_parser.py | 8 +- .../python/python3/cxxtest/cxxtestgen.py | 12 +- contrib/cxxtest/sample/.cvsignore | 5 + contrib/cxxtest/sample/Makefile.bcc32 | 4 +- contrib/cxxtest/sample/Makefile.msvc | 4 +- contrib/cxxtest/sample/SCons/SConstruct | 16 +- .../cxxtest/sample/SCons/tests/stack_test.h | 6 +- contrib/cxxtest/sample/msvc/CxxTest_1_Run.dsp | 16 +- .../cxxtest/sample/msvc/CxxTest_2_Build.dsp | 14 +- .../sample/msvc/CxxTest_3_Generate.dsp | 16 +- contrib/cxxtest/sample/msvc/FixFiles.bat | 16 +- contrib/cxxtest/sample/only.tpl | 2 +- contrib/cxxtest/sample/parts/.cvsignore | 1 + contrib/cxxtest/test/.cvsignore | 1 + contrib/cxxtest/test/CharAssertions.h | 112 +++++ contrib/cxxtest/test/NullPtrGuards.h | 19 + contrib/cxxtest/test/char_assertions.out | 21 + contrib/cxxtest/test/fake/.cvsignore | 1 + contrib/cxxtest/test/fake/X11/Xlib.h | 2 +- contrib/cxxtest/test/nullptr_guards.out | 17 + contrib/cxxtest/test/preamble.tpl | 2 +- contrib/cxxtest/test/test_cxxtest.py | 403 ++++++++++-------- 44 files changed, 911 insertions(+), 598 deletions(-) create mode 100644 contrib/cxxtest/python/cxxtest/.gitignore create mode 100644 contrib/cxxtest/sample/.cvsignore create mode 100644 contrib/cxxtest/sample/parts/.cvsignore create mode 100644 contrib/cxxtest/test/.cvsignore create mode 100644 contrib/cxxtest/test/CharAssertions.h create mode 100644 contrib/cxxtest/test/NullPtrGuards.h create mode 100644 contrib/cxxtest/test/char_assertions.out create mode 100644 contrib/cxxtest/test/fake/.cvsignore create mode 100644 contrib/cxxtest/test/nullptr_guards.out diff --git a/contrib/cxxtest/README b/contrib/cxxtest/README index 87aea1bf3..98d2e29f4 100644 --- a/contrib/cxxtest/README +++ b/contrib/cxxtest/README @@ -21,7 +21,7 @@ MyTestSuite.h: #include - class MyTestSuite : public CxxTest::TestSuite + class MyTestSuite : public CxxTest::TestSuite { public: void testAddition( void ) diff --git a/contrib/cxxtest/cxxtest/Descriptions.cpp b/contrib/cxxtest/cxxtest/Descriptions.cpp index 17e9de35c..09829a253 100644 --- a/contrib/cxxtest/cxxtest/Descriptions.cpp +++ b/contrib/cxxtest/cxxtest/Descriptions.cpp @@ -13,6 +13,7 @@ #define __cxxtest__Descriptions_cpp__ #include +#include namespace CxxTest { diff --git a/contrib/cxxtest/cxxtest/ErrorFormatter.h b/contrib/cxxtest/cxxtest/ErrorFormatter.h index 81582a3aa..3319dec74 100644 --- a/contrib/cxxtest/cxxtest/ErrorFormatter.h +++ b/contrib/cxxtest/cxxtest/ErrorFormatter.h @@ -130,33 +130,31 @@ class ErrorFormatter : public TestListener void trace(const char *file, int line, const char *expression) { - stop(file, line) << "Trace: " << - expression << endl; + stop(file, line) << "Trace: " << (expression ? expression : "") << endl; } void warning(const char *file, int line, const char *expression) { stop(file, line) << _warningString << ": " << - expression << endl; + (expression ? expression : "") << endl; } void skippedTest(const char *file, int line, const char *expression) { - if(expression && strlen(expression) > 0) - stop(file, line) << _warningString << ": Test skipped: " << - expression << endl; + stop(file, line) << _warningString << ": Test skipped: " << + (expression ? expression : "") << endl; } void failedTest(const char *file, int line, const char *expression) { stop(file, line) << _errorString << ": Test failed: " << - expression << endl; + (expression ? expression : "") << endl; } void failedAssert(const char *file, int line, const char *expression) { stop(file, line) << _errorString << ": Assertion failed: " << - expression << endl; + (expression ? expression : "") << endl; } void failedAssertEquals(const char *file, int line, @@ -185,7 +183,8 @@ class ErrorFormatter : public TestListener const char* explanation ) { - stop(file, line) << _errorString << ": " << explanation << endl; + stop(file, line) << _errorString << ": " << + (explanation ? explanation : "") << endl; } void failedAssertDelta(const char *file, int line, diff --git a/contrib/cxxtest/cxxtest/LinkedList.cpp b/contrib/cxxtest/cxxtest/LinkedList.cpp index 223e4d9ba..01a801a4a 100644 --- a/contrib/cxxtest/cxxtest/LinkedList.cpp +++ b/contrib/cxxtest/cxxtest/LinkedList.cpp @@ -13,6 +13,8 @@ #define __cxxtest__LinkedList_cpp__ #include +#include +#include namespace CxxTest { diff --git a/contrib/cxxtest/cxxtest/Mock.h b/contrib/cxxtest/cxxtest/Mock.h index 2ba2a436e..59814d034 100644 --- a/contrib/cxxtest/cxxtest/Mock.h +++ b/contrib/cxxtest/cxxtest/Mock.h @@ -225,14 +225,14 @@ namespace dummy_mock_ns {} { \ CXXTEST_MOCK_NAMESPACE::Base_##MOCK::current().NAME CALL; \ } \ - + // // Error for calling mock function w/o object // #define __CXXTEST_MOCK_UNIMPLEMENTED( NAME, ARGS ) \ TS_FAIL( CXXTEST_MOCK_NAMESPACE_STR #NAME #ARGS " called with no " \ CXXTEST_MOCK_NAMESPACE_STR "Base_" #NAME " object" ); \ - + #define CXXTEST_MOCK_NAMESPACE_STR __CXXTEST_STR(CXXTEST_MOCK_NAMESPACE) "::" #define __CXXTEST_STR(X) __CXXTEST_XSTR(X) #define __CXXTEST_XSTR(X) #X diff --git a/contrib/cxxtest/cxxtest/TestSuite.h b/contrib/cxxtest/cxxtest/TestSuite.h index b34c45d33..7a184ec39 100644 --- a/contrib/cxxtest/cxxtest/TestSuite.h +++ b/contrib/cxxtest/cxxtest/TestSuite.h @@ -168,6 +168,70 @@ struct differs } }; +template<> +struct differs +{ + static bool test(const char *x, const char *y) + { + if ((x != 0) && (y != 0)) + { + return (CXXTEST_STD(strcmp(x, y)) != 0); + } + else + { + return (x != y); + } + } +}; + +template<> +struct differs +{ + static bool test(char *x, char *y) + { + if ((x != 0) && (y != 0)) + { + return (CXXTEST_STD(strcmp(x, y)) != 0); + } + else + { + return (x != y); + } + } +}; + +template<> +struct differs +{ + static bool test(const char *x, char *y) + { + if ((x != 0) && (y != 0)) + { + return (CXXTEST_STD(strcmp(x, y)) != 0); + } + else + { + return (x != y); + } + } +}; + +template<> +struct differs +{ + static bool test(char *x, const char *y) + { + if ((x != 0) && (y != 0)) + { + return (CXXTEST_STD(strcmp(x, y)) != 0); + } + else + { + return (x != y); + } + } +}; + template void doAssertDiffers(const char *file, int line, const char *xExpr, X x, diff --git a/contrib/cxxtest/cxxtest/ValueTraits.cpp b/contrib/cxxtest/cxxtest/ValueTraits.cpp index 095830ad9..dd169debc 100644 --- a/contrib/cxxtest/cxxtest/ValueTraits.cpp +++ b/contrib/cxxtest/cxxtest/ValueTraits.cpp @@ -152,7 +152,7 @@ void ValueTraits::hugeNumber(double t) s = copyString(s, "."); s = doubleToString(t, s, 1, DIGITS_ON_RIGHT); s = copyString(s, "E"); - s = numberToString(requiredDigitsOnLeft(t) - 1, s); + numberToString(requiredDigitsOnLeft(t) - 1, s); } void ValueTraits::normalNumber(double t) @@ -171,17 +171,17 @@ void ValueTraits::nonFiniteNumber(double t) char *s = _asString; if (t != t) { - s = copyString(s, "nan"); + copyString(s, "nan"); } //else if ( t == 1.0/0.0 ) else if (t >= HUGE_VAL) { - s = copyString(s, "-inf"); + copyString(s, "-inf"); } else if (t <= -HUGE_VAL) { //else if ( t == -1.0/0.0 ) - s = copyString(s, "inf"); + copyString(s, "inf"); } } diff --git a/contrib/cxxtest/cxxtest/XmlFormatter.h b/contrib/cxxtest/cxxtest/XmlFormatter.h index b6fd1a2f9..863bd3029 100644 --- a/contrib/cxxtest/cxxtest/XmlFormatter.h +++ b/contrib/cxxtest/cxxtest/XmlFormatter.h @@ -598,7 +598,7 @@ class XmlFormatter : public TestListener std::string retVal; const time_t now(time(NULL)); char current_date_string[27]; - + #ifdef WIN32 if (ctime_s(current_date_string, sizeof(current_date_string)-1, &now) == 0) { @@ -607,11 +607,11 @@ class XmlFormatter : public TestListener } #else const size_t n = strlen(ctime_r(&now, current_date_string)); - if (n) + if (n) { current_date_string[n-1] = '\0'; // remove the ending \n retVal = current_date_string; - } + } #endif return retVal; } diff --git a/contrib/cxxtest/doc/Makefile b/contrib/cxxtest/doc/Makefile index f3e890f1e..31726a0fe 100644 --- a/contrib/cxxtest/doc/Makefile +++ b/contrib/cxxtest/doc/Makefile @@ -19,7 +19,7 @@ A2X_OPTS := -a toc -a icons -L -d article -v --xsltproc-opts "$(XSLTPROC_OP all: guide.html guide.pdf guide.epub -manpages: +manpages: cd man; ./create_manpage; cd man; asciidoc -v -d manpage ./cxxtestgen.1.txt diff --git a/contrib/cxxtest/doc/epub/README b/contrib/cxxtest/doc/epub/README index 5e2587a12..e3b9598b5 100644 --- a/contrib/cxxtest/doc/epub/README +++ b/contrib/cxxtest/doc/epub/README @@ -5,42 +5,42 @@ These are XSL stylesheets for transforming DocBook XML document instances into .epub format. -.epub is an open standard of the The International Digital Publishing Forum (IDPF), -a the trade and standards association for the digital publishing industry. +.epub is an open standard of the The International Digital Publishing Forum (IDPF), +a the trade and standards association for the digital publishing industry. -An alpha-quality reference implementation (dbtoepub) for a DocBook to .epub -converter (written in Ruby) is available under bin/. +An alpha-quality reference implementation (dbtoepub) for a DocBook to .epub +converter (written in Ruby) is available under bin/. From http://idpf.org What is EPUB, .epub, OPS/OCF & OEB? - ".epub" is the file extension of an XML format for reflowable digital - books and publications. ".epub" is composed of three open standards, - the Open Publication Structure (OPS), Open Packaging Format (OPF) and - Open Container Format (OCF), produced by the IDPF. "EPUB" allows - publishers to produce and send a single digital publication file - through distribution and offers consumers interoperability between - software/hardware for unencrypted reflowable digital books and other - publications. The Open eBook Publication Structure or "OEB", - originally produced in 1999, is the precursor to OPS. + ".epub" is the file extension of an XML format for reflowable digital + books and publications. ".epub" is composed of three open standards, + the Open Publication Structure (OPS), Open Packaging Format (OPF) and + Open Container Format (OCF), produced by the IDPF. "EPUB" allows + publishers to produce and send a single digital publication file + through distribution and offers consumers interoperability between + software/hardware for unencrypted reflowable digital books and other + publications. The Open eBook Publication Structure or "OEB", + originally produced in 1999, is the precursor to OPS. ---------------------------------------------------------------------- -.epub Constraints +.epub Constraints ---------------------------------------------------------------------- .epub does not support all of the image formats that DocBook supports. When an image is available in an accepted format, it will be used. The accepted @formats are: 'GIF','GIF87a','GIF89a','JPEG','JPG','PNG','SVG' -A mime-type for the image will be guessed from the file extension, +A mime-type for the image will be guessed from the file extension, which may not work if your file extensions are non-standard. Non-supported elements: - * - * , , , with text/XML + * + * , , , with text/XML @filerefs * * in lists (generic XHTML rendering inability) - * (just make your programlistings + * (just make your programlistings siblings, rather than descendents of paras) ---------------------------------------------------------------------- @@ -48,7 +48,7 @@ dbtoepub Reference Implementation ---------------------------------------------------------------------- An alpha-quality DocBook to .epub conversion program, dbtoepub, is provided -in bin/dbtoepub. +in bin/dbtoepub. This tool requires: - 'xsltproc' in your PATH @@ -65,7 +65,7 @@ $ dbtoepub --help .epub is defined by the IDPF at www.idpf.org and is made up of 3 standards: - Open Publication Structure (OPS) - - Open Packaging Format (OPF) + - Open Packaging Format (OPF) - Open Container Format (OCF) Specific options: @@ -78,7 +78,7 @@ $ dbtoepub --help Validation ---------------------------------------------------------------------- -The epubcheck project provides limited validation for .epub documents. +The epubcheck project provides limited validation for .epub documents. See http://code.google.com/p/epubcheck/ for details. ---------------------------------------------------------------------- diff --git a/contrib/cxxtest/doc/epub/bin/dbtoepub b/contrib/cxxtest/doc/epub/bin/dbtoepub index 9976f816a..a0737e757 100755 --- a/contrib/cxxtest/doc/epub/bin/dbtoepub +++ b/contrib/cxxtest/doc/epub/bin/dbtoepub @@ -1,11 +1,11 @@ #!/usr/bin/env ruby # This program converts DocBook documents into .epub files. -# +# # Usage: dbtoepub [OPTIONS] [DocBook Files] # # .epub is defined by the IDPF at www.idpf.org and is made up of 3 standards: # - Open Publication Structure (OPS) -# - Open Packaging Format (OPF) +# - Open Packaging Format (OPF) # - Open Container Format (OCF) # # Specific options: @@ -43,7 +43,7 @@ opts.banner = "Usage: #{File.basename($0)} [OPTIONS] [DocBook Files] .epub is defined by the IDPF at www.idpf.org and is made up of 3 standards: - Open Publication Structure (OPS) -- Open Packaging Format (OPF) +- Open Packaging Format (OPF) - Open Container Format (OCF) Specific options:" @@ -68,9 +68,9 @@ db_files.each {|docbook_file| if output_file epub_file = output_file - else + else epub_file = File.basename(docbook_file, ".xml") + ".epub" - end + end puts "Rendering DocBook file #{docbook_file} to #{epub_file}" if verbose e.render_to_file(epub_file) -} +} diff --git a/contrib/cxxtest/doc/epub/docbook.xsl b/contrib/cxxtest/doc/epub/docbook.xsl index 753fcd00c..542aee572 100644 --- a/contrib/cxxtest/doc/epub/docbook.xsl +++ b/contrib/cxxtest/doc/epub/docbook.xsl @@ -1,8 +1,8 @@ - - + 4 - + - - - - - - + + + + + + - + ncxtoc htmltoc - + @@ -57,7 +57,7 @@ @@ -69,7 +69,7 @@ - + @@ -191,10 +191,10 @@ - + - @@ -221,7 +221,7 @@ - + _ @@ -263,21 +263,21 @@ - + + mode="opf.metadata"/> - + - + cover @@ -355,7 +355,7 @@ type="cover" pointing to it AND there is a logical cover specified in a tag, THEN, the HTML cover is discarded. --> - + cover @@ -576,7 +576,7 @@ - + : @@ -584,14 +584,14 @@ - + - + @@ -601,7 +601,7 @@ - + @@ -639,10 +639,10 @@ - + - + @@ -650,7 +650,7 @@ cover Cover - + @@ -662,9 +662,9 @@ toc Table of Contents - - - + + + @@ -674,7 +674,7 @@ - + @@ -696,7 +696,7 @@ yes - + @@ -707,7 +707,7 @@ - + @@ -746,7 +746,7 @@ - + @@ -756,15 +756,15 @@ - + - + application/xhtml+xml - + @@ -811,7 +811,7 @@ //inlinegraphic| //mediaobject| //mediaobjectco| - //inlinemediaobject" + //inlinemediaobject" mode="opf.manifest"/> @@ -822,7 +822,7 @@ - + @@ -894,7 +894,7 @@ @@ -909,27 +909,27 @@ - - + mode="opf.manifest"/> + mode="opf.manifest"/> - + + mode="opf.manifest"/> + mode="opf.manifest"/> - + WARNING: mediaobjectco almost certainly will not render as expected in .epub! - + @@ -961,7 +961,7 @@ + mode="opf.manifest"> @@ -980,8 +980,8 @@ - - + + @@ -992,7 +992,7 @@ - + @@ -1004,10 +1004,10 @@ - + - + @@ -1040,13 +1040,13 @@ - + - + @@ -1058,7 +1058,7 @@ - + @@ -1072,7 +1072,7 @@ - application/xhtml+xml - - + + @@ -1268,11 +1268,11 @@ - + + priority="1"> @@ -1372,7 +1372,7 @@ - + - + priority="1"> + @@ -1400,7 +1400,7 @@ - @@ -1435,11 +1435,11 @@ - + No insertfile extension available. Use a different processor (with extensions) or turn on $use.extensions and $textinsert.extension (see docs for more). - + @@ -1447,11 +1447,11 @@ - + - + @@ -1493,8 +1493,8 @@ - - + + @@ -1538,15 +1538,15 @@ ) - + - diff --git a/contrib/cxxtest/doc/examples/test_examples.py b/contrib/cxxtest/doc/examples/test_examples.py index 059b91157..073a64775 100644 --- a/contrib/cxxtest/doc/examples/test_examples.py +++ b/contrib/cxxtest/doc/examples/test_examples.py @@ -24,9 +24,9 @@ datere = re.compile("date=\"[^\"]*\"") failure = re.compile("^(?P.+)file=\"(?P[^\"]+)\"(?P.*)$") -#print "FOO", dirre +#print "FOO", dirre def filter(line): - # for xml, remove prefixes from everything that looks like a + # for xml, remove prefixes from everything that looks like a # file path inside "" line = xmlre.sub( lambda match: '"'+re.sub("^[^/]+/", "", match.group(1))+'"', diff --git a/contrib/cxxtest/doc/guide.txt b/contrib/cxxtest/doc/guide.txt index 7eb1e1a7e..910292487 100644 --- a/contrib/cxxtest/doc/guide.txt +++ b/contrib/cxxtest/doc/guide.txt @@ -27,7 +27,7 @@ Overview CxxTest is a unit testing framework for C++ that is similar in spirit to http://junit.org/[JUnit], http://cppunit.sourceforge.net[CppUnit], and -http://xprogramming.com/software.html[xUnit]. +http://xprogramming.com/software.html[xUnit]. CxxTest is designed to be as portable as possible; it does not require - RTTI @@ -365,7 +365,7 @@ The only difference is the parentheses used in the output. This test listener p The +StdioPrinter+ makes reference to +stdout+ as the default output stream. In some environments, the +stdio.h+ header may be defined but not +stdout+. The +StdioFilePrinter+ test listener can be used -in this case, though the main() function needs to be adapted to specify the +in this case, though the main() function needs to be adapted to specify the stream that is used in output. //// @@ -402,7 +402,10 @@ This test runner generates the following output: ---- include::examples/buildRunner7.txt[] ---- -The default filename for the XML results is +TEST-cxxtest.xml+. The +--xunit-file+ option can be used to specify an alternative filename. Additionally, the value of the +--world+ option can be used to specify the filename +TEST-.xml+. +The default filename for the XML results is +TEST-cxxtest.xml+. The ++--xunit-file+ option can be used to specify an alternative filename. +Additionally, the value of the +--world+ option can be used to specify the +filename +TEST-.xml+. Language Options @@ -422,7 +425,7 @@ should use the standard library, and the +--no-std+ option indicates that the test runner should not use the standard library. The --have-eh+ options indicates that the test runner should use exception handling, and the +--no-eh+ indicates that the test runner -should not not use exception handling. +should not not use exception handling. The +--longlong+ option specifies the type used for long long integers. The default is for _no_ long long integer type to be specified, @@ -437,12 +440,14 @@ for compilers or linkers that have trouble compiling the default test runner. Creating Test Runners from Parts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The default behavior of +cxxtestgen+ is to generate a test runner -that directly integrates classes that define the tests along with -a +main()+ function that executes all test suites. It is often useful to -allow test suites to be processes separately and then linked together. The +--root+ and +--part+ options -support this logic. For example, suppose that we wish to define a test runner for tests in the headers -MyTestSuite1.h+ and +MyTestSuite2.h+. We execute +cxxtestgen+ with the +--part+ option to generate source files for each of the test suites: +The default behavior of +cxxtestgen+ is to generate a test runner that directly +integrates classes that define the tests along with a +main()+ function that +executes all test suites. It is often useful to allow test suites to be +processes separately and then linked together. The +--root+ and +--part+ +options support this logic. For example, suppose that we wish to define a test +runner for tests in the headers MyTestSuite1.h+ and +MyTestSuite2.h+. We +execute +cxxtestgen+ with the +--part+ option to generate source files for each +of the test suites: [source,bash] ---- include::examples/.buildRunner9_part.sh[] @@ -479,7 +484,8 @@ For example, consider the following template file: ---- include::examples/runner10.tpl[] ---- -This file specifies macros that customize the test runner, and output is generated before and after the tests are run. +This file specifies macros that customize the test runner, and output is +generated before and after the tests are run. Note that CxxTest needs to insert certain definitions and +#include+ directives in the runner file. It normally does that before the @@ -676,15 +682,15 @@ CxxTest recognizes a variety of preprocessor macros that can be used to modify t [options="header"] |==================================================================================== -| Preprocessor Macro | Description -| +CXXTEST_HAVE_STD+ | Use the standard library. -| +CXXTEST_HAVE_EH+ | Use exception handling. -| +CXXTEST_ABORT_TEST_ON_FAIL+ | Abort tests on failed asserts. -| +CXXTEST_USER_VALUE_TRAITS+ | Enable user-defined value traits. The default traits dump up to 8 bytes of the data as hex values. -| +CXXTEST_OLD_TEMPLATE_SYNTAX+ | Use old template syntax that is used by some compilers (e.g. Borland C++ 5). -| +CXXTEST_OLD_STD+ | Use old syntax for libraries where +std::+ is not recognized. -| +CXXTEST_MAX_DUMP_SIZE+ | The value of this macro defines the maximum number of bytes to dump if +TS_ASSERT_SAME_DATA()+ fails. The default is 0, which indicates no limit. -| +CXXTEST_DEFAULT_ABORT+ | The value of this macro is the default value of the dynamic _abort on fail_ flag. +| Preprocessor Macro | Description +| +CXXTEST_HAVE_STD+ | Use the standard library. +| +CXXTEST_HAVE_EH+ | Use exception handling. +| +CXXTEST_ABORT_TEST_ON_FAIL+ | Abort tests on failed asserts. +| +CXXTEST_USER_VALUE_TRAITS+ | Enable user-defined value traits. The default traits dump up to 8 bytes of the data as hex values. +| +CXXTEST_OLD_TEMPLATE_SYNTAX+ | Use old template syntax that is used by some compilers (e.g. Borland C++ 5). +| +CXXTEST_OLD_STD+ | Use old syntax for libraries where +std::+ is not recognized. +| +CXXTEST_MAX_DUMP_SIZE+ | The value of this macro defines the maximum number of bytes to dump if +TS_ASSERT_SAME_DATA()+ fails. The default is 0, which indicates no limit. +| +CXXTEST_DEFAULT_ABORT+ | The value of this macro is the default value of the dynamic _abort on fail_ flag. | +CXXTEST_LONGLONG+ | The value of this macro is used to define long long integers. |===================================== @@ -737,7 +743,7 @@ virtual functions `TestSuite::setUp()` and `TestSuite::tearDown()`. The `setUp()` function is called before each test, and `tearDown()` is called after each test. -For example, the following test suite employs +setUp()+ and +tearDown()+ methods to +For example, the following test suite employs +setUp()+ and +tearDown()+ methods to allocate and deallocate memory for a string buffer: [source,{cpp}] ----- @@ -821,7 +827,7 @@ CxxTest defines several functions that can be called in a test suite to modify t |================================== | Test Suite Method | Description | +setAbortTestOnFail(bool)+ | This function specifies whether tests abort after a failure. The default value of the flag is +false+. This function only has an effect if exception handling is enabled. -| +setMaxDumpSize(unsigned)+ | This function sets the maximum number of bytes that are dumped when +| +setMaxDumpSize(unsigned)+ | This function sets the maximum number of bytes that are dumped when +TS_ASSERT_SAME_DATA()+ fails. The default is 0, which indicates no limit. |============= @@ -897,7 +903,7 @@ include::examples/buildRunner19.txt[] ----- The enumeration value traits print strings that represent the elements of the enumeration, except where a numeric value is provided. -Note that the `CXXTEST_ENUM_TRAITS` macros has two arguments; the list of `CXXTEST_ENUM_MEMBER` macros is not separated by commas! +Note that the `CXXTEST_ENUM_TRAITS` macros has two arguments; the list of `CXXTEST_ENUM_MEMBER` macros is not separated by commas! Defining New Value Traits @@ -966,9 +972,9 @@ when ``bad'' things happen (e.g., when `fopen()` fails). Handling these types of exceptional conditions is often a very challenging issue for software testing. -CxxTest addresses this challenge by providing a generic mechanism for -defining mock global functions. The next section illustrates this mechanism for a single -global function. The following section provides more detail about specific features of CxxTest's +CxxTest addresses this challenge by providing a generic mechanism for +defining mock global functions. The next section illustrates this mechanism for a single +global function. The following section provides more detail about specific features of CxxTest's support for mock testing. @@ -1029,7 +1035,7 @@ Test Suites using Mock Functions A mock object for the `time()` function is created using the `T::Base_time` class, which is automatically created by CxxTest. This class includes a `time()` method whose API is the same as the global `time()` function. Thus, this method can be defined to have -whatever behavior is desired during testing. For example, the following example defines a +whatever behavior is desired during testing. For example, the following example defines a mock object that increments a counter to define an incremental value for `time()`. [source,{cpp}] ----- @@ -1066,7 +1072,7 @@ Advanced Topics Void Functions ^^^^^^^^^^^^^^ -The `CXXTEST_MOCK_VOID_GLOBAL` is used to define mock global functions that return `void`. +The `CXXTEST_MOCK_VOID_GLOBAL` is used to define mock global functions that return `void`. This is identical to `CXXTEST_MOCK_GLOBAL` except that it does not specify the return type. Take a look in `sample/mock/T/stdlib.h` for a demonstation. @@ -1114,7 +1120,7 @@ Functions in Namespaces ^^^^^^^^^^^^^^^^^^^^^^^ The `CXXTEST_MOCK` macro is used to declare a mock global function that is associated -with a function in a namespace, including static class member functions. +with a function in a namespace, including static class member functions. For example, consider the function `bool Files::FileExists( const String &name )`; the namespace `Files` contains the function `FileExists`. The mock class will be called `T::Base_Files_FileExists` @@ -1148,14 +1154,14 @@ Overloaded Functions The `CXXTEST_MOCK` and `CXXTEST_MOCK_VOID` macros have a flexible interface that can provide mock global function definitions for overloaded functions. The arguments simply need to specify different -mock class names, mock member names and different prototype definitions. +mock class names, mock member names and different prototype definitions. These different mock declarations will generate different mock objects that can be explicitly referenced in a test suite. The Mock Namespace ^^^^^^^^^^^^^^^^^^ -The default namespace for mock functions is `T::`. This namespace can be changed by defining the +The default namespace for mock functions is `T::`. This namespace can be changed by defining the `CXXTEST_MOCK_NAMESPACE` macro. @@ -1176,7 +1182,7 @@ The FOG parser requires two Python packages: - +ply+ - +ordereddict+ (This is needed when running Python 2.4, 2.5 or 2.6) -If these packages are not available, then +cxxtestgen+ will generate an error when the +If these packages are not available, then +cxxtestgen+ will generate an error when the FOG parser option is selected. If you have http://pypi.python.org/pypi/setuptools[setuptools] or @@ -1195,7 +1201,6 @@ Python 2.4. Note that this script has only been tested with the CPython implementation. CxxTest has been tested on Linux and Mac platforms using the `g++` and `clang++` compilers. - //// WEH - I thought about moving this section into the Getting Started @@ -1205,6 +1210,30 @@ distribution model is very strategic for cxxtest. //// +### Mac + +If when using a makefile such as +--- +test: + cxxtestgen --runner=ErrorPrinter -o slinkedlist-runner.cpp slinkedlist-test.cpp + cxxtestgen --runner=ErrorPrinter -o dlinkedlist-runner.cpp dlinkedlist-test.cpp + g++ -o test-runner slinkedlist-runner.cpp + g++ -o test-runner dlinkedlist-runner.cpp + ./test-runner +--- + +you receive the error +--- +fatal error: 'cxxtest/TestListener.h' file not found +--- + +And your PATH is correct, try running +--- +xcode-select --install +--- + +to authorize Xcode and let your header files work +See http://stackoverflow.com/questions/23905661/on-mac-g-fails-to-search-usr-local-include-and-usr-local-lib-by-default [[discussion]] @@ -1248,7 +1277,8 @@ default output stream. This test listener can be used in contexts where a custom output stream must be specified. //// -WEH - I'd like to say more about future support for CxxTest, but I don't know more basic things like how we should plan to host CxxTest in the future. +WEH - I'd like to say more about future support for CxxTest, but I don't know +more basic things like how we should plan to host CxxTest in the future. Discuss support for ... @@ -1272,7 +1302,7 @@ CXXTEST_LONGLONG :numbered!: -[[acknowledgements]] +[[acknowledgements]] Acknowledgements ---------------- @@ -1283,7 +1313,7 @@ developers contributed to the CxxTest 4.x releases: * Andrey Batyiev * Olivier Charloton * Dave Elcock -* Kevin Fitch +* Kevin Fitch * William Hart * Allan Odgaard * Lionel Orry @@ -1304,7 +1334,7 @@ mechanism that is based on a parser of the Flexible Object Language extract high-level class structure for test discovery. FOG was developed by Edward Willink: -* Edward D. Willink. 'Meta-Compilation for C++', PhD Thesis, Computer Science Research Group, University of Surrey, January 2000. +* Edward D. Willink. 'Meta-Compilation for C++', PhD Thesis, Computer Science Research Group, University of Surrey, January 2000. The FOG parser in CxxTest critically relies on the excellent LALR parser provided by Dave Beazley's `ply` Python package. The scalable @@ -1322,7 +1352,7 @@ National Nuclear Security Administration under contract DE-AC04-94AL85000. [appendix] -[[appendix_A]] +[[appendix_A]] Test Assertion Examples ----------------------- @@ -1388,8 +1418,8 @@ This test assertion takes as an argument the name of a class, similar to a STL + ---- include::examples/.Assertions_assertPredicate.h[] ---- -This test assertion can be seen as a generalization of <>, but it -allows the tester to see the failed value. +This test assertion can be seen as a generalization of <>, but it +allows the tester to see the failed value. [[ts_assert_relation]] TS_ASSERT_RELATION:: It takes as an argument the name of a class, similar to a STL +binary_function+, and evaluates the +operator()+ method: @@ -1397,8 +1427,8 @@ It takes as an argument the name of a class, similar to a STL +binary_function+, ---- include::examples/.Assertions_assertRelation.h[] ---- -This test assertion can be seen as a generalization of <>, <>, <> and <>. -This can be used to assert comparisons which are not covered by the builtin test assertions. +This test assertion can be seen as a generalization of <>, <>, <> and <>. +This can be used to assert comparisons which are not covered by the builtin test assertions. [[ts_assert_same_data]] TS_ASSERT_SAME_DATA:: This test assertion is similar to <>, @@ -1424,7 +1454,7 @@ include::examples/.Assertions_assertThrowsAnything.h[] ---- [[ts_assert_throws_assert]] TS_ASSERT_THROWS_ASSERT:: -This test assertion verifies that an exception is thrown when executing the first argument. The second argument specifies a variable declaration for the exception, and the third argument is executed to test that +This test assertion verifies that an exception is thrown when executing the first argument. The second argument specifies a variable declaration for the exception, and the third argument is executed to test that exception value: [source,{cpp}] ---- @@ -1490,7 +1520,7 @@ include::examples/.Assertions_warn.h[] [appendix] -[[appendix_B]] +[[appendix_B]] Integrating with Your Build Environment --------------------------------------- @@ -1745,7 +1775,7 @@ runner.cpp: SimpleTest.h ComplicatedTest.h Using Cons ~~~~~~~~~~ -http://dsmit.com/cons/[Cons] is a powerful and +http://dsmit.com/cons/[Cons] is a powerful and versatile make replacement which uses Perl scripts instead of Makefiles. See `cxxtest/sample/Construct` in the CxxTest distribution for an @@ -1782,14 +1812,14 @@ how to do this is in the CxxTest distribution under `sample/winddk`. [appendix] -[[appendix_C]] +[[appendix_C]] Testing CxxTest --------------- In the +cxxtest/test+ directory, you can execute [source,bash] ---- -python test_cxxtest.py +python test_cxxtest.py ---- to launch all tests. By default, this script executes test suites for a variety of compilers if they are found on the user's path: @@ -1835,7 +1865,7 @@ If these packages are not available, then +test_cxxtest.py+ will skip the FOG te [appendix] -[[appendix_D]] +[[appendix_D]] include::../Versions[] // vim: ft=asciidoc diff --git a/contrib/cxxtest/python/README.txt b/contrib/cxxtest/python/README.txt index 1cd84b902..90b166ba0 100644 --- a/contrib/cxxtest/python/README.txt +++ b/contrib/cxxtest/python/README.txt @@ -3,6 +3,6 @@ CxxTest Python Package The CxxTest Python package includes utilities that are used by the CxxTest unit testing framework. Specifically, this Python package -supports C++ parsing and code generation done in the cxxtestgen +supports C++ parsing and code generation done in the cxxtestgen script. diff --git a/contrib/cxxtest/python/cxxtest/.gitignore b/contrib/cxxtest/python/cxxtest/.gitignore new file mode 100644 index 000000000..0d20b6487 --- /dev/null +++ b/contrib/cxxtest/python/cxxtest/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/contrib/cxxtest/python/cxxtest/cxx_parser.py b/contrib/cxxtest/python/cxxtest/cxx_parser.py index b9761b329..37327b000 100644 --- a/contrib/cxxtest/python/cxxtest/cxx_parser.py +++ b/contrib/cxxtest/python/cxxtest/cxx_parser.py @@ -10,7 +10,7 @@ # vim: fileencoding=utf-8 # -# This is a PLY parser for the entire ANSI C++ grammar. This grammar was +# This is a PLY parser for the entire ANSI C++ grammar. This grammar was # adapted from the FOG grammar developed by E. D. Willink. See # # http://www.computing.surrey.ac.uk/research/dsrg/fog/ @@ -18,7 +18,7 @@ # for further details. # # The goal of this grammar is to extract information about class, function and -# class method declarations, along with their associated scope. Thus, this +# class method declarations, along with their associated scope. Thus, this # grammar can be used to analyze classes in an inheritance heirarchy, and then # enumerate the methods in a derived class. # @@ -35,9 +35,9 @@ # # 2. Template class specialization. Although the goal of this grammar is to # extract class information, specialization of templated classes is -# not supported. When a template class definition is parsed, it's +# not supported. When a template class definition is parsed, it's # declaration is archived without information about the template -# parameters. Class specializations will be stored separately, and +# parameters. Class specializations will be stored separately, and # thus they can be processed after the fact. However, this grammar # does not attempt to correctly process properties of class inheritence # when template class specialization is employed. @@ -82,7 +82,7 @@ def __init__(self,name,abs_name,scope_t,base_classes,lineno): self.base_classes=base_classes self.abs_name=abs_name self.lineno=lineno - + def insert(self,scope): self.sub_scopes.append(scope) @@ -137,13 +137,13 @@ def get_functions(self,name,quiet=False): else: fns += self.get_functions(cname,quiet) return fns - + def find_class(self,name,scope): if ':' in name: if name in self.index: return name else: - return None + return None tmp = scope.abs_name.split(':') name1 = ":".join(tmp[:-1] + [name]) if name1 in self.index: @@ -289,11 +289,11 @@ def flatten(x): '__attribute__' : 'ATTRIBUTE', '__cdecl__' : 'CDECL', '__typeof' : 'uTYPEOF', - 'typeof' : 'TYPEOF', + 'typeof' : 'TYPEOF', 'CXXTEST_STD' : 'CXXTEST_STD' } - + tokens = [ "CharacterLiteral", "FloatingLiteral", @@ -402,17 +402,17 @@ def t_newline(t): # # The %prec resolves the 14.2-3 ambiguity: # Identifier '<' is forced to go through the is-it-a-template-name test -# All names absorb TEMPLATE with the name, so that no template_test is -# performed for them. This requires all potential declarations within an -# expression to perpetuate this policy and thereby guarantee the ultimate +# All names absorb TEMPLATE with the name, so that no template_test is +# performed for them. This requires all potential declarations within an +# expression to perpetuate this policy and thereby guarantee the ultimate # coverage of explicit_instantiation. # -# The %prec also resolves a conflict in identifier : which is forced to be a -# shift of a label for a labeled-statement rather than a reduction for the -# name of a bit-field or generalised constructor. This is pretty dubious -# syntactically but correct for all semantic possibilities. The shift is -# only activated when the ambiguity exists at the start of a statement. -# In this context a bit-field declaration or constructor definition are not +# The %prec also resolves a conflict in identifier : which is forced to be a +# shift of a label for a labeled-statement rather than a reduction for the +# name of a bit-field or generalised constructor. This is pretty dubious +# syntactically but correct for all semantic possibilities. The shift is +# only activated when the ambiguity exists at the start of a statement. +# In this context a bit-field declaration or constructor definition are not # allowed. # @@ -469,10 +469,10 @@ def p_scoped_id(p): p[0] = "".join(data) # -# destructor_id has to be held back to avoid a conflict with a one's -# complement as per 5.3.1-9, It gets put back only when scoped or in a +# destructor_id has to be held back to avoid a conflict with a one's +# complement as per 5.3.1-9, It gets put back only when scoped or in a # declarator_id, which is only used as an explicit member name. -# Declarations of an unscoped destructor are always parsed as a one's +# Declarations of an unscoped destructor are always parsed as a one's # complement. # def p_destructor_id(p): @@ -526,10 +526,10 @@ def p_declarator_id(p): p[0]=p[1] # -# The standard defines pseudo-destructors in terms of type-name, which is -# class/enum/typedef, of which class-name is covered by a normal destructor. -# pseudo-destructors are supposed to support ~int() in templates, so the -# grammar here covers built-in names. Other names are covered by the lack +# The standard defines pseudo-destructors in terms of type-name, which is +# class/enum/typedef, of which class-name is covered by a normal destructor. +# pseudo-destructors are supposed to support ~int() in templates, so the +# grammar here covers built-in names. Other names are covered by the lack # of identifier/type discrimination. # def p_built_in_type_id(p): @@ -584,39 +584,39 @@ def p_translation_unit(p): # A.4 Expressions #------------------------------------------------------------------------------- # -# primary_expression covers an arbitrary sequence of all names with the -# exception of an unscoped destructor, which is parsed as its unary expression -# which is the correct disambiguation (when ambiguous). This eliminates the -# traditional A(B) meaning A B ambiguity, since we never have to tack an A -# onto the front of something that might start with (. The name length got -# maximised ab initio. The downside is that semantic interpretation must split +# primary_expression covers an arbitrary sequence of all names with the +# exception of an unscoped destructor, which is parsed as its unary expression +# which is the correct disambiguation (when ambiguous). This eliminates the +# traditional A(B) meaning A B ambiguity, since we never have to tack an A +# onto the front of something that might start with (. The name length got +# maximised ab initio. The downside is that semantic interpretation must split # the names up again. # -# Unification of the declaration and expression syntax means that unary and +# Unification of the declaration and expression syntax means that unary and # binary pointer declarator operators: # int * * name -# are parsed as binary and unary arithmetic operators (int) * (*name). Since +# are parsed as binary and unary arithmetic operators (int) * (*name). Since # type information is not used # ambiguities resulting from a cast # (cast)*(value) -# are resolved to favour the binary rather than the cast unary to ease AST -# clean-up. The cast-call ambiguity must be resolved to the cast to ensure +# are resolved to favour the binary rather than the cast unary to ease AST +# clean-up. The cast-call ambiguity must be resolved to the cast to ensure # that (a)(b)c can be parsed. # # The problem of the functional cast ambiguity # name(arg) -# as call or declaration is avoided by maximising the name within the parsing -# kernel. So primary_id_expression picks up +# as call or declaration is avoided by maximising the name within the parsing +# kernel. So primary_id_expression picks up # extern long int const var = 5; -# as an assignment to the syntax parsed as "extern long int const var". The -# presence of two names is parsed so that "extern long into const" is -# distinguished from "var" considerably simplifying subsequent +# as an assignment to the syntax parsed as "extern long int const var". The +# presence of two names is parsed so that "extern long into const" is +# distinguished from "var" considerably simplifying subsequent # semantic resolution. # -# The generalised name is a concatenation of potential type-names (scoped -# identifiers or built-in sequences) plus optionally one of the special names -# such as an operator-function-id, conversion-function-id or destructor as the -# final name. +# The generalised name is a concatenation of potential type-names (scoped +# identifiers or built-in sequences) plus optionally one of the special names +# such as an operator-function-id, conversion-function-id or destructor as the +# final name. # def get_rest(p): @@ -648,7 +648,7 @@ def p_postfix_expression(p): | postfix_expression '.' declarator_id | postfix_expression '.' scoped_pseudo_destructor_id | postfix_expression ARROW declarator_id - | postfix_expression ARROW scoped_pseudo_destructor_id + | postfix_expression ARROW scoped_pseudo_destructor_id | postfix_expression INC | postfix_expression DEC | DYNAMIC_CAST '<' nonlgt_seq_opt '>' '(' expression ')' @@ -755,8 +755,8 @@ def p_new_initializer_opt(p): pass # -# cast-expression is generalised to support a [] as well as a () prefix. This covers the omission of -# DELETE[] which when followed by a parenthesised expression was ambiguous. It also covers the gcc +# cast-expression is generalised to support a [] as well as a () prefix. This covers the omission of +# DELETE[] which when followed by a parenthesised expression was ambiguous. It also covers the gcc # indexed array initialisation for free. # def p_cast_expression(p): @@ -848,7 +848,7 @@ def p_conditional_expression(p): # -# assignment-expression is generalised to cover the simple assignment of a braced initializer in order to +# assignment-expression is generalised to cover the simple assignment of a braced initializer in order to # contribute to the coverage of parameter-declaration and init-declaration. # # | logical_or_expression assignment_operator assignment_expression @@ -861,7 +861,7 @@ def p_assignment_expression(p): p[0]=get_rest(p) def p_assignment_operator(p): - '''assignment_operator : '=' + '''assignment_operator : '=' | ASS_ADD | ASS_AND | ASS_DIV @@ -990,7 +990,7 @@ def p_declaration_statement(p): # A.6 Declarations #--------------------------------------------------------------------------------------------------- def p_compound_declaration(p): - '''compound_declaration : LBRACE declaration_seq_opt RBRACE + '''compound_declaration : LBRACE declaration_seq_opt RBRACE ''' pass @@ -1052,7 +1052,7 @@ def p_simple_declaration(p): # # A decl-specifier following a ptr_operator provokes a shift-reduce conflict for * const name which is resolved in favour of the pointer, and implemented by providing versions of decl-specifier guaranteed not to start with a cv_qualifier. decl-specifiers are implemented type-centrically. That is the semantic constraint that there must be a type is exploited to impose structure, but actually eliminate very little syntax. built-in types are multi-name and so need a different policy. # -# non-type decl-specifiers are bound to the left-most type in a decl-specifier-seq, by parsing from the right and attaching suffixes to the right-hand type. Finally residual prefixes attach to the left. +# non-type decl-specifiers are bound to the left-most type in a decl-specifier-seq, by parsing from the right and attaching suffixes to the right-hand type. Finally residual prefixes attach to the left. # def p_suffix_built_in_decl_specifier_raw(p): '''suffix_built_in_decl_specifier_raw : built_in_type_specifier @@ -1070,8 +1070,8 @@ def p_suffix_built_in_decl_specifier(p): # | id_scope_seq # | SCOPE id_scope_seq def p_suffix_named_decl_specifier(p): - '''suffix_named_decl_specifier : scoped_id - | elaborate_type_specifier + '''suffix_named_decl_specifier : scoped_id + | elaborate_type_specifier | suffix_named_decl_specifier decl_specifier_suffix ''' p[0]=get_rest(p) @@ -1135,8 +1135,8 @@ def p_decl_specifier_prefix(p): pass def p_storage_class_specifier(p): - '''storage_class_specifier : REGISTER - | STATIC + '''storage_class_specifier : REGISTER + | STATIC | MUTABLE | EXTERN %prec SHIFT_THERE | EXTENSION @@ -1190,16 +1190,16 @@ def p_attribute(p): ''' def p_Xbuilt_in_type_specifier(p): - '''Xbuilt_in_type_specifier : CHAR - | WCHAR_T - | BOOL - | SHORT - | INT - | LONG - | SIGNED - | UNSIGNED - | FLOAT - | DOUBLE + '''Xbuilt_in_type_specifier : CHAR + | WCHAR_T + | BOOL + | SHORT + | INT + | LONG + | SIGNED + | UNSIGNED + | FLOAT + | DOUBLE | VOID | uTYPEOF parameters_clause | TYPEOF parameters_clause @@ -1383,7 +1383,7 @@ def p_cv_qualifier_seq_opt(p): # TODO: verify that we should include attributes here def p_cv_qualifier(p): - '''cv_qualifier : CONST + '''cv_qualifier : CONST | VOLATILE | attributes ''' @@ -1516,7 +1516,7 @@ def p_function_block(p): pass def p_function_body(p): - '''function_body : LBRACE nonbrace_seq_opt RBRACE + '''function_body : LBRACE nonbrace_seq_opt RBRACE ''' p[0] = ['{','}'] @@ -1549,8 +1549,8 @@ def p_initializer_list(p): # The two usages are too distant to try to create and enforce a common prefix so we have to resort to # a parser hack by backtracking. Inheritance is much the most likely so we mark the input stream context # and try to parse a base-clause. If we successfully reach a { the base-clause is ok and inheritance was -# the correct choice so we unmark and continue. If we fail to find the { an error token causes -# back-tracking to the alternative parse in elaborated_type_specifier which regenerates the : and +# the correct choice so we unmark and continue. If we fail to find the { an error token causes +# back-tracking to the alternative parse in elaborated_type_specifier which regenerates the : and # declares unconditional success. # @@ -1572,11 +1572,11 @@ def p_class_specifier_head(p): else: scope = "" _parse_info.push_scope(scope,p[1],base_classes) - + def p_class_key(p): - '''class_key : CLASS - | STRUCT + '''class_key : CLASS + | STRUCT | UNION ''' p[0] = p[1] @@ -1680,8 +1680,8 @@ def p_base_specifier(p): p[0] = p[2] def p_access_specifier(p): - '''access_specifier : PRIVATE - | PROTECTED + '''access_specifier : PRIVATE + | PROTECTED | PUBLIC ''' pass @@ -2184,7 +2184,7 @@ def parse_cpp(data=None, filename=None, debug=0, optimize=0, verbose=False, func if __name__ == '__main__': #pragma: no cover # # This MAIN routine parses a sequence of files provided at the command - # line. If '-v' is included, then a verbose parsing output is + # line. If '-v' is included, then a verbose parsing output is # generated. # for arg in sys.argv[1:]: @@ -2197,8 +2197,8 @@ def parse_cpp(data=None, filename=None, debug=0, optimize=0, verbose=False, func parse_cpp(filename=arg,verbose=2) # # Print the _parse_info object summary for this file. - # This illustrates how class inheritance can be used to + # This illustrates how class inheritance can be used to # deduce class members. - # + # print str(_parse_info) diff --git a/contrib/cxxtest/python/cxxtest/cxxtest_fog.py b/contrib/cxxtest/python/cxxtest/cxxtest_fog.py index a157b6834..6fdc59f94 100644 --- a/contrib/cxxtest/python/cxxtest/cxxtest_fog.py +++ b/contrib/cxxtest/python/cxxtest/cxxtest_fog.py @@ -36,7 +36,7 @@ def scanInputFiles(files, _options): print " error." print str(err) continue - print "done." + print "done." sys.stdout.flush() # # WEH: see if it really makes sense to use parse information to @@ -55,7 +55,7 @@ def scanInputFiles(files, _options): fullname = key[2:] else: fullname = key - suite = { + suite = { 'fullname' : fullname, 'name' : name, 'file' : file, diff --git a/contrib/cxxtest/python/cxxtest/cxxtest_parser.py b/contrib/cxxtest/python/cxxtest/cxxtest_parser.py index d7c8f2057..86a58f586 100644 --- a/contrib/cxxtest/python/cxxtest/cxxtest_parser.py +++ b/contrib/cxxtest/python/cxxtest/cxxtest_parser.py @@ -73,7 +73,7 @@ def scanInputFile(fileName): prev = "" if contNo: scanInputLine( fileName, lineNo - contNo, prev + line ) - + closeSuite() file.close() @@ -193,7 +193,7 @@ def addLineToBlock( suite, lineNo, line ): '''Append the line to the current CXXTEST_CODE() block''' line = fixBlockLine( suite, lineNo, line ) line = re.sub( r'^.*\{\{', '', line ) - + e = re.search( r'\}\}', line ) if e: line = line[:e.start()] diff --git a/contrib/cxxtest/python/cxxtest/cxxtestgen.py b/contrib/cxxtest/python/cxxtest/cxxtestgen.py index 99437cd82..ff43dbb62 100644 --- a/contrib/cxxtest/python/cxxtest/cxxtestgen.py +++ b/contrib/cxxtest/python/cxxtest/cxxtestgen.py @@ -196,7 +196,7 @@ def parseCommandline(args): if options.error_printer: options.runner= "ErrorPrinter" options.haveStandardLibrary = True - + if options.noStaticInit and (options.root or options.part): abort( '--no-static-init cannot be used with --root/--part' ) @@ -386,7 +386,7 @@ def writeInclude(output, file): global lastIncluded if options.outputFileName: dirname = os.path.split(options.outputFileName)[0] - tfile = relpath(file, dirname) + tfile = relpath(file, dirname) if os.path.exists(tfile): if tfile == lastIncluded: return output.writelines( [ '#include "', tfile, '"\n\n' ] ) @@ -446,7 +446,7 @@ def writeTestDescription( output, suite, test ): output.write( 'static class %s : public CxxTest::RealTestDescription {\n' % test['class'] ) else: output.write( 'class %s : public CxxTest::RealTestDescription {\n' % test['class'] ) - # + # output.write( 'public:\n' ) if not options.noStaticInit: output.write( ' %s() : CxxTest::RealTestDescription( %s, %s, %s, "%s" ) {}\n' % @@ -461,7 +461,7 @@ def writeTestDescription( output, suite, test ): (test['class'], suite['fullname'], suite['object'], suite['object'], suite['object']) ) output.write( ' %s& %s;\n' % (suite['fullname'], suite['object']) ) output.write( ' void runTest() { %s }\n' % runBody( suite, test ) ) - # + # if not options.noStaticInit: output.write( '} %s;\n\n' % test['object'] ) else: @@ -475,11 +475,11 @@ def runBody( suite, test ): def dynamicRun( suite, test ): '''Body of TestDescription::run() for test in a dynamic suite''' return 'if ( ' + suite['object'] + ' ) ' + suite['object'] + '->' + test['name'] + '();' - + def staticRun( suite, test ): '''Body of TestDescription::run() for test in a non-dynamic suite''' return suite['object'] + '.' + test['name'] + '();' - + def writeSuiteDescription( output, suite ): '''Write SuiteDescription object''' if isDynamic( suite ): diff --git a/contrib/cxxtest/python/python3/cxxtest/cxx_parser.py b/contrib/cxxtest/python/python3/cxxtest/cxx_parser.py index c3b7561e3..ca9d7aee1 100644 --- a/contrib/cxxtest/python/python3/cxxtest/cxx_parser.py +++ b/contrib/cxxtest/python/python3/cxxtest/cxx_parser.py @@ -10,7 +10,7 @@ # vim: fileencoding=utf-8 # -# This is a PLY parser for the entire ANSI C++ grammar. This grammar was +# This is a PLY parser for the entire ANSI C++ grammar. This grammar was # adapted from the FOG grammar developed by E. D. Willink. See # # http://www.computing.surrey.ac.uk/research/dsrg/fog/ @@ -18,7 +18,7 @@ # for further details. # # The goal of this grammar is to extract information about class, function and -# class method declarations, along with their associated scope. Thus, this +# class method declarations, along with their associated scope. Thus, this # grammar can be used to analyze classes in an inheritance heirarchy, and then # enumerate the methods in a derived class. # @@ -35,9 +35,9 @@ # # 2. Template class specialization. Although the goal of this grammar is to # extract class information, specialization of templated classes is -# not supported. When a template class definition is parsed, it's +# not supported. When a template class definition is parsed, it's # declaration is archived without information about the template -# parameters. Class specializations will be stored separately, and +# parameters. Class specializations will be stored separately, and # thus they can be processed after the fact. However, this grammar # does not attempt to correctly process properties of class inheritence # when template class specialization is employed. @@ -82,7 +82,7 @@ def __init__(self,name,abs_name,scope_t,base_classes,lineno): self.base_classes=base_classes self.abs_name=abs_name self.lineno=lineno - + def insert(self,scope): self.sub_scopes.append(scope) @@ -137,13 +137,13 @@ def get_functions(self,name,quiet=False): else: fns += self.get_functions(cname,quiet) return fns - + def find_class(self,name,scope): if ':' in name: if name in self.index: return name else: - return None + return None tmp = scope.abs_name.split(':') name1 = ":".join(tmp[:-1] + [name]) if name1 in self.index: @@ -289,11 +289,11 @@ def flatten(x): '__attribute__' : 'ATTRIBUTE', '__cdecl__' : 'CDECL', '__typeof' : 'uTYPEOF', - 'typeof' : 'TYPEOF', + 'typeof' : 'TYPEOF', 'CXXTEST_STD' : 'CXXTEST_STD' } - + tokens = [ "CharacterLiteral", "FloatingLiteral", @@ -402,17 +402,17 @@ def t_newline(t): # # The %prec resolves the 14.2-3 ambiguity: # Identifier '<' is forced to go through the is-it-a-template-name test -# All names absorb TEMPLATE with the name, so that no template_test is -# performed for them. This requires all potential declarations within an -# expression to perpetuate this policy and thereby guarantee the ultimate +# All names absorb TEMPLATE with the name, so that no template_test is +# performed for them. This requires all potential declarations within an +# expression to perpetuate this policy and thereby guarantee the ultimate # coverage of explicit_instantiation. # -# The %prec also resolves a conflict in identifier : which is forced to be a -# shift of a label for a labeled-statement rather than a reduction for the -# name of a bit-field or generalised constructor. This is pretty dubious -# syntactically but correct for all semantic possibilities. The shift is -# only activated when the ambiguity exists at the start of a statement. -# In this context a bit-field declaration or constructor definition are not +# The %prec also resolves a conflict in identifier : which is forced to be a +# shift of a label for a labeled-statement rather than a reduction for the +# name of a bit-field or generalised constructor. This is pretty dubious +# syntactically but correct for all semantic possibilities. The shift is +# only activated when the ambiguity exists at the start of a statement. +# In this context a bit-field declaration or constructor definition are not # allowed. # @@ -469,10 +469,10 @@ def p_scoped_id(p): p[0] = "".join(data) # -# destructor_id has to be held back to avoid a conflict with a one's -# complement as per 5.3.1-9, It gets put back only when scoped or in a +# destructor_id has to be held back to avoid a conflict with a one's +# complement as per 5.3.1-9, It gets put back only when scoped or in a # declarator_id, which is only used as an explicit member name. -# Declarations of an unscoped destructor are always parsed as a one's +# Declarations of an unscoped destructor are always parsed as a one's # complement. # def p_destructor_id(p): @@ -526,10 +526,10 @@ def p_declarator_id(p): p[0]=p[1] # -# The standard defines pseudo-destructors in terms of type-name, which is -# class/enum/typedef, of which class-name is covered by a normal destructor. -# pseudo-destructors are supposed to support ~int() in templates, so the -# grammar here covers built-in names. Other names are covered by the lack +# The standard defines pseudo-destructors in terms of type-name, which is +# class/enum/typedef, of which class-name is covered by a normal destructor. +# pseudo-destructors are supposed to support ~int() in templates, so the +# grammar here covers built-in names. Other names are covered by the lack # of identifier/type discrimination. # def p_built_in_type_id(p): @@ -584,39 +584,39 @@ def p_translation_unit(p): # A.4 Expressions #------------------------------------------------------------------------------- # -# primary_expression covers an arbitrary sequence of all names with the -# exception of an unscoped destructor, which is parsed as its unary expression -# which is the correct disambiguation (when ambiguous). This eliminates the -# traditional A(B) meaning A B ambiguity, since we never have to tack an A -# onto the front of something that might start with (. The name length got -# maximised ab initio. The downside is that semantic interpretation must split +# primary_expression covers an arbitrary sequence of all names with the +# exception of an unscoped destructor, which is parsed as its unary expression +# which is the correct disambiguation (when ambiguous). This eliminates the +# traditional A(B) meaning A B ambiguity, since we never have to tack an A +# onto the front of something that might start with (. The name length got +# maximised ab initio. The downside is that semantic interpretation must split # the names up again. # -# Unification of the declaration and expression syntax means that unary and +# Unification of the declaration and expression syntax means that unary and # binary pointer declarator operators: # int * * name -# are parsed as binary and unary arithmetic operators (int) * (*name). Since +# are parsed as binary and unary arithmetic operators (int) * (*name). Since # type information is not used # ambiguities resulting from a cast # (cast)*(value) -# are resolved to favour the binary rather than the cast unary to ease AST -# clean-up. The cast-call ambiguity must be resolved to the cast to ensure +# are resolved to favour the binary rather than the cast unary to ease AST +# clean-up. The cast-call ambiguity must be resolved to the cast to ensure # that (a)(b)c can be parsed. # # The problem of the functional cast ambiguity # name(arg) -# as call or declaration is avoided by maximising the name within the parsing -# kernel. So primary_id_expression picks up +# as call or declaration is avoided by maximising the name within the parsing +# kernel. So primary_id_expression picks up # extern long int const var = 5; -# as an assignment to the syntax parsed as "extern long int const var". The -# presence of two names is parsed so that "extern long into const" is -# distinguished from "var" considerably simplifying subsequent +# as an assignment to the syntax parsed as "extern long int const var". The +# presence of two names is parsed so that "extern long into const" is +# distinguished from "var" considerably simplifying subsequent # semantic resolution. # -# The generalised name is a concatenation of potential type-names (scoped -# identifiers or built-in sequences) plus optionally one of the special names -# such as an operator-function-id, conversion-function-id or destructor as the -# final name. +# The generalised name is a concatenation of potential type-names (scoped +# identifiers or built-in sequences) plus optionally one of the special names +# such as an operator-function-id, conversion-function-id or destructor as the +# final name. # def get_rest(p): @@ -648,7 +648,7 @@ def p_postfix_expression(p): | postfix_expression '.' declarator_id | postfix_expression '.' scoped_pseudo_destructor_id | postfix_expression ARROW declarator_id - | postfix_expression ARROW scoped_pseudo_destructor_id + | postfix_expression ARROW scoped_pseudo_destructor_id | postfix_expression INC | postfix_expression DEC | DYNAMIC_CAST '<' nonlgt_seq_opt '>' '(' expression ')' @@ -755,8 +755,8 @@ def p_new_initializer_opt(p): pass # -# cast-expression is generalised to support a [] as well as a () prefix. This covers the omission of -# DELETE[] which when followed by a parenthesised expression was ambiguous. It also covers the gcc +# cast-expression is generalised to support a [] as well as a () prefix. This covers the omission of +# DELETE[] which when followed by a parenthesised expression was ambiguous. It also covers the gcc # indexed array initialisation for free. # def p_cast_expression(p): @@ -848,7 +848,7 @@ def p_conditional_expression(p): # -# assignment-expression is generalised to cover the simple assignment of a braced initializer in order to +# assignment-expression is generalised to cover the simple assignment of a braced initializer in order to # contribute to the coverage of parameter-declaration and init-declaration. # # | logical_or_expression assignment_operator assignment_expression @@ -861,7 +861,7 @@ def p_assignment_expression(p): p[0]=get_rest(p) def p_assignment_operator(p): - '''assignment_operator : '=' + '''assignment_operator : '=' | ASS_ADD | ASS_AND | ASS_DIV @@ -990,7 +990,7 @@ def p_declaration_statement(p): # A.6 Declarations #--------------------------------------------------------------------------------------------------- def p_compound_declaration(p): - '''compound_declaration : LBRACE declaration_seq_opt RBRACE + '''compound_declaration : LBRACE declaration_seq_opt RBRACE ''' pass @@ -1052,7 +1052,7 @@ def p_simple_declaration(p): # # A decl-specifier following a ptr_operator provokes a shift-reduce conflict for * const name which is resolved in favour of the pointer, and implemented by providing versions of decl-specifier guaranteed not to start with a cv_qualifier. decl-specifiers are implemented type-centrically. That is the semantic constraint that there must be a type is exploited to impose structure, but actually eliminate very little syntax. built-in types are multi-name and so need a different policy. # -# non-type decl-specifiers are bound to the left-most type in a decl-specifier-seq, by parsing from the right and attaching suffixes to the right-hand type. Finally residual prefixes attach to the left. +# non-type decl-specifiers are bound to the left-most type in a decl-specifier-seq, by parsing from the right and attaching suffixes to the right-hand type. Finally residual prefixes attach to the left. # def p_suffix_built_in_decl_specifier_raw(p): '''suffix_built_in_decl_specifier_raw : built_in_type_specifier @@ -1070,8 +1070,8 @@ def p_suffix_built_in_decl_specifier(p): # | id_scope_seq # | SCOPE id_scope_seq def p_suffix_named_decl_specifier(p): - '''suffix_named_decl_specifier : scoped_id - | elaborate_type_specifier + '''suffix_named_decl_specifier : scoped_id + | elaborate_type_specifier | suffix_named_decl_specifier decl_specifier_suffix ''' p[0]=get_rest(p) @@ -1135,8 +1135,8 @@ def p_decl_specifier_prefix(p): pass def p_storage_class_specifier(p): - '''storage_class_specifier : REGISTER - | STATIC + '''storage_class_specifier : REGISTER + | STATIC | MUTABLE | EXTERN %prec SHIFT_THERE | EXTENSION @@ -1190,16 +1190,16 @@ def p_attribute(p): ''' def p_Xbuilt_in_type_specifier(p): - '''Xbuilt_in_type_specifier : CHAR - | WCHAR_T - | BOOL - | SHORT - | INT - | LONG - | SIGNED - | UNSIGNED - | FLOAT - | DOUBLE + '''Xbuilt_in_type_specifier : CHAR + | WCHAR_T + | BOOL + | SHORT + | INT + | LONG + | SIGNED + | UNSIGNED + | FLOAT + | DOUBLE | VOID | uTYPEOF parameters_clause | TYPEOF parameters_clause @@ -1383,7 +1383,7 @@ def p_cv_qualifier_seq_opt(p): # TODO: verify that we should include attributes here def p_cv_qualifier(p): - '''cv_qualifier : CONST + '''cv_qualifier : CONST | VOLATILE | attributes ''' @@ -1516,7 +1516,7 @@ def p_function_block(p): pass def p_function_body(p): - '''function_body : LBRACE nonbrace_seq_opt RBRACE + '''function_body : LBRACE nonbrace_seq_opt RBRACE ''' p[0] = ['{','}'] @@ -1549,8 +1549,8 @@ def p_initializer_list(p): # The two usages are too distant to try to create and enforce a common prefix so we have to resort to # a parser hack by backtracking. Inheritance is much the most likely so we mark the input stream context # and try to parse a base-clause. If we successfully reach a { the base-clause is ok and inheritance was -# the correct choice so we unmark and continue. If we fail to find the { an error token causes -# back-tracking to the alternative parse in elaborated_type_specifier which regenerates the : and +# the correct choice so we unmark and continue. If we fail to find the { an error token causes +# back-tracking to the alternative parse in elaborated_type_specifier which regenerates the : and # declares unconditional success. # @@ -1572,11 +1572,11 @@ def p_class_specifier_head(p): else: scope = "" _parse_info.push_scope(scope,p[1],base_classes) - + def p_class_key(p): - '''class_key : CLASS - | STRUCT + '''class_key : CLASS + | STRUCT | UNION ''' p[0] = p[1] @@ -1680,8 +1680,8 @@ def p_base_specifier(p): p[0] = p[2] def p_access_specifier(p): - '''access_specifier : PRIVATE - | PROTECTED + '''access_specifier : PRIVATE + | PROTECTED | PUBLIC ''' pass @@ -2087,7 +2087,7 @@ def p_error(p): tmp = "Syntax error at end of file." else: tmp = "Syntax error at token " - if p.type is "": + if p.type == "": tmp = tmp + "''" else: tmp = tmp + str(p.type) @@ -2184,7 +2184,7 @@ def parse_cpp(data=None, filename=None, debug=0, optimize=0, verbose=False, func if __name__ == '__main__': #pragma: no cover # # This MAIN routine parses a sequence of files provided at the command - # line. If '-v' is included, then a verbose parsing output is + # line. If '-v' is included, then a verbose parsing output is # generated. # for arg in sys.argv[1:]: @@ -2197,8 +2197,8 @@ def parse_cpp(data=None, filename=None, debug=0, optimize=0, verbose=False, func parse_cpp(filename=arg,verbose=2) # # Print the _parse_info object summary for this file. - # This illustrates how class inheritance can be used to + # This illustrates how class inheritance can be used to # deduce class members. - # + # print(str(_parse_info)) diff --git a/contrib/cxxtest/python/python3/cxxtest/cxxtest_fog.py b/contrib/cxxtest/python/python3/cxxtest/cxxtest_fog.py index 45dc9406d..42dde295e 100644 --- a/contrib/cxxtest/python/python3/cxxtest/cxxtest_fog.py +++ b/contrib/cxxtest/python/python3/cxxtest/cxxtest_fog.py @@ -36,7 +36,7 @@ def scanInputFiles(files, _options): print(" error.") print(str(err)) continue - print("done.") + print("done.") sys.stdout.flush() # # WEH: see if it really makes sense to use parse information to @@ -55,7 +55,7 @@ def scanInputFiles(files, _options): fullname = key[2:] else: fullname = key - suite = { + suite = { 'fullname' : fullname, 'name' : name, 'file' : file, diff --git a/contrib/cxxtest/python/python3/cxxtest/cxxtest_parser.py b/contrib/cxxtest/python/python3/cxxtest/cxxtest_parser.py index a4313a611..2488e90c1 100644 --- a/contrib/cxxtest/python/python3/cxxtest/cxxtest_parser.py +++ b/contrib/cxxtest/python/python3/cxxtest/cxxtest_parser.py @@ -36,7 +36,7 @@ def scanInputFiles(files, _options): # for file in files: scanInputFile(file) - if len(suites) is 0 and not options.root: + if len(suites) == 0 and not options.root: abort( 'No tests defined' ) return [options,suites] @@ -73,7 +73,7 @@ def scanInputFile(fileName): prev = "" if contNo: scanInputLine( fileName, lineNo - contNo, prev + line ) - + closeSuite() file.close() @@ -193,7 +193,7 @@ def addLineToBlock( suite, lineNo, line ): '''Append the line to the current CXXTEST_CODE() block''' line = fixBlockLine( suite, lineNo, line ) line = re.sub( r'^.*\{\{', '', line ) - + e = re.search( r'\}\}', line ) if e: line = line[:e.start()] @@ -233,7 +233,7 @@ def closeSuite(): '''Close current suite and add it to the list if valid''' global suite if suite is not None: - if len(suite['tests']) is not 0: + if len(suite['tests']) != 0: verifySuite(suite) rememberSuite(suite) suite = None diff --git a/contrib/cxxtest/python/python3/cxxtest/cxxtestgen.py b/contrib/cxxtest/python/python3/cxxtest/cxxtestgen.py index 8a5b84c41..28c34a895 100644 --- a/contrib/cxxtest/python/python3/cxxtest/cxxtestgen.py +++ b/contrib/cxxtest/python/python3/cxxtest/cxxtestgen.py @@ -196,7 +196,7 @@ def parseCommandline(args): if options.error_printer: options.runner= "ErrorPrinter" options.haveStandardLibrary = True - + if options.noStaticInit and (options.root or options.part): abort( '--no-static-init cannot be used with --root/--part' ) @@ -386,7 +386,7 @@ def writeInclude(output, file): global lastIncluded if options.outputFileName: dirname = os.path.split(options.outputFileName)[0] - tfile = relpath(file, dirname) + tfile = relpath(file, dirname) if os.path.exists(tfile): if tfile == lastIncluded: return output.writelines( [ '#include "', tfile, '"\n\n' ] ) @@ -446,7 +446,7 @@ def writeTestDescription( output, suite, test ): output.write( 'static class %s : public CxxTest::RealTestDescription {\n' % test['class'] ) else: output.write( 'class %s : public CxxTest::RealTestDescription {\n' % test['class'] ) - # + # output.write( 'public:\n' ) if not options.noStaticInit: output.write( ' %s() : CxxTest::RealTestDescription( %s, %s, %s, "%s" ) {}\n' % @@ -461,7 +461,7 @@ def writeTestDescription( output, suite, test ): (test['class'], suite['fullname'], suite['object'], suite['object'], suite['object']) ) output.write( ' %s& %s;\n' % (suite['fullname'], suite['object']) ) output.write( ' void runTest() { %s }\n' % runBody( suite, test ) ) - # + # if not options.noStaticInit: output.write( '} %s;\n\n' % test['object'] ) else: @@ -475,11 +475,11 @@ def runBody( suite, test ): def dynamicRun( suite, test ): '''Body of TestDescription::run() for test in a dynamic suite''' return 'if ( ' + suite['object'] + ' ) ' + suite['object'] + '->' + test['name'] + '();' - + def staticRun( suite, test ): '''Body of TestDescription::run() for test in a non-dynamic suite''' return suite['object'] + '.' + test['name'] + '();' - + def writeSuiteDescription( output, suite ): '''Write SuiteDescription object''' if isDynamic( suite ): diff --git a/contrib/cxxtest/sample/.cvsignore b/contrib/cxxtest/sample/.cvsignore new file mode 100644 index 000000000..badbdfa91 --- /dev/null +++ b/contrib/cxxtest/sample/.cvsignore @@ -0,0 +1,5 @@ +.consign +Makefile +*_runner* +tests.cpp error_printer.cpp stdio_printer.cpp file_printer.cpp aborter.cpp only.cpp +error_printer stdio_printer file_printer aborter only diff --git a/contrib/cxxtest/sample/Makefile.bcc32 b/contrib/cxxtest/sample/Makefile.bcc32 index 6471e99e1..ff35ac8bb 100644 --- a/contrib/cxxtest/sample/Makefile.bcc32 +++ b/contrib/cxxtest/sample/Makefile.bcc32 @@ -21,8 +21,8 @@ CXXC = bcc32.exe -w- -I. -I.. all: $(TARGETS) clean: - del *~ *.o *.obj - del $(TARGETS) + del *~ *.o *.obj + del $(TARGETS) del $(GUI_TARGETS) del tests.cpp error_printer.cpp stdio_printer.cpp file_printer.cpp aborter.cpp only.cpp del win32_runner.cpp qt_runner.cpp diff --git a/contrib/cxxtest/sample/Makefile.msvc b/contrib/cxxtest/sample/Makefile.msvc index 2374f8028..ca447d1ca 100644 --- a/contrib/cxxtest/sample/Makefile.msvc +++ b/contrib/cxxtest/sample/Makefile.msvc @@ -20,8 +20,8 @@ CXXC = cl.exe -GX -W3 -WX -I. -I.. all: $(TARGETS) clean: - del *~ *.o *.obj - del $(TARGETS) + del *~ *.o *.obj + del $(TARGETS) del $(GUI_TARGETS) del tests.cpp error_printer.cpp stdio_printer.cpp file_printer.cpp aborter.cpp only.cpp del win32_runner.cpp qt_runner.cpp diff --git a/contrib/cxxtest/sample/SCons/SConstruct b/contrib/cxxtest/sample/SCons/SConstruct index cb394084f..433d0570c 100644 --- a/contrib/cxxtest/sample/SCons/SConstruct +++ b/contrib/cxxtest/sample/SCons/SConstruct @@ -2,34 +2,34 @@ cxxtestbuilder_path = '../../build_tools/SCons/cxxtest.py' cxxtest_path = '../..' -# First a bit of python magic to make the CxxTestBuilder available +# First a bit of python magic to make the CxxTestBuilder available # without having to copy it into a particular path. -# for nicer examples you *should* use, see the cxxtest builder tests in the +# for nicer examples you *should* use, see the cxxtest builder tests in the # build_tools/SCons/test directory. import imp cxxtest = imp.load_source('cxxtest', cxxtestbuilder_path) -# First build the 'real' library, when working on an embedded system +# First build the 'real' library, when working on an embedded system # this may involve a cross compiler. env = Environment() env.BuildDir('build/embedded_platform', 'src') env.Append(CPPPATH=['include']) -libtested = env.StaticLibrary('build/embedded_platform/tested', +libtested = env.StaticLibrary('build/embedded_platform/tested', env.Glob('build/embedded_platform/*.c')) # Now create a seperate build environment for the tests so we can keep any # options that are specific to testing seperate from the 'production' build # environment. For simplicity I am just copying the production environment. -# If we are cross compiling for the "real" library, then this +# If we are cross compiling for the "real" library, then this # environement might be using the normal compiler. env_test = env.Clone() # Add the CxxTestBuilder to our testing build environment. cxxtest.generate(env_test, CXXTEST_INSTALL_DIR = cxxtest_path) -# If we were working with an embedded platform we may want to create a -# seperate version of our library that runs on our development box in -# order to do our initial unit testing. This version may also include +# If we were working with an embedded platform we may want to create a +# seperate version of our library that runs on our development box in +# order to do our initial unit testing. This version may also include # any special preprocessor defines needed for testing e.g. -DTESTING env_test.BuildDir('build/dev_platform', 'src') env_test.BuildDir('build/tests', 'tests') diff --git a/contrib/cxxtest/sample/SCons/tests/stack_test.h b/contrib/cxxtest/sample/SCons/tests/stack_test.h index 24fd6b521..714e0b24f 100644 --- a/contrib/cxxtest/sample/SCons/tests/stack_test.h +++ b/contrib/cxxtest/sample/SCons/tests/stack_test.h @@ -6,7 +6,7 @@ class stack_test : public CxxTest::TestSuite { - + private: stack_t* stack; public: @@ -31,11 +31,11 @@ class stack_test : public CxxTest::TestSuite stack_push(stack, 1); TS_ASSERT_EQUALS(1, stack_size(stack)); } - + void test_push_pop_doesnt_change_size() { stack_push(stack, 1); (void)stack_pop(stack); - TS_ASSERT_EQUALS(0, stack_size(stack)); + TS_ASSERT_EQUALS(0, stack_size(stack)); } void test_peak_after_push() { diff --git a/contrib/cxxtest/sample/msvc/CxxTest_1_Run.dsp b/contrib/cxxtest/sample/msvc/CxxTest_1_Run.dsp index 9ab9114d5..8b621865e 100644 --- a/contrib/cxxtest/sample/msvc/CxxTest_1_Run.dsp +++ b/contrib/cxxtest/sample/msvc/CxxTest_1_Run.dsp @@ -7,19 +7,19 @@ CFG=CxxTest_1_Run - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "CxxTest_1_Run.mak". -!MESSAGE +!MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "CxxTest_1_Run.mak" CFG="CxxTest_1_Run - Win32 Debug" -!MESSAGE +!MESSAGE !MESSAGE Possible choices for configuration are: -!MESSAGE +!MESSAGE !MESSAGE "CxxTest_1_Run - Win32 Release" (based on "Win32 (x86) External Target") !MESSAGE "CxxTest_1_Run - Win32 Debug" (based on "Win32 (x86) External Target") -!MESSAGE +!MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 @@ -68,7 +68,7 @@ CFG=CxxTest_1_Run - Win32 Debug # PROP Bsc_Name "" # PROP Target_Dir "" -!ENDIF +!ENDIF # Begin Target @@ -79,7 +79,7 @@ CFG=CxxTest_1_Run - Win32 Debug !ELSEIF "$(CFG)" == "CxxTest_1_Run - Win32 Debug" -!ENDIF +!ENDIF # Begin Source File diff --git a/contrib/cxxtest/sample/msvc/CxxTest_2_Build.dsp b/contrib/cxxtest/sample/msvc/CxxTest_2_Build.dsp index 301320d84..a642745ef 100644 --- a/contrib/cxxtest/sample/msvc/CxxTest_2_Build.dsp +++ b/contrib/cxxtest/sample/msvc/CxxTest_2_Build.dsp @@ -7,19 +7,19 @@ CFG=CxxTest_2_Build - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "CxxTest_2_Build.mak". -!MESSAGE +!MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "CxxTest_2_Build.mak" CFG="CxxTest_2_Build - Win32 Debug" -!MESSAGE +!MESSAGE !MESSAGE Possible choices for configuration are: -!MESSAGE +!MESSAGE !MESSAGE "CxxTest_2_Build - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "CxxTest_2_Build - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE +!MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 @@ -76,7 +76,7 @@ LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"Debug/runner.exe" /pdbtype:sept -!ENDIF +!ENDIF # Begin Target diff --git a/contrib/cxxtest/sample/msvc/CxxTest_3_Generate.dsp b/contrib/cxxtest/sample/msvc/CxxTest_3_Generate.dsp index 1dd6d4dc5..300b53215 100644 --- a/contrib/cxxtest/sample/msvc/CxxTest_3_Generate.dsp +++ b/contrib/cxxtest/sample/msvc/CxxTest_3_Generate.dsp @@ -7,19 +7,19 @@ CFG=CxxTest_3_Generate - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "CxxTest_3_Generate.mak". -!MESSAGE +!MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "CxxTest_3_Generate.mak" CFG="CxxTest_3_Generate - Win32 Debug" -!MESSAGE +!MESSAGE !MESSAGE Possible choices for configuration are: -!MESSAGE +!MESSAGE !MESSAGE "CxxTest_3_Generate - Win32 Release" (based on "Win32 (x86) External Target") !MESSAGE "CxxTest_3_Generate - Win32 Debug" (based on "Win32 (x86) External Target") -!MESSAGE +!MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 @@ -68,7 +68,7 @@ CFG=CxxTest_3_Generate - Win32 Debug # PROP Bsc_Name "" # PROP Target_Dir "" -!ENDIF +!ENDIF # Begin Target @@ -79,7 +79,7 @@ CFG=CxxTest_3_Generate - Win32 Debug !ELSEIF "$(CFG)" == "CxxTest_3_Generate - Win32 Debug" -!ENDIF +!ENDIF # Begin Source File diff --git a/contrib/cxxtest/sample/msvc/FixFiles.bat b/contrib/cxxtest/sample/msvc/FixFiles.bat index 785a01526..c82710d38 100644 --- a/contrib/cxxtest/sample/msvc/FixFiles.bat +++ b/contrib/cxxtest/sample/msvc/FixFiles.bat @@ -101,7 +101,7 @@ run: $(DIR)\runner.exe $(DIR)\runner.exe $(RUNNER_FLAGS) '; -$CxxTest_2_Build = +$CxxTest_2_Build = '# Microsoft Developer Studio Project File - Name="CxxTest_2_Build" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** @@ -111,19 +111,19 @@ $CxxTest_2_Build = CFG=CxxTest_2_Build - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "CxxTest_2_Build.mak". -!MESSAGE +!MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "CxxTest_2_Build.mak" CFG="CxxTest_2_Build - Win32 Debug" -!MESSAGE +!MESSAGE !MESSAGE Possible choices for configuration are: -!MESSAGE +!MESSAGE !MESSAGE "CxxTest_2_Build - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "CxxTest_2_Build - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE +!MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 @@ -180,7 +180,7 @@ LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"Debug/runner.exe" /pdbtype:sept -!ENDIF +!ENDIF # Begin Target diff --git a/contrib/cxxtest/sample/only.tpl b/contrib/cxxtest/sample/only.tpl index b2a7277cf..337ecc50e 100644 --- a/contrib/cxxtest/sample/only.tpl +++ b/contrib/cxxtest/sample/only.tpl @@ -23,7 +23,7 @@ int main( int argc, char *argv[] ) fprintf( stderr, "Cannot find class %s\n", argv[1] ); return 2; } - + return CxxTest::StdioPrinter().run(); } diff --git a/contrib/cxxtest/sample/parts/.cvsignore b/contrib/cxxtest/sample/parts/.cvsignore new file mode 100644 index 000000000..6e091710d --- /dev/null +++ b/contrib/cxxtest/sample/parts/.cvsignore @@ -0,0 +1 @@ +*.cpp *.o runner \ No newline at end of file diff --git a/contrib/cxxtest/test/.cvsignore b/contrib/cxxtest/test/.cvsignore new file mode 100644 index 000000000..e56da81ff --- /dev/null +++ b/contrib/cxxtest/test/.cvsignore @@ -0,0 +1 @@ +*pl.cpp *py.cpp *pl.out *py.out *px *px.exe *px.out *build.log *root.cpp diff --git a/contrib/cxxtest/test/CharAssertions.h b/contrib/cxxtest/test/CharAssertions.h new file mode 100644 index 000000000..6bb8ebf05 --- /dev/null +++ b/contrib/cxxtest/test/CharAssertions.h @@ -0,0 +1,112 @@ +#include + +// +// A test for issue 122/123, where TS_ASSERT_EQUALS and TS_ASSERT_DIFFERS were +// both true at the same time. +// + +// not const on purpose +static char non_const_value_1[] = { "toto" }; +static char non_const_value_2[] = { "toto" }; // different pointers from value1 +static char non_const_value_3[] = { "nekobus" }; +class CharAssertions : public CxxTest::TestSuite { + public: + template void differs_must_succeed_generator() + { + T1 str1 = non_const_value_1; + T2 str2 = non_const_value_3; + TS_ASSERT_DIFFERS(str1, str2); + } + template void differs_must_fail_generator() + { + T1 str1 = non_const_value_1; + T2 str2 = non_const_value_2; + TS_ASSERT_DIFFERS(str1, str2); + } + template void equals_must_succeed_generator() + { + T1 str1 = non_const_value_1; + T2 str2 = non_const_value_2; + TS_ASSERT_EQUALS(str1, str2); + } + template void equals_must_fail_generator() + { + T1 str1 = non_const_value_1; + T2 str2 = non_const_value_3; + TS_ASSERT_EQUALS(str1, str2); + } + + // we must test the entire matrix + // naming scheme is test_[de][sf][cm][cm], where: + // - d or e are for 'differs' and 'equals' + // - s or f are for 'expect to succeed' or 'expect to fail' + // - c or m are for 'const' or 'mutable' chars. + void test_dscc() + { + differs_must_succeed_generator(); + } + void test_dscm() + { + differs_must_succeed_generator(); + } + void test_dsmc() + { + differs_must_succeed_generator(); + } + void test_dsmm() + { + differs_must_succeed_generator(); + } + + void test_dfcc() + { + differs_must_fail_generator(); + } + void test_dfcm() + { + differs_must_fail_generator(); + } + void test_dfmc() + { + differs_must_fail_generator(); + } + void test_dfmm() + { + differs_must_fail_generator(); + } + + + void test_escc() + { + equals_must_succeed_generator(); + } + void test_escm() + { + equals_must_succeed_generator(); + } + void test_esmc() + { + equals_must_succeed_generator(); + } + void test_esmm() + { + equals_must_succeed_generator(); + } + + void test_efcc() + { + equals_must_fail_generator(); + } + void test_efcm() + { + equals_must_fail_generator(); + } + void test_efmc() + { + equals_must_fail_generator(); + } + void test_efmm() + { + equals_must_fail_generator(); + } +}; diff --git a/contrib/cxxtest/test/NullPtrGuards.h b/contrib/cxxtest/test/NullPtrGuards.h new file mode 100644 index 000000000..11a8be93d --- /dev/null +++ b/contrib/cxxtest/test/NullPtrGuards.h @@ -0,0 +1,19 @@ +#include + +static char const* const file = "filename"; +static int line = 1; +// +// A test for issue #115: Defensive guards in ErrorFormatter to deal with +// (char*) nullptr being passed as an error message. +class NullPtrFormatterTest : public CxxTest::TestSuite { + + public: + void testTsAssert() + { + CxxTest::doFailAssert(file, line, (char const*)NULL, (char const*)NULL); + } + void testTsFail() { CxxTest::doFailTest(file, line, (char const*)NULL); } + void testTsWarn() { CxxTest::doWarn(file, line, (char const*)NULL); } + void testTsSkip() { CxxTest::doSkipTest(file, line, (char const*)NULL); } + void testTsTrace() { CxxTest::doTrace(file, line, (char const*)NULL); } +}; diff --git a/contrib/cxxtest/test/char_assertions.out b/contrib/cxxtest/test/char_assertions.out new file mode 100644 index 000000000..098ee78c5 --- /dev/null +++ b/contrib/cxxtest/test/char_assertions.out @@ -0,0 +1,21 @@ +Running cxxtest tests (16 tests).... +In CharAssertions::test_dfcc: +CharAssertions.h:24: Error: Expected (str1 != str2), found (toto) +In CharAssertions::test_dfcm: +CharAssertions.h:24: Error: Expected (str1 != str2), found (toto) +In CharAssertions::test_dfmc: +CharAssertions.h:24: Error: Expected (str1 != str2), found (toto) +In CharAssertions::test_dfmm: +CharAssertions.h:24: Error: Expected (str1 != str2), found (toto) +.... +In CharAssertions::test_efcc: +CharAssertions.h:36: Error: Expected (str1 == str2), found (toto != nekobus) +In CharAssertions::test_efcm: +CharAssertions.h:36: Error: Expected (str1 == str2), found (toto != nekobus) +In CharAssertions::test_efmc: +CharAssertions.h:36: Error: Expected (str1 == str2), found (toto != nekobus) +In CharAssertions::test_efmm: +CharAssertions.h:36: Error: Expected (str1 == str2), found (toto != nekobus) +Failed 8 and Skipped 0 of 16 tests +Success rate: 50% +Error level = 8 diff --git a/contrib/cxxtest/test/fake/.cvsignore b/contrib/cxxtest/test/fake/.cvsignore new file mode 100644 index 000000000..782a42d26 --- /dev/null +++ b/contrib/cxxtest/test/fake/.cvsignore @@ -0,0 +1 @@ +*.cpp *_runner* \ No newline at end of file diff --git a/contrib/cxxtest/test/fake/X11/Xlib.h b/contrib/cxxtest/test/fake/X11/Xlib.h index 05eddd10e..caca12f42 100644 --- a/contrib/cxxtest/test/fake/X11/Xlib.h +++ b/contrib/cxxtest/test/fake/X11/Xlib.h @@ -24,7 +24,7 @@ inline int XFreeFontInfo( char **, XFontStruct *, int ) { return 0; } inline int XSelectInput( Display *, Window, int ) { return 0; } inline int XMapWindow( Display *, Window ) { return 0; } inline Screen *XDefaultScreenOfDisplay( Display * ) { return 0; } -inline int WidthOfScreen( Screen * ) { return 0; } +inline int WidthOfScreen( Screen * ) { return 0; } inline int HeightOfScreen( Screen * ) { return 0; } inline int XMoveResizeWindow( Display *, Window, int, int, int, int ) { return 0; } diff --git a/contrib/cxxtest/test/nullptr_guards.out b/contrib/cxxtest/test/nullptr_guards.out new file mode 100644 index 000000000..38a844716 --- /dev/null +++ b/contrib/cxxtest/test/nullptr_guards.out @@ -0,0 +1,17 @@ +Running cxxtest tests (5 tests) +In NullPtrFormatterTest::testTsAssert: +filename:1: Error: Assertion failed: +In NullPtrFormatterTest::testTsFail: +filename:1: Error: Test failed: +In NullPtrFormatterTest::testTsWarn: +filename:1: Warning: +. +In NullPtrFormatterTest::testTsSkip: +filename:1: Warning: Test skipped: +s +In NullPtrFormatterTest::testTsTrace: +filename:1: Trace: +. +Failed 2 and Skipped 1 of 5 tests +Success rate: 50% +Error level=2 diff --git a/contrib/cxxtest/test/preamble.tpl b/contrib/cxxtest/test/preamble.tpl index a15356b4d..0e60d9b3e 100644 --- a/contrib/cxxtest/test/preamble.tpl +++ b/contrib/cxxtest/test/preamble.tpl @@ -19,7 +19,7 @@ int main() TS_FAIL( "This will not be displayed" ); int result = runner.run() + runner.run(); TS_FAIL( "This will not be displayed" ); - + return result; } diff --git a/contrib/cxxtest/test/test_cxxtest.py b/contrib/cxxtest/test/test_cxxtest.py index 63593ae63..d9e654aa6 100644 --- a/contrib/cxxtest/test/test_cxxtest.py +++ b/contrib/cxxtest/test/test_cxxtest.py @@ -1,11 +1,11 @@ -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------ # CxxTest: A lightweight C++ unit testing library. # Copyright (c) 2008 Sandia Corporation. # This software is distributed under the LGPL License v3 # For more information, see the COPYING file in the top CxxTest directory. # Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, # the U.S. Government retains certain rights in this software. -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------ import shutil import time @@ -16,35 +16,34 @@ import difflib import subprocess import re -import string -if sys.version_info < (2,7): +if sys.version_info < (2, 7): import unittest2 as unittest else: import unittest try: import ply - ply_available=True + ply_available = True except: - ply_available=False + ply_available = False try: import cxxtest - cxxtest_available=True + cxxtest_available = True import cxxtest.cxxtestgen except: - cxxtest_available=False + cxxtest_available = False -currdir = os.path.dirname(os.path.abspath(__file__))+os.sep -sampledir = os.path.dirname(os.path.dirname(currdir))+'/sample'+os.sep -cxxtestdir = os.path.dirname(os.path.dirname(currdir))+os.sep +currdir = os.path.dirname(os.path.abspath(__file__)) + os.sep +sampledir = os.path.dirname(os.path.dirname(currdir)) + '/sample' + os.sep +cxxtestdir = os.path.dirname(os.path.dirname(currdir)) + os.sep compilerre = re.compile("^(?P[^:]+)(?P:.*)$") -dirre = re.compile("^([^%s]*/)*" % re.escape(os.sep)) -xmlre = re.compile("\"(?P[^\"]*/[^\"]*)\"") -datere = re.compile("date=\"[^\"]*\"") +dirre = re.compile("^([^%s]*/)*" % re.escape(os.sep)) +xmlre = re.compile("\"(?P[^\"]*/[^\"]*)\"") +datere = re.compile("date=\"[^\"]*\"") # Headers from the cxxtest/sample directory -samples = ' '.join(file for file in sorted(glob.glob(sampledir+'*.h'))) -guiInputs=currdir+'../sample/gui/GreenYellowRed.h' +samples = ' '.join(file for file in sorted(glob.glob(sampledir + '*.h'))) +guiInputs = currdir + '../sample/gui/GreenYellowRed.h' if sys.platform.startswith('win'): target_suffix = '.exe' command_separator = ' && ' @@ -54,8 +53,9 @@ target_suffix = '' command_separator = '; ' remove_extra_path_prefixes_on_windows = False - -def find(filename, executable=False, isfile=True, validate=None): + + +def find(filename, executable=False, isfile=True, validate=None): # # Use the PATH environment if it is defined and not empty # @@ -65,47 +65,54 @@ def find(filename, executable=False, isfile=True, validate=None): search_path = os.defpath.split(os.pathsep) for path in search_path: test_fname = os.path.join(path, filename) - if os.path.exists(test_fname) \ - and (not isfile or os.path.isfile(test_fname)) \ - and (not executable or os.access(test_fname, os.X_OK)): + if ( + os.path.exists(test_fname) + and (not isfile or os.path.isfile(test_fname)) + and (not executable or os.access(test_fname, os.X_OK)) + ): return os.path.abspath(test_fname) return None + def join_commands(command_one, command_two): return command_separator.join([command_one, command_two]) _available = {} + + def available(compiler, exe_option): - if (compiler,exe_option) in _available: - return _available[compiler,exe_option] + if (compiler, exe_option) in _available: + return _available[compiler, exe_option] cmd = join_commands("cd %s" % currdir, - "%s %s %s %s > %s 2>&1" % (compiler, exe_option, currdir+'anything', currdir+'anything.cpp', currdir+'anything.log')) - print("Testing for compiler "+compiler) - print("Command: "+cmd) + "%s %s %s %s > %s 2>&1" % (compiler, exe_option, currdir + 'anything', currdir + 'anything.cpp', currdir + 'anything.log')) + print("Testing for compiler " + compiler) + print("Command: " + cmd) status = subprocess.call(cmd, shell=True) - executable = currdir+'anything'+target_suffix + executable = currdir + 'anything' + target_suffix flag = status == 0 and os.path.exists(executable) - os.remove(currdir+'anything.log') + os.remove(currdir + 'anything.log') if os.path.exists(executable): os.remove(executable) - print("Status: "+str(flag)) - _available[compiler,exe_option] = flag + print("Status: " + str(flag)) + _available[compiler, exe_option] = flag return flag + def remove_absdir(filename): - INPUT=open(filename, 'r') + INPUT = open(filename, 'r') lines = [line.strip() for line in INPUT] INPUT.close() - OUTPUT=open(filename, 'w') + OUTPUT = open(filename, 'w') for line in lines: # remove basedir at front of line - match = compilerre.match(line) # see if we can remove the basedir + match = compilerre.match(line) # see if we can remove the basedir if match: parts = match.groupdict() line = dirre.sub("", parts['path']) + parts['rest'] - OUTPUT.write(line+'\n') + OUTPUT.write(line + '\n') OUTPUT.close() + def normalize_line_for_diff(line): # add spaces around {}<>() line = re.sub("[{}<>()]", r" \0 ", line) @@ -130,72 +137,78 @@ def normalize_line_for_diff(line): line = ''.join(line.split(os.path.normcase(cxxtestdir))) line = ''.join(line.split(os.path.normpath(cxxtestdir))) # And some extra relative paths left behind - line= re.sub(r'^.*[\\/]([^\\/]+\.(h|cpp))', r'\1', line) + line = re.sub(r'^.*[\\/]([^\\/]+\.(h|cpp))', r'\1', line) - # for xml, remove prefixes from everything that looks like a + # for xml, remove prefixes from everything that looks like a # file path inside "" line = xmlre.sub( - lambda match: '"'+re.sub("^[^/]+/", "", match.group(1))+'"', - line - ) + lambda match: '"' + re.sub("^[^/]+/", "", match.group(1)) + '"', + line) # Remove date info - line = datere.sub( lambda match: 'date=""', line) + line = datere.sub(lambda match: 'date=""', line) return line + def make_diff_readable(diff): i = 0 - while i+1 < len(diff): - if diff[i][0] == '-' and diff[i+1][0] == '+': + while i + 1 < len(diff): + if diff[i][0] == '-' and diff[i + 1][0] == '+': l1 = diff[i] - l2 = diff[i+1] + l2 = diff[i + 1] for j in range(1, min([len(l1), len(l2)])): if l1[j] != l2[j]: if j > 4: - j = j-2; + j = j - 2 l1 = l1[j:] l2 = l2[j:] diff[i] = '-(...)' + l1 - diff[i+1] = '+(...)' + l2 + diff[i + 1] = '+(...)' + l2 break - i+=1 + i += 1 + def file_diff(filename1, filename2, filtered_reader): remove_absdir(filename1) remove_absdir(filename2) # - INPUT=open(filename1, 'r') + INPUT = open(filename1, 'r') lines1 = list(filtered_reader(INPUT)) INPUT.close() # - INPUT=open(filename2, 'r') + INPUT = open(filename2, 'r') lines2 = list(filtered_reader(INPUT)) INPUT.close() # - diff = list(difflib.unified_diff(lines2, lines1, - fromfile=filename2, tofile=filename1)) + diff = list( + difflib.unified_diff( + lines2, lines1, + fromfile=filename2, tofile=filename1)) if diff: make_diff_readable(diff) - raise Exception("ERROR: \n\n%s\n\n%s\n\n" % (lines1, lines2)) + raise Exception("ERROR: \n\n%s\n\n%s\n\n%s\n\n" % + ('\n'.join(lines1), + '\n'.join(lines2), + '\n'.join(diff))) diff = '\n'.join(diff) return diff class BaseTestCase(object): - fog='' - valgrind='' - cxxtest_import=False + fog = '' + valgrind = '' + cxxtest_import = False def setUp(self): - sys.stderr.write("("+self.__class__.__name__+") ") - self.passed=False - self.prefix='' - self.py_out='' - self.py_cpp='' - self.px_pre='' - self.px_out='' - self.build_log='' - self.build_target='' + sys.stderr.write("(" + self.__class__.__name__ + ") ") + self.passed = False + self.prefix = '' + self.py_out = '' + self.py_cpp = '' + self.px_pre = '' + self.px_out = '' + self.build_log = '' + self.build_target = '' def tearDown(self): if not self.passed: @@ -203,7 +216,7 @@ def tearDown(self): files = [] if os.path.exists(self.py_out): files.append(self.py_out) - if os.path.exists(self.py_cpp) and not 'CXXTEST_GCOV_FLAGS' in os.environ: + if os.path.exists(self.py_cpp) and 'CXXTEST_GCOV_FLAGS' not in os.environ: files.append(self.py_cpp) if os.path.exists(self.px_pre): files.append(self.px_pre) @@ -211,7 +224,7 @@ def tearDown(self): files.append(self.px_out) if os.path.exists(self.build_log): files.append(self.build_log) - if os.path.exists(self.build_target) and not 'CXXTEST_GCOV_FLAGS' in os.environ: + if os.path.exists(self.build_target) and 'CXXTEST_GCOV_FLAGS' not in os.environ: files.append(self.build_target) for file in files: try: @@ -221,18 +234,16 @@ def tearDown(self): try: os.remove(file) except: - print( "Error removing file '%s'" % file) - + print("Error removing file '%s'" % file) # This is a "generator" that just reads a file and normalizes the lines def file_filter(self, file): for line in file: yield normalize_line_for_diff(line) - def check_if_supported(self, filename, msg): - target=currdir+'check'+'px'+target_suffix - log=currdir+'check'+'_build.log' + target = currdir + 'check' + 'px' + target_suffix + log = currdir + 'check' + '_build.log' cmd = join_commands("cd %s" % currdir, "%s %s %s %s. %s%s../ %s > %s 2>&1" % (self.compiler, self.exe_option, target, self.include_option, self.include_option, currdir, filename, log)) status = subprocess.call(cmd, shell=True) @@ -243,39 +254,41 @@ def check_if_supported(self, filename, msg): def init(self, prefix): # - self.prefix = self.__class__.__name__+'_'+prefix - self.py_out = currdir+self.prefix+'_py.out' - self.py_cpp = currdir+self.prefix+'_py.cpp' - self.px_pre = currdir+self.prefix+'_px.pre' - self.px_out = currdir+self.prefix+'_px.out' - self.build_log = currdir+self.prefix+'_build.log' - self.build_target = currdir+self.prefix+'px'+target_suffix + self.prefix = self.__class__.__name__ + '_' + prefix + self.py_out = currdir + self.prefix + '_py.out' + self.py_cpp = currdir + self.prefix + '_py.cpp' + self.px_pre = currdir + self.prefix + '_px.pre' + self.px_out = currdir + self.prefix + '_px.out' + self.build_log = currdir + self.prefix + '_build.log' + self.build_target = currdir + self.prefix + 'px' + target_suffix def check_root(self, prefix='', output=None): self.init(prefix) args = "--have-eh --abort-on-fail --root --error-printer" if self.cxxtest_import: os.chdir(currdir) - cxxtest.cxxtestgen.main(['cxxtestgen', self.fog, '-o', self.py_cpp]+re.split('[ ]+',args), True) + cxxtest.cxxtestgen.main(['cxxtestgen', self.fog, '-o', self.py_cpp] + re.split('[ ]+', args), True) else: - cmd = join_commands("cd %s" % currdir, - "%s %s../bin/cxxtestgen %s -o %s %s > %s 2>&1" % (sys.executable, currdir, self.fog, self.py_cpp, args, self.py_out)) + cmd = join_commands( + "cd %s" % currdir, + "%s %s../bin/cxxtestgen %s -o %s %s > %s 2>&1" % (sys.executable, currdir, self.fog, self.py_cpp, args, self.py_out)) status = subprocess.call(cmd, shell=True) - self.assertEqual(status, 0, 'Bad return code: %d Error executing cxxtestgen: %s' % (status,cmd)) + self.assertEqual(status, 0, 'Bad return code: %d Error executing cxxtestgen: %s' % (status, cmd)) # files = [self.py_cpp] - for i in [1,2]: + for i in [1, 2]: args = "--have-eh --abort-on-fail --part Part%s.h" % str(i) - file = currdir+self.prefix+'_py%s.cpp' % str(i) + file = currdir + self.prefix + '_py%s.cpp' % str(i) files.append(file) if self.cxxtest_import: os.chdir(currdir) - cxxtest.cxxtestgen.main(['cxxtestgen', self.fog, '-o', file]+re.split('[ ]+',args), True) + cxxtest.cxxtestgen.main(['cxxtestgen', self.fog, '-o', file] + re.split('[ ]+', args), True) else: - cmd = join_commands("cd %s" % currdir, - "%s %s../bin/cxxtestgen %s -o %s %s > %s 2>&1" % (sys.executable, currdir, self.fog, file, args, self.py_out)) + cmd = join_commands( + "cd %s" % currdir, + "%s %s../bin/cxxtestgen %s -o %s %s > %s 2>&1" % (sys.executable, currdir, self.fog, file, args, self.py_out)) status = subprocess.call(cmd, shell=True) - self.assertEqual(status, 0, 'Bad return code: %d Error executing cxxtestgen: %s' % (status,cmd)) + self.assertEqual(status, 0, 'Bad return code: %d Error executing cxxtestgen: %s' % (status, cmd)) # cmd = join_commands("cd %s" % currdir, "%s %s %s %s. %s%s../ %s > %s 2>&1" % (self.compiler, self.exe_option, self.build_target, self.include_option, self.include_option, currdir, ' '.join(files), self.build_log)) @@ -283,21 +296,21 @@ def check_root(self, prefix='', output=None): for file in files: if os.path.exists(file): os.remove(file) - self.assertEqual(status, 0, 'Bad return code: %d Error executing command: %s' % (status,cmd)) + self.assertEqual(status, 0, 'Bad return code: %d Error executing command: %s' % (status, cmd)) # cmd = join_commands("cd %s" % currdir, "%s %s -v > %s 2>&1" % (self.valgrind, self.build_target, self.px_pre)) status = subprocess.call(cmd, shell=True) - OUTPUT = open(self.px_pre,'a') - OUTPUT.write('Error level = '+str(status)+'\n') + OUTPUT = open(self.px_pre, 'a') + OUTPUT.write('Error level = ' + str(status) + '\n') OUTPUT.close() - diffstr = file_diff(self.px_pre, currdir+output, self.file_filter) + diffstr = file_diff(self.px_pre, currdir + output, self.file_filter) if not diffstr == '': - self.fail("Unexpected differences in output:\n"+diffstr) + self.fail("Unexpected differences in output:\n" + diffstr) if self.valgrind != '': self.parse_valgrind(self.px_pre) # - self.passed=True + self.passed = True def compile(self, prefix='', args=None, compile='', output=None, main=None, failGen=False, run=None, logfile=None, failBuild=False, init=True): """Run cxxtestgen and compile the code that is generated""" @@ -307,23 +320,24 @@ def compile(self, prefix='', args=None, compile='', output=None, main=None, fail if self.cxxtest_import: try: os.chdir(currdir) - status = cxxtest.cxxtestgen.main(['cxxtestgen', self.fog, '-o', self.py_cpp]+re.split('[ ]+',args), True) + status = cxxtest.cxxtestgen.main(['cxxtestgen', self.fog, '-o', self.py_cpp] + re.split('[ ]+', args), True) except: status = 1 else: - cmd = join_commands("cd %s" % currdir, - "%s %s../bin/cxxtestgen %s -o %s %s > %s 2>&1" % (sys.executable, currdir, self.fog, self.py_cpp, args, self.py_out)) + cmd = join_commands( + "cd %s" % currdir, + "%s %s../bin/cxxtestgen %s -o %s %s > %s 2>&1" % (sys.executable, currdir, self.fog, self.py_cpp, args, self.py_out)) status = subprocess.call(cmd, shell=True) if failGen: if status == 0: self.fail('Expected cxxtestgen to fail.') else: - self.passed=True + self.passed = True return if not self.cxxtest_import: - self.assertEqual(status, 0, 'Bad return code: %d Error executing command: %s' % (status,cmd)) + self.assertEqual(status, 0, 'Bad return code: %d Error executing command: %s' % (status, cmd)) # - if not main is None: + if main is not None: # Compile with main cmd = join_commands("cd %s" % currdir, "%s %s %s %s. %s%s../ %s main.cpp %s > %s 2>&1" % (self.compiler, self.exe_option, self.build_target, self.include_option, self.include_option, currdir, compile, self.py_cpp, self.build_log)) @@ -336,36 +350,36 @@ def compile(self, prefix='', args=None, compile='', output=None, main=None, fail if status == 0: self.fail('Expected compiler to fail.') else: - self.passed=True + self.passed = True return else: - self.assertEqual(status, 0, 'Bad return code: %d Error executing command: %s' % (status,cmd)) + self.assertEqual(status, 0, 'Bad return code: %d Error executing command: %s' % (status, cmd)) # - if compile == '' and not output is None: + if compile == '' and output is not None: if run is None: cmd = join_commands("cd %s" % currdir, "%s %s -v > %s 2>&1" % (self.valgrind, self.build_target, self.px_pre)) else: cmd = run % (self.valgrind, self.build_target, self.px_pre) status = subprocess.call(cmd, shell=True) - OUTPUT = open(self.px_pre,'a') - OUTPUT.write('Error level = '+str(status)+'\n') + OUTPUT = open(self.px_pre, 'a') + OUTPUT.write('Error level = ' + str(status) + '\n') OUTPUT.close() if logfile is None: - diffstr = file_diff(self.px_pre, currdir+output, self.file_filter) + diffstr = file_diff(self.px_pre, currdir + output, self.file_filter) else: - diffstr = file_diff(currdir+logfile, currdir+output, self.file_filter) + diffstr = file_diff(currdir + logfile, currdir + output, self.file_filter) if not diffstr == '': - self.fail("Unexpected differences in output:\n"+diffstr) + self.fail("Unexpected differences in output:\n" + diffstr) if self.valgrind != '': self.parse_valgrind(self.px_pre) - if not logfile is None: - os.remove(currdir+logfile) + if logfile is not None: + os.remove(currdir + logfile) # if compile == '' and output is None and os.path.exists(self.py_cpp): self.fail("Output cpp file %s should not have been generated." % self.py_cpp) # - self.passed=True + self.passed = True # # Tests for cxxtestgen @@ -377,7 +391,7 @@ def test_root_or_part(self): def test_root_plus_part(self): """Root + Part""" - self.compile(prefix='root_plus_part', args="--error-printer --root --part "+samples, output="error.out") + self.compile(prefix='root_plus_part', args="--error-printer --root --part " + samples, output="error.out") def test_wildcard(self): """Wildcard input""" @@ -385,29 +399,29 @@ def test_wildcard(self): def test_stdio_printer(self): """Stdio printer""" - self.compile(prefix='stdio_printer', args="--runner=StdioPrinter "+samples, output="error.out") + self.compile(prefix='stdio_printer', args="--runner=StdioPrinter " + samples, output="error.out") def test_paren_printer(self): """Paren printer""" - self.compile(prefix='paren_printer', args="--runner=ParenPrinter "+samples, output="paren.out") + self.compile(prefix='paren_printer', args="--runner=ParenPrinter " + samples, output="paren.out") def test_yn_runner(self): """Yes/No runner""" - self.compile(prefix='yn_runner', args="--runner=YesNoRunner "+samples, output="runner.out") + self.compile(prefix='yn_runner', args="--runner=YesNoRunner " + samples, output="runner.out") def test_no_static_init(self): """No static init""" - self.compile(prefix='no_static_init', args="--error-printer --no-static-init "+samples, output="error.out") + self.compile(prefix='no_static_init', args="--error-printer --no-static-init " + samples, output="error.out") def test_samples_file(self): """Samples file""" # Create a file with the list of sample files - OUTPUT = open(currdir+'Samples.txt','w') - for line in sorted(glob.glob(sampledir+'*.h')): - OUTPUT.write(line+'\n') + OUTPUT = open(currdir + 'Samples.txt', 'w') + for line in sorted(glob.glob(sampledir + '*.h')): + OUTPUT.write(line + '\n') OUTPUT.close() self.compile(prefix='samples_file', args="--error-printer --headers Samples.txt", output="error.out") - os.remove(currdir+'Samples.txt') + os.remove(currdir + 'Samples.txt') def test_have_std(self): """Have Std""" @@ -431,17 +445,23 @@ def test_include(self): """Include""" self.compile(prefix='include', args="--include=VoidTraits.h --include=LongTraits.h --error-printer IncludeTest.h", output="include.out") + def test_nullptr_guards(self): + """Nullptr Messages""" + self.compile(prefix='nullptr_guards', + args="--error-printer NullPtrGuards.h --have-eh", + output="nullptr_guards.out") + # # Template file tests # def test_preamble(self): """Preamble""" - self.compile(prefix='preamble', args="--template=preamble.tpl "+samples, output="preamble.out") + self.compile(prefix='preamble', args="--template=preamble.tpl " + samples, output="preamble.out") def test_activate_all(self): """Activate all""" - self.compile(prefix='activate_all', args="--template=activate.tpl "+samples, output="error.out") + self.compile(prefix='activate_all', args="--template=activate.tpl " + samples, output="error.out") def test_only_suite(self): """Only Suite""" @@ -457,7 +477,7 @@ def test_have_std_tpl(self): def test_exceptions_tpl(self): """Exceptions - Template""" - self.compile(prefix='exceptions_tpl', args="--template=HaveEH.tpl "+self.ehNormals, output="eh_normals.out") + self.compile(prefix='exceptions_tpl', args="--template=HaveEH.tpl " + self.ehNormals, output="eh_normals.out") # # Test cases which do not require exception handling @@ -475,32 +495,38 @@ def test_max_dump_size(self): """Max dump size""" self.compile(prefix='max_dump_size', args="--error-printer --include=MaxDump.h DynamicMax.h SameData.h", output='max.out') + def test_char_assertions(self): + """char* assertions""" + self.compile(prefix='char_assertions', + args='--error-printer CharAssertions.h', + output='char_assertions.out') + def test_wide_char(self): """Wide char""" self.check_if_supported('wchar.cpp', "The file wchar.cpp is not supported.") self.compile(prefix='wide_char', args="--error-printer WideCharTest.h", output="wchar.out") - #def test_factor(self): - #"""Factor""" - #self.compile(prefix='factor', args="--error-printer --factor Factor.h", output="factor.out") + # def test_factor(self): + # """Factor""" + # self.compile(prefix='factor', args="--error-printer --factor Factor.h", output="factor.out") def test_user_traits(self): """User traits""" self.compile(prefix='user_traits', args="--template=UserTraits.tpl UserTraits.h", output='user.out') - normals = " ".join(currdir+file for file in ["LessThanEquals.h","Relation.h","DefaultTraits.h","DoubleCall.h","SameData.h","SameFiles.h","Tsm.h","TraitsTest.h","MockTest.h","SameZero.h"]) + normals = " ".join(currdir + file for file in ["LessThanEquals.h", "Relation.h", "DefaultTraits.h", "DoubleCall.h", "SameData.h", "SameFiles.h", "Tsm.h", "TraitsTest.h", "MockTest.h", "SameZero.h"]) def test_normal_behavior_xunit(self): """Normal Behavior with XUnit Output""" - self.compile(prefix='normal_behavior_xunit', args="--xunit-printer "+self.normals, logfile='TEST-cxxtest.xml', output="normal.xml") + self.compile(prefix='normal_behavior_xunit', args="--xunit-printer " + self.normals, logfile='TEST-cxxtest.xml', output="normal.xml") def test_normal_behavior(self): """Normal Behavior""" - self.compile(prefix='normal_behavior', args="--error-printer "+self.normals, output="normal.out") + self.compile(prefix='normal_behavior', args="--error-printer " + self.normals, output="normal.out") def test_normal_plus_abort(self): """Normal + Abort""" - self.compile(prefix='normal_plus_abort', args="--error-printer --have-eh --abort-on-fail "+self.normals, output="abort.out") + self.compile(prefix='normal_plus_abort', args="--error-printer --have-eh --abort-on-fail " + self.normals, output="abort.out") def test_stl_traits(self): """STL Traits""" @@ -509,7 +535,7 @@ def test_stl_traits(self): def test_normal_behavior_world(self): """Normal Behavior with World""" - self.compile(prefix='normal_behavior_world', args="--error-printer --world=myworld "+self.normals, output="world.out") + self.compile(prefix='normal_behavior_world', args="--error-printer --world=myworld " + self.normals, output="world.out") # # Test cases which do require exception handling @@ -522,7 +548,7 @@ def test_throw_wo_std(self): def test_exceptions(self): """Exceptions""" - self.compile(prefix='exceptions', args="--error-printer --have-eh "+self.ehNormals, output="eh_normals.out") + self.compile(prefix='exceptions', args="--error-printer --have-eh " + self.ehNormals, output="eh_normals.out") def test_exceptions_plus_abort(self): """Exceptions plus abort""" @@ -530,11 +556,11 @@ def test_exceptions_plus_abort(self): def test_default_abort(self): """Default abort""" - self.compile(prefix='default_abort', args="--error-printer --include=DefaultAbort.h "+self.ehNormals+ " DeepAbort.h ThrowsAssert.h", output="default_abort.out") + self.compile(prefix='default_abort', args="--error-printer --include=DefaultAbort.h " + self.ehNormals + " DeepAbort.h ThrowsAssert.h", output="default_abort.out") def test_default_no_abort(self): """Default no abort""" - self.compile(prefix='default_no_abort', args="--error-printer "+self.ehNormals+" DeepAbort.h ThrowsAssert.h", output="default_abort.out") + self.compile(prefix='default_no_abort', args="--error-printer " + self.ehNormals + " DeepAbort.h ThrowsAssert.h", output="default_abort.out") # # Global Fixtures @@ -590,7 +616,7 @@ def test_gf_suw_fails_XML(self): def test_gui(self): """GUI""" - self.compile(prefix='gui', args='--gui=DummyGui %s' % guiInputs, output ="gui.out") + self.compile(prefix='gui', args='--gui=DummyGui %s' % guiInputs, output="gui.out") def test_gui_runner(self): """GUI + runner""" @@ -606,14 +632,13 @@ def test_win32_gui(self): def test_win32_unicode(self): """Win32 Unicode""" - self.compile(prefix='win32_unicode', args="--gui=Win32Gui GoodSuite.h", compile=self.w32Flags+' -DUNICODE') + self.compile(prefix='win32_unicode', args="--gui=Win32Gui GoodSuite.h", compile=self.w32Flags + ' -DUNICODE') def test_x11_gui(self): """X11 GUI""" self.check_if_supported('wchar.cpp', "Cannot compile wchar.cpp") self.compile(prefix='x11_gui', args="--gui=X11Gui GoodSuite.h", compile=self.x11Flags) - # # Tests for when the compiler doesn't support exceptions # @@ -644,7 +669,7 @@ def test_missing_input(self): def test_missing_template(self): """Missing template""" - self.compile(prefix='missing_template', args='--template=NoSuchFile.h '+samples, failGen=True) + self.compile(prefix='missing_template', args='--template=NoSuchFile.h ' + samples, failGen=True) def test_inheritance(self): """Test relying on inheritance""" @@ -710,27 +735,40 @@ def test_bad1(self): def test_normal_sympath(self): """Normal Behavior - symbolic path""" - _files = " ".join(["LessThanEquals.h","Relation.h","DefaultTraits.h","DoubleCall.h","SameData.h","SameFiles.h","Tsm.h","TraitsTest.h","MockTest.h","SameZero.h"]) + files = ["LessThanEquals.h", "Relation.h", "DefaultTraits.h", + "DoubleCall.h", "SameData.h", "SameFiles.h", "Tsm.h", + "TraitsTest.h", "MockTest.h", "SameZero.h"] + + sympath_name = 'test_sympath' + sympath_dir = '../%s' % (sympath_name,) prefix = 'normal_sympath' + + _files = " ".join(files) self.init(prefix=prefix) - try: - os.remove('test_sympath') - except: - pass - try: - shutil.rmtree('../test_sympath') - except: - pass - os.mkdir('../test_sympath') - os.symlink('../test_sympath', 'test_sympath') - self.py_cpp = 'test_sympath/'+prefix+'_py.cpp' - self.compile(prefix=prefix, init=False, args="--error-printer "+_files, output="normal.out") - os.remove('test_sympath') - shutil.rmtree('../test_sympath') + # need to ignore very specific errors here + if os.path.islink(sympath_name): + os.remove(sympath_name) + if os.path.isdir(sympath_dir): + shutil.rmtree(sympath_dir) + if not os.path.exists('../.git'): + raise ValueError("Wrong local directory, run from the tests folder.") + os.mkdir(sympath_dir) + os.symlink(sympath_dir, sympath_name) + self.py_cpp = 'test_sympath/%s_py.cpp' % (prefix,) + self.compile(prefix=prefix, + init=False, + args="--error-printer " + _files, + output="normal.out") + os.remove(sympath_name) + shutil.rmtree(sympath_dir) + def test_normal_relpath(self): """Normal Behavior - relative path""" - _files = " ".join(["LessThanEquals.h","Relation.h","DefaultTraits.h","DoubleCall.h","SameData.h","SameFiles.h","Tsm.h","TraitsTest.h","MockTest.h","SameZero.h"]) + files = ["LessThanEquals.h", "Relation.h", "DefaultTraits.h", + "DoubleCall.h", "SameData.h", "SameFiles.h", "Tsm.h", + "TraitsTest.h", "MockTest.h", "SameZero.h"] + _files = " ".join(files) prefix = 'normal_relative' self.init(prefix=prefix) try: @@ -738,22 +776,24 @@ def test_normal_relpath(self): except: pass os.mkdir('../test_relpath') - self.py_cpp = '../test_relpath/'+prefix+'_py.cpp' - self.compile(prefix=prefix, init=False, args="--error-printer "+_files, output="normal.out") + self.py_cpp = '../test_relpath/' + prefix + '_py.cpp' + self.compile(prefix=prefix, + init=False, + args="--error-printer " + _files, + output="normal.out") shutil.rmtree('../test_relpath') - class TestCpp(BaseTestCase, unittest.TestCase): # Compiler specifics exe_option = '-o' include_option = '-I' - compiler='c++ -Wall -W -Werror -g' + compiler = 'c++ -Wall -W -Werror -g' no_eh_option = None - qtFlags='-Ifake' - x11Flags='-Ifake' - w32Flags='-Ifake' + qtFlags = '-Ifake' + x11Flags = '-Ifake' + w32Flags = '-Ifake' def run(self, *args, **kwds): if available('c++', '-o'): @@ -768,7 +808,7 @@ def tearDown(self): class TestCppFOG(TestCpp): - fog='-f' + fog = '-f' def run(self, *args, **kwds): if ply_available: @@ -780,11 +820,11 @@ class TestGpp(BaseTestCase, unittest.TestCase): # Compiler specifics exe_option = '-o' include_option = '-I' - compiler='g++ -g -ansi -pedantic -Wmissing-declarations -Werror -Wall -W -Wshadow -Woverloaded-virtual -Wnon-virtual-dtor -Wreorder -Wsign-promo %s' % os.environ.get('CXXTEST_GCOV_FLAGS','') + compiler = 'g++ -g -ansi -pedantic -Wmissing-declarations -Werror -Wall -W -Wshadow -Woverloaded-virtual -Wnon-virtual-dtor -Wreorder -Wsign-promo %s' % os.environ.get('CXXTEST_GCOV_FLAGS', '') no_eh_option = '-fno-exceptions' - qtFlags='-Ifake' - x11Flags='-Ifake' - w32Flags='-Ifake' + qtFlags = '-Ifake' + x11Flags = '-Ifake' + w32Flags = '-Ifake' def run(self, *args, **kwds): if available('g++', '-o'): @@ -809,7 +849,7 @@ def run(self, *args, **kwds): class TestGppFOG(TestGpp): - fog='-f' + fog = '-f' def run(self, *args, **kwds): if ply_available: @@ -828,7 +868,7 @@ def run(self, *args, **kwds): class TestGppValgrind(TestGpp): - valgrind='valgrind --tool=memcheck --leak-check=yes' + valgrind = 'valgrind --tool=memcheck --leak-check=yes' def file_filter(self, file): for line in file: @@ -857,21 +897,20 @@ def parse_valgrind(self, fname): for line in INPUT: if not line.startswith('=='): continue - tokens = re.split('[ \t]+', line) + tokens = re.split('[ \t]+ ', line) if len(tokens) < 4: continue if tokens[1] == 'definitely' and tokens[2] == 'lost:': if eval(tokens[3]) > min_leak: - self.fail("Valgrind Error: "+ ' '.join(tokens[1:])) + self.fail("Valgrind Error: " + ' '.join(tokens[1:])) if tokens[1] == 'possibly' and tokens[2] == 'lost:': if eval(tokens[3]) > min_leak: - self.fail("Valgrind Error: "+ ' '.join(tokens[1:])) - + self.fail("Valgrind Error: " + ' '.join(tokens[1:])) class TestGppFOGValgrind(TestGppValgrind): - fog='-f' + fog = '-f' def run(self, *args, **kwds): if ply_available: @@ -883,11 +922,11 @@ class TestClang(BaseTestCase, unittest.TestCase): # Compiler specifics exe_option = '-o' include_option = '-I' - compiler='clang++ -v -g -Wall -W -Wshadow -Woverloaded-virtual -Wnon-virtual-dtor -Wreorder -Wsign-promo' + compiler = 'clang++ -v -g -Wall -W -Wshadow -Woverloaded-virtual -Wnon-virtual-dtor -Wreorder -Wsign-promo' no_eh_option = '-fno-exceptions' - qtFlags='-Ifake' - x11Flags='-Ifake' - w32Flags='-Ifake' + qtFlags = '-Ifake' + x11Flags = '-Ifake' + w32Flags = '-Ifake' def run(self, *args, **kwds): if available('clang++', '-o'): @@ -902,7 +941,7 @@ def tearDown(self): class TestClangFOG(TestClang): - fog='-f' + fog = '-f' def run(self, *args, **kwds): if ply_available: @@ -914,11 +953,11 @@ class TestCL(BaseTestCase, unittest.TestCase): # Compiler specifics exe_option = '-o' include_option = '-I' - compiler='cl -nologo -GX -W4'# -WX' + compiler = 'cl -nologo -GX -W4' # -WX' no_eh_option = '-GX-' - qtFlags='-Ifake' - x11Flags='-Ifake' - w32Flags='-Ifake' + qtFlags = '-Ifake' + x11Flags = '-Ifake' + w32Flags = '-Ifake' def run(self, *args, **kwds): if available('cl', '-o'): @@ -933,7 +972,7 @@ def tearDown(self): class TestCLFOG(TestCL): - fog='-f' + fog = '-f' def run(self, *args, **kwds): if ply_available: