Ticket #2488: cxxtest_fix2.patch

File cxxtest_fix2.patch, 11.2 KB (added by leper, 10 years ago)

Different approach.

  • build/premake/premake4.lua

    diff --git a/build/premake/premake4.lua b/build/premake/premake4.lua
    index 1f5951f..c8b9488 100644
    a b function configure_cxxtestgen()  
    13041304    local lcxxtestrootoptions = "--have-std"
    13051305
    13061306    if _OPTIONS["jenkins-tests"] then
    1307         lcxxtestrootoptions = lcxxtestrootoptions .. " --gui=PsTestWrapper --runner=XmlPrinter"
     1307        lcxxtestrootoptions = lcxxtestrootoptions .. " --runner=XmlPrinter"
    13081308    else
    13091309        if os.is("windows") then
    1310             lcxxtestrootoptions = lcxxtestrootoptions .. " --gui=PsTestWrapper --runner=Win32ODSPrinter"
     1310            lcxxtestrootoptions = lcxxtestrootoptions .. " --runner=Win32ODSPrinter"
    13111311        else
    1312             lcxxtestrootoptions = lcxxtestrootoptions .. " --gui=PsTestWrapper --runner=ErrorPrinter"
     1312            lcxxtestrootoptions = lcxxtestrootoptions .. " --runner=ErrorPrinter"
    13131313        end
    13141314    end
    13151315
  • new file libraries/source/cxxtest-4.4/cxxtest/PsExtensions.cpp

    diff --git a/libraries/source/cxxtest-4.4/cxxtest/PsExtensions.cpp b/libraries/source/cxxtest-4.4/cxxtest/PsExtensions.cpp
    new file mode 100644
    index 0000000..e633195
    - +  
     1namespace CxxTest
     2{
     3    bool g_RunDisabled = false;
     4}
  • deleted file libraries/source/cxxtest-4.4/cxxtest/PsTestWrapper.cpp

    diff --git a/libraries/source/cxxtest-4.4/cxxtest/PsTestWrapper.cpp b/libraries/source/cxxtest-4.4/cxxtest/PsTestWrapper.cpp
    deleted file mode 100644
    index 981b475..0000000
    + -  
    1 #include <cxxtest/PsTestWrapper.h>
    2 
    3 namespace CxxTest
    4 {
    5     const char *g_PsArgv0 = NULL;
    6     const char *g_PsOnlySuite = NULL;
    7     const char *g_PsOnlyTest = NULL;
    8     bool g_PsListSuites = false;
    9 }
  • deleted file libraries/source/cxxtest-4.4/cxxtest/PsTestWrapper.h

    diff --git a/libraries/source/cxxtest-4.4/cxxtest/PsTestWrapper.h b/libraries/source/cxxtest-4.4/cxxtest/PsTestWrapper.h
    deleted file mode 100644
    index 59be0c4..0000000
    + -  
    1 #ifndef __cxxtest__PsTestWrapper_h__
    2 #define __cxxtest__PsTestWrapper_h__
    3 
    4 #include <cstdio>
    5 
    6 #include <cxxtest/Gui.h>
    7 // (This is not actually a GUI, but we use the CxxTest GUI mechanism
    8 // to capture argv and do some special processing)
    9 
    10 // We want this to act like Win32Gui on Windows, but like the default
    11 // empty undisplayed GUI elsewhere
    12 #ifdef _WIN32
    13 # define PS_TEST_WRAPPER_BASE Win32Gui
    14 # include <cxxtest/Win32Gui.h>
    15 #else
    16 # define PS_TEST_WRAPPER_BASE GuiListener
    17 #endif
    18 
    19 #include "ps/DllLoader.h"
    20 
    21 namespace CxxTest
    22 {
    23     extern const char *g_PsArgv0;
    24     extern const char *g_PsOnlySuite;
    25     extern const char *g_PsOnlyTest;
    26     extern bool g_PsListSuites;
    27 
    28     class PsTestRunner : public TestRunner
    29     {
    30     public:
    31         static void runAllTests( TestListener &listener )
    32         {
    33             // Code copied from TestRunner:
    34             tracker().setListener( &listener );
    35             _TS_TRY { PsTestRunner().runWorld(); }
    36             _TS_LAST_CATCH( { tracker().failedTest( __FILE__, __LINE__, "Exception thrown from world" ); } );
    37             tracker().setListener( 0 );
    38         }
    39 
    40         void runWorld()
    41         {
    42             RealWorldDescription wd;
    43             WorldGuard sg;
    44 
    45             // Print all the (initially active) test suites, as an
    46             // occasionally handy test-runner-debugging feature
    47             if ( g_PsListSuites )
    48                 for ( SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next() )
    49                     if ( sd->active() )
    50                         printf( "%s\n", sd->suiteName() );
    51 
    52             // Allow all but one suite/test to be disabled
    53             if ( g_PsOnlySuite ) {
    54                 for ( SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next() ) {
    55                     if ( stringsEqual( sd->suiteName(), g_PsOnlySuite ) ) {
    56                         for ( TestDescription *td = sd->firstTest(); td; td = td->next() )
    57                             if ( g_PsOnlyTest && !stringsEqual( td->testName(), g_PsOnlyTest ) )
    58                                 td->setActive( false );
    59                     } else {
    60                         sd->setActive( false );
    61                     }
    62                 }
    63             }
    64             else
    65             {
    66                 // By default, disable all tests with names containing "DISABLED"
    67                 // (they can only be run by explicitly naming the suite/test)
    68                 for ( SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next() ) {
    69                     for ( TestDescription *td = sd->firstTest(); td; td = td->next() )
    70                         if ( strstr( td->testName(), "DISABLED" ) )
    71                             td->setActive( false );
    72                 }
    73             }
    74 
    75             // Code copied from TestRunner:
    76             tracker().enterWorld( wd );
    77             if ( wd.setUp() ) {
    78                 for ( SuiteDescription *sd = wd.firstSuite(); sd; sd = sd->next() )
    79                     if ( sd->active() ) {
    80                         runSuite( *sd );
    81                     }
    82                 wd.tearDown();
    83             }
    84             tracker().leaveWorld( wd );
    85         }
    86     };
    87 
    88     class PsTestWrapper : public PS_TEST_WRAPPER_BASE
    89     {
    90     public:
    91         virtual void runGui( int &argc, char **argv, TestListener &listener )
    92         {
    93             parseCommandLine( argc, argv );
    94             enterGui( argc, argv );
    95             PsTestRunner::runAllTests( listener );
    96             leaveGui();
    97         }
    98     private:
    99         void parseCommandLine( int argc, char **argv )
    100         {
    101             g_PsArgv0 = argv[0];
    102 
    103             for ( int i = 1; i < argc; ++i ) {
    104                 if ( !strcmp( argv[i], "-test" ) && (i + 1 < argc) ) {
    105                     char *test = argv[++i];
    106                     // Try splitting as "suite::test", else use the whole string as the suite name
    107                     char *colons = strstr( test, "::" );
    108                     if ( colons ) {
    109                         colons[0] = '\0'; // (modifying argv is safe enough)
    110                         g_PsOnlySuite = test;
    111                         g_PsOnlyTest = colons + 2;
    112                     } else {
    113                         g_PsOnlySuite = test;
    114                     }
    115                 } else if ( !strcmp( argv[i], "-list" ) ) {
    116                     g_PsListSuites = true;
    117                 } else if ( !strcmp( argv[i], "-libdir" ) ) {
    118                     DllLoader::OverrideLibdir( argv[++i] );
    119                 } else {
    120                     fprintf( stderr, "Unrecognized command line option '%s'\n", argv[i] );
    121                     fprintf( stderr, "Permitted options:\n" );
    122                     fprintf( stderr, "  %s -list\n", argv[0] );
    123                     fprintf( stderr, "  %s -test TestSuiteName\n", argv[0] );
    124                     fprintf( stderr, "  %s -test TestSuiteName::test_case_name\n", argv[0] );
    125                     fprintf( stderr, "  %s -libdir .\n", argv[0] );
    126                     fprintf( stderr, "\n" );
    127                 }
    128             }
    129         }
    130     };
    131 }
    132 
    133 #endif // __cxxtest__PsTestWrapper_h__
  • libraries/source/cxxtest-4.4/cxxtest/RealDescriptions.cpp

    diff --git a/libraries/source/cxxtest-4.4/cxxtest/RealDescriptions.cpp b/libraries/source/cxxtest-4.4/cxxtest/RealDescriptions.cpp
    index 60b4f20..16adad0 100644
    a b unsigned RealWorldDescription::numTotalTests(void) const  
    248248    unsigned count = 0;
    249249    for (const SuiteDescription *sd = firstSuite(); sd != 0; sd = sd->next())
    250250    {
    251         count += sd->numTests();
     251        if (g_RunDisabled)
     252            count += sd->numTests();
     253        else
     254        {
     255            for (const TestDescription *td = sd->firstTest(); td != 0; td = td->next())
     256            {
     257                if (!strstr(td->testName(), "DISABLED"))
     258                    count++;
     259            }
     260        }
    252261    }
    253262    return count;
    254263}
  • libraries/source/cxxtest-4.4/cxxtest/Root.cpp

    diff --git a/libraries/source/cxxtest-4.4/cxxtest/Root.cpp b/libraries/source/cxxtest-4.4/cxxtest/Root.cpp
    index dd6f1eb..809d1fc 100644
    a b  
    2525#include <cxxtest/RealDescriptions.cpp>
    2626#include <cxxtest/TestSuite.cpp>
    2727#include <cxxtest/TestTracker.cpp>
    28 #include <cxxtest/PsTestWrapper.cpp>
     28#include <cxxtest/PsExtensions.cpp>
    2929
    3030#endif // __cxxtest__Root_cpp__
  • libraries/source/cxxtest-4.4/cxxtest/TestMain.h

    diff --git a/libraries/source/cxxtest-4.4/cxxtest/TestMain.h b/libraries/source/cxxtest-4.4/cxxtest/TestMain.h
    index c4d14bb..0666505 100644
    a b  
    3030#   include <cstring>
    3131#endif // _CXXTEST_OLD_STD
    3232
     33#include "ps/DllLoader.h"
     34
    3335namespace CxxTest
    3436{
    3537
    int Main(TesterT& tmp, int argc, char* argv[])  
    8486//
    8587    while ((argc > 1) && (argv[1][0] == '-'))
    8688    {
     89        int args = 1;
    8790        if (CXXTEST_STD(strcmp)(argv[1], "-v") == 0)
    8891        {
    8992            tracker().print_tracing = true;
    9093        }
     94        else if (CXXTEST_STD(strcmp)(argv[1], "-libdir") == 0)
     95        {
     96            if (argc < 2)
     97            {
     98                CXXTEST_STD(cerr) << "ERROR: not enough arguments" << CXXTEST_STD(endl);
     99                return -1;
     100            }
     101            DllLoader::OverrideLibdir(argv[2]);
     102            args = 2;
     103        }
     104        else if (CXXTEST_STD(strcmp)(argv[1], "-disabled") == 0)
     105        {
     106            g_RunDisabled = true;
     107        }
    91108        else
    92109        {
    93110            CXXTEST_STD(cerr) << "ERROR: unknown option '" << argv[1] << "'" << CXXTEST_STD(endl);
    94111            return -1;
    95112        }
    96         for (int i = 1; i < (argc - 1); i++)
     113        for (int i = 1; i < (argc - args); i++)
    97114        {
    98             argv[i] = argv[i + 1];
     115            argv[i] = argv[i + args];
    99116        }
    100         argc--;
     117        argc -= args;
    101118    }
    102119
    103120//
  • libraries/source/cxxtest-4.4/cxxtest/TestRunner.h

    diff --git a/libraries/source/cxxtest-4.4/cxxtest/TestRunner.h b/libraries/source/cxxtest-4.4/cxxtest/TestRunner.h
    index ef914fa..9c10fac 100644
    a b  
    2525
    2626namespace CxxTest
    2727{
     28extern bool g_RunDisabled;
     29
    2830class TestRunner
    2931{
    30     friend class PsTestRunner;
    31 
    3232public:
    3333
    3434    static void setListener(TestListener* listener)
    private:  
    8484        {
    8585            for (TestDescription *td = sd.firstTest(); td; td = td->next())
    8686            {
    87                 if (td->active())
     87                if ((g_RunDisabled || !strstr(td->testName(), "DISABLED")) && td->active())
    8888                {
    8989                    runTest(*td);
    9090                }
  • libraries/source/cxxtest-4.4/cxxtest/TestTracker.h

    diff --git a/libraries/source/cxxtest-4.4/cxxtest/TestTracker.h b/libraries/source/cxxtest-4.4/cxxtest/TestTracker.h
    index b1a1f4f..50e59bc 100644
    a b private:  
    122122    void countSkipped();
    123123
    124124    friend class TestRunner;
    125     friend class PsTestRunner;
    126125
    127126    TestTracker();
    128127    void setListener(TestListener *l);
  • source/lib/sysdep/tests/test_sysdep.h

    diff --git a/source/lib/sysdep/tests/test_sysdep.h b/source/lib/sysdep/tests/test_sysdep.h
    index faad5d0..0ebf6bb 100644
    a b  
    3333# include "mocks/unistd.h"
    3434#endif
    3535
    36 #include <cxxtest/PsTestWrapper.h>
    37 
    3836class TestSysdep : public CxxTest::TestSuite
    3937{
    4038public: