~russel/groovynativelauncher/trunk

« back to all changes in this revision

Viewing changes to tests/nativelauncherTest.py

  • Committer: akaranta
  • Date: 2010-04-16 12:30:01 UTC
  • Revision ID: svn-v4:a5544e8c-8a19-0410-ba12-f9af4593a198:trunk/groovy/modules/native_launcher:19870
added a python func to modify the swig generated c file so that not having debug version of python on windows does not stop the build. This functionality is not yet installed in the build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
        # launchermodule = __import__( 'nativelauncher' )
15
15
        self.assertEqual( 0, nativelauncher.cvar._jst_debug )
16
16
        
 
17
# FIXME move these to a separate test class. 
 
18
 
 
19
    def testModifyingSwigFileToBeMSVCDebugCompliant( self ) :
 
20
        import tempfile
 
21
        # create a temporary file with the appropriate #include
 
22
        sampleFile = tempfile.TemporaryFile( 'w+' )
 
23
        try :
 
24
            sampleFile.writelines( [ "\n",
 
25
                                     "/* Python.h has to appear first */\n", 
 
26
                                     "#include <Python.h>\n",
 
27
                                     "bar\n",
 
28
                                     "\n"] )
 
29
            
 
30
            sampleFile.flush()
 
31
            sampleFile.seek( 0 )
 
32
 
 
33
            supportModule.surroundPythonHIncludeWithGuards( sampleFile )
 
34
            
 
35
            # check that the said import in said file is now ok
 
36
            sampleFile.seek( 0 )
 
37
            lines = sampleFile.readlines()
 
38
            
 
39
            expectedLines = [
 
40
                "\n",
 
41
                "/* Python.h has to appear first */\n", 
 
42
                "#if defined( _DEBUG )\n",
 
43
                "#  define _DEBUG_WAS_DEFINED\n",
 
44
                "#  undef _DEBUG\n",
 
45
                "#endif\n",
 
46
                "#include <Python.h>\n",
 
47
                "#if defined( _DEBUG_WAS_DEFINED )\n",
 
48
                "#  define _DEBUG\n",
 
49
                "#endif\n",
 
50
                "bar\n",
 
51
                "\n"
 
52
            ]
 
53
            
 
54
            self.assertEqual( expectedLines, lines )
 
55
            
 
56
            # call func to modify the file again
 
57
            supportModule.surroundPythonHIncludeWithGuards( sampleFile )
 
58
            # check there are no further modifications
 
59
            sampleFile.seek( 0 )
 
60
            linesNow = sampleFile.readlines()
 
61
            self.assertEqual( lines, linesNow )
 
62
        finally :
 
63
            sampleFile.close()
17
64
 
18
65
#  The entry point for SCons to use.
19
66
 
22
69
 
23
70
if __name__ == '__main__' :
24
71
    print 'Run tests using command "scons test".'
 
72
###    unittest.main()
25
73