diff options
Diffstat (limited to 'test/MSVC')
-rw-r--r-- | test/MSVC/PCHCOM.py | 6 | ||||
-rw-r--r-- | test/MSVC/PCHCOMSTR.py | 6 | ||||
-rw-r--r-- | test/MSVC/RCCOM.py | 4 | ||||
-rw-r--r-- | test/MSVC/RCCOMSTR.py | 4 | ||||
-rw-r--r-- | test/MSVC/generate-rc.py | 70 | ||||
-rw-r--r-- | test/MSVC/msvc.py | 36 |
6 files changed, 102 insertions, 24 deletions
diff --git a/test/MSVC/PCHCOM.py b/test/MSVC/PCHCOM.py index 593a1c1..2473391 100644 --- a/test/MSVC/PCHCOM.py +++ b/test/MSVC/PCHCOM.py @@ -30,7 +30,7 @@ Test the ability to configure the $MIDLCOM construction variable. import TestSCons -python = TestSCons.python +_python_ = TestSCons._python_ test = TestSCons.TestSCons() @@ -48,9 +48,9 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(tools=['default', 'msvc'], - PCHCOM = r'%s mypch.py $TARGET $SOURCES') + PCHCOM = r'%(_python_)s mypch.py $TARGET $SOURCES') env.PCH(target = 'aaa', source = 'aaa.h') -""" % python) +""" % locals()) test.write('aaa.h', "aaa.h\n/*pch*/\n") diff --git a/test/MSVC/PCHCOMSTR.py b/test/MSVC/PCHCOMSTR.py index c5ab9f5..23322d4 100644 --- a/test/MSVC/PCHCOMSTR.py +++ b/test/MSVC/PCHCOMSTR.py @@ -31,7 +31,7 @@ the displayed string when pch is called. import TestSCons -python = TestSCons.python +_python_ = TestSCons._python_ test = TestSCons.TestSCons() @@ -49,10 +49,10 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(tools=['default', 'msvc'], - PCHCOM = r'%s mypch.py $TARGET $SOURCES', + PCHCOM = r'%(_python_)s mypch.py $TARGET $SOURCES', PCHCOMSTR = 'PCHing $TARGET from $SOURCE') env.PCH(target = 'aaa', source = 'aaa.h') -""" % python) +""" % locals()) test.write('aaa.h', "aaa.h\n/*pch*/\n") diff --git a/test/MSVC/RCCOM.py b/test/MSVC/RCCOM.py index 3262f0c..e881bb5 100644 --- a/test/MSVC/RCCOM.py +++ b/test/MSVC/RCCOM.py @@ -31,7 +31,7 @@ when using MSVC. import TestSCons -python = TestSCons.python +_python_ = TestSCons._python_ test = TestSCons.TestSCons() @@ -49,7 +49,7 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(tools=['default', 'msvc'], - RCCOM = r'%(python)s myrc.py $TARGET $SOURCES') + RCCOM = r'%(_python_)s myrc.py $TARGET $SOURCES') env.RES(target = 'aaa', source = 'aaa.rc') """ % locals()) diff --git a/test/MSVC/RCCOMSTR.py b/test/MSVC/RCCOMSTR.py index 33e192b..96ccee0 100644 --- a/test/MSVC/RCCOMSTR.py +++ b/test/MSVC/RCCOMSTR.py @@ -31,7 +31,7 @@ the displayed string when rc is called. import TestSCons -python = TestSCons.python +_python_ = TestSCons._python_ test = TestSCons.TestSCons() @@ -49,7 +49,7 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(tools=['default', 'msvc'], - RCCOM = r'%(python)s myrc.py $TARGET $SOURCES', + RCCOM = r'%(_python_)s myrc.py $TARGET $SOURCES', RCCOMSTR = 'RCing $TARGET from $SOURCE') env.RES(target = 'aaa', source = 'aaa.rc') """ % locals()) diff --git a/test/MSVC/generate-rc.py b/test/MSVC/generate-rc.py new file mode 100644 index 0000000..0b3c332 --- /dev/null +++ b/test/MSVC/generate-rc.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# 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__" + +""" +Test adding a src_builder to the RES builder so that RC files can +be generated. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +fake_rc = test.workpath('fake_rc.py') + +test.write(fake_rc, """\ +import sys +contents = open(sys.argv[2], 'rb').read() +open(sys.argv[1], 'wb').write("fake_rc.py\\n" + contents) +""") + +test.write('SConstruct', """ +def generate_rc(target, source, env): + t = str(target[0]) + s = str(source[0]) + tfp = open(t, 'wb') + tfp.write('generate_rc\\n' + open(s, 'r').read()) + +env = Environment(tools=['msvc'], + RCCOM=r'%(_python_)s %(fake_rc)s $TARGET $SOURCE') +env['BUILDERS']['GenerateRC'] = Builder(action=generate_rc, + suffix='.rc', + src_suffix='.in') +env['BUILDERS']['RES'].src_builder.append('GenerateRC') + +env.RES('my.in') +""" % locals()) + +test.write('my.in', "my.in\n") + +test.run(arguments = '.') + +test.must_match('my.rc', "generate_rc\nmy.in\n") +test.must_match('my.res', "fake_rc.py\ngenerate_rc\nmy.in\n") + +test.pass_test() diff --git a/test/MSVC/msvc.py b/test/MSVC/msvc.py index dd0f5ca..857b6bd 100644 --- a/test/MSVC/msvc.py +++ b/test/MSVC/msvc.py @@ -24,13 +24,15 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import TestSCons -import sys -import os.path import os -import TestCmd +import os.path +import re +import sys import time +import TestCmd +import TestSCons + test = TestSCons.TestSCons(match = TestCmd.match_re) if sys.platform != 'win32': @@ -234,30 +236,36 @@ test.must_not_exist(test.workpath('build/StdAfx.obj')) ##### # Test error reporting -test.write('SConstruct',""" -env=Environment() +SConstruct_path = test.workpath('SConstruct') + +test.write(SConstruct_path, """\ +env = Environment() env['PDB'] = File('test.pdb') env['PCH'] = env.PCH('StdAfx.cpp')[0] env.Program('test', 'test.cpp') """) -test.run(status=2, stderr=''' +expect_stderr = r''' scons: \*\*\* The PCHSTOP construction must be defined if PCH is defined. -File "SConstruct", line 5, in \? -''') +File "%s", line 4, in \? +''' % re.escape(SConstruct_path) -test.write('SConstruct',""" -env=Environment() +test.run(status=2, stderr=expect_stderr) + +test.write(SConstruct_path, """\ +env = Environment() env['PDB'] = File('test.pdb') env['PCHSTOP'] = File('StdAfx.h') env['PCH'] = env.PCH('StdAfx.cpp')[0] env.Program('test', 'test.cpp') """) -test.run(status=2, stderr=''' +expect_stderr = r''' scons: \*\*\* The PCHSTOP construction variable must be a string: .+ -File "SConstruct", line 6, in \? -''') +File "%s", line 5, in \? +''' % re.escape(SConstruct_path) + +test.run(status=2, stderr=expect_stderr) test.pass_test() |