summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-01-09 05:29:53 (GMT)
committerSteven Knight <knight@baldmt.com>2003-01-09 05:29:53 (GMT)
commit270b93aea9b0543094f95bdb22c914e1189c31d1 (patch)
tree37cd2c8844687f1dc33839a3e7f3e7b923fc0ff1 /test
parent61a74e9d5770e83b296356700c128bd3dd59601e (diff)
downloadSCons-270b93aea9b0543094f95bdb22c914e1189c31d1.zip
SCons-270b93aea9b0543094f95bdb22c914e1189c31d1.tar.gz
SCons-270b93aea9b0543094f95bdb22c914e1189c31d1.tar.bz2
Add MinGW support. (Anthony Roach)
Diffstat (limited to 'test')
-rw-r--r--test/mingw.py190
-rw-r--r--test/msvc.py4
2 files changed, 192 insertions, 2 deletions
diff --git a/test/mingw.py b/test/mingw.py
new file mode 100644
index 0000000..5d6e2c1
--- /dev/null
+++ b/test/mingw.py
@@ -0,0 +1,190 @@
+"""
+This tests the MinGW C/C++ compiler support.
+"""
+
+#!/usr/bin/env python
+#
+# Copyright (c) 2001, 2002 Steven Knight
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import TestSCons
+import sys
+import os.path
+import os
+import TestCmd
+import time
+import string
+
+test = TestSCons.TestSCons(match = TestCmd.match_re_dotall)
+
+# MinGW is win32 only:
+if sys.platform != 'win32':
+ test.pass_test()
+
+# This test requires MingW to be installed:
+test.write('SConstruct',"""
+from SCons.Tool.mingw import exists
+import sys
+env = Environment()
+if exists(env):
+ print 'mingw exists'
+sys.exit(0)
+""")
+
+test.run()
+if string.find(test.stdout(), 'mingw exists') == -1:
+ test.no_result()
+
+test.subdir('header')
+
+# Do the actual testing:
+test.write('SConstruct',"""
+env=Environment(tools=['mingw'])
+assert env['CC'] == 'gcc'
+env.StaticLibrary('static', 'static.cpp')
+env.SharedLibrary('shared', 'shared.cpp')
+env.SharedLibrary('cshared', 'cshared.c')
+env.Program('test', ['test.cpp', env.RES('resource.rc', CPPPATH=['header'])], LIBS=['static', 'shared', 'cshared'], LIBPATH=['.'])
+""")
+
+test.write('test.cpp', '''
+#include <stdio.h>
+#include <windows.h>
+#include "resource.h"
+
+void shared_func(void);
+void static_func(void);
+extern "C" void cshared_func(void);
+
+int main(void)
+{
+ printf("%s\\n", "test.cpp");
+ shared_func();
+ static_func();
+ cshared_func();
+
+ char test[1024];
+ LoadString(GetModuleHandle(NULL), IDS_TEST, test, sizeof(test));
+ printf("%d %s\\n", IDS_TEST, test);
+
+ return 0;
+}
+''')
+
+test.write('resource.rc', '''
+#include "resource.h"
+#include <resource2.h>
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_TEST RESOURCE_RC
+END
+''')
+
+test.write('resource.h', '''
+#define IDS_TEST 2001
+''')
+
+test.write('static.cpp', '''
+#include <stdio.h>
+
+void static_func(void)
+{
+ printf("%s\\n", "static.cpp");
+}
+''')
+
+test.write('shared.cpp', '''
+#include <stdio.h>
+
+void shared_func(void)
+{
+ printf("%s\\n", "shared.cpp");
+}
+''')
+
+test.write('cshared.c', '''
+#include <stdio.h>
+
+void cshared_func(void)
+{
+ printf("%s\\n", "cshared.c");
+}
+''')
+
+test.write('header/resource2.h', '''
+#define RESOURCE_RC "resource.rc"
+''')
+
+# the mingw linker likes to print "Creating library file: libfoo.a" to stderr, but
+# we'd like for this test to pass once this bug is fixed, so match anything at all
+# that comes out of stderr:
+test.run(arguments='test.exe', stderr='.*')
+test.run(program=test.workpath('test.exe'), stdout='test.cpp\nshared.cpp\nstatic.cpp\ncshared.c\n2001 resource.rc\n')
+
+# ensure that modifying the header causes the resource to be rebuilt:
+test.write('resource.h', '''
+#define IDS_TEST 2002
+''')
+test.run(arguments='test.exe', stderr='.*')
+test.run(program=test.workpath('test.exe'), stdout='test.cpp\nshared.cpp\nstatic.cpp\ncshared.c\n2002 resource.rc\n')
+
+# Test with specifying the default tool to make sure msvc setting doen't ruin it
+# for mingw:
+test.write('SConstruct',"""
+env=Environment(tools=['default', 'mingw'])
+assert env['CC'] == 'gcc'
+env.SharedLibrary('shared', 'shared.cpp')
+env.Program('test', 'test.cpp', LIBS=['static', 'shared', 'cshared'], LIBPATH=['.'])
+""")
+
+test.write('test.cpp', '''
+#include <stdio.h>
+
+void shared_func(void);
+
+int main(void)
+{
+ printf("%s\\n", "test.cpp2");
+ shared_func();
+ return 0;
+}
+''')
+
+test.write('shared.cpp', '''
+#include <stdio.h>
+
+void shared_func(void)
+{
+ printf("%s\\n", "shared.cpp2");
+}
+''')
+
+# the mingw linker likes to print "Creating library file: libfoo.a" to stderr, but
+# we'd like for this test to pass once this bug is fixed, so match anything at all
+# that comes out of stderr:
+test.run(arguments='test.exe', stderr='.*')
+test.run(program=test.workpath('test.exe'), stdout='test.cpp2\nshared.cpp2\n')
+
+test.pass_test()
diff --git a/test/msvc.py b/test/msvc.py
index 7d771d3..7b274fa 100644
--- a/test/msvc.py
+++ b/test/msvc.py
@@ -215,7 +215,7 @@ env.Program('test', 'test.cpp')
""")
test.run(status=2, stderr='''
-SCons error: The PCHSTOP construction must be defined if PCH is defined.
+scons: \*\*\* The PCHSTOP construction must be defined if PCH is defined.
File "SConstruct", line 5, in \?
''')
@@ -228,7 +228,7 @@ env.Program('test', 'test.cpp')
""")
test.run(status=2, stderr='''
-SCons error: The PCHSTOP construction variable must be a string: .+
+scons: \*\*\* The PCHSTOP construction variable must be a string: .+
File "SConstruct", line 6, in \?
''')