From b30925aaefdf7a5b2ca9d25862998c590f9e92da Mon Sep 17 00:00:00 2001 From: stevenknight Date: Fri, 7 Oct 2005 10:53:07 +0000 Subject: [PATCH] Update MSVS tests with BuildDir logic. git-svn-id: http://scons.tigris.org/svn/scons/trunk@1359 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- etc/TestSCons.py | 6 +++- test/MSVS/vs-6.0-files.py | 58 ++++++++++++++++++++++++++++++----- test/MSVS/vs-7.0-files.py | 63 +++++++++++++++++++++++++++++++++----- test/MSVS/vs-7.1-files.py | 64 +++++++++++++++++++++++++++++++++------ 4 files changed, 166 insertions(+), 25 deletions(-) diff --git a/etc/TestSCons.py b/etc/TestSCons.py index e0fd12fb..b49afadd 100644 --- a/etc/TestSCons.py +++ b/etc/TestSCons.py @@ -473,7 +473,7 @@ print "self._msvs_versions =", str(env['MSVS']['VERSIONS']) contents = string.replace(contents, orig, replace) self.write(fname, contents) - def msvs_substitute(self, input, msvs_ver, subdir=None, python=sys.executable): + def msvs_substitute(self, input, msvs_ver, subdir=None, sconscript=None, python=sys.executable): if not hasattr(self, '_msvs_versions'): self.msvs_versions() @@ -482,11 +482,15 @@ print "self._msvs_versions =", str(env['MSVS']['VERSIONS']) else: workpath = self.workpath() + if not sconscript: + sconscript = self.workpath('SConstruct') + exec_script_main = "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-%s'), join(sys.prefix, 'scons-%s'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" % (self._scons_version, self._scons_version) exec_script_main_xml = string.replace(exec_script_main, "'", "'") result = string.replace(input, r'', workpath) result = string.replace(result, r'', python) + result = string.replace(result, r'', sconscript) result = string.replace(result, r'', exec_script_main) result = string.replace(result, r'', exec_script_main_xml) return result diff --git a/test/MSVS/vs-6.0-files.py b/test/MSVS/vs-6.0-files.py index fdc8ef2c..8792cb09 100644 --- a/test/MSVS/vs-6.0-files.py +++ b/test/MSVS/vs-6.0-files.py @@ -35,7 +35,7 @@ import sys import TestCmd import TestSCons -test = TestSCons.TestSCons(match = TestCmd.match_re) +test = TestSCons.TestSCons() if sys.platform != 'win32': msg = "Skipping Visual Studio test on non-Windows platform '%s'\n" % sys.platform @@ -144,7 +144,7 @@ SOURCE="test.rc" # End Group # Begin Source File -SOURCE="\SConstruct" +SOURCE="" # End Source File # End Target # End Project @@ -182,9 +182,8 @@ Package=<3> ''' -test.subdir('work1') -test.write(['work1', 'SConstruct'], """\ +SConscript_contents = """\ env=Environment(MSVS_VERSION = '6.0') testsrc = ['test.c'] @@ -201,19 +200,27 @@ env.MSVSProject(target = 'Test.dsp', misc = testmisc, buildtarget = 'Test.exe', variant = 'Release') -""") +""" + + + +test.subdir('work1') + +test.write(['work1', 'SConstruct'], SConscript_contents) test.run(chdir='work1', arguments="Test.dsp") test.must_exist(test.workpath('work1', 'Test.dsp')) dsp = test.read(['work1', 'Test.dsp'], 'r') -expect = test.msvs_substitute(expected_dspfile, '6.0', 'work1') +expect = test.msvs_substitute(expected_dspfile, '6.0', 'work1', + test.workpath('work1', 'SConstruct')) # don't compare the pickled data assert dsp[:len(expect)] == expect, test.diff_substr(expect, dsp) test.must_exist(test.workpath('work1', 'Test.dsw')) dsw = test.read(['work1', 'Test.dsw'], 'r') -expect = test.msvs_substitute(expected_dswfile, '6.0', 'work1') +expect = test.msvs_substitute(expected_dswfile, '6.0', 'work1', + test.workpath('work1', 'SConstruct')) assert dsw == expect, test.diff_substr(expect, dsw) test.run(chdir='work1', arguments='-c .') @@ -233,4 +240,41 @@ test.must_not_exist(test.workpath('work1', 'Test.dsw')) +test.subdir('work2', ['work2', 'src']) + +test.write(['work2', 'SConstruct'], """\ +SConscript('src/SConscript', build_dir='build') +""") + +test.write(['work2', 'src', 'SConscript'], SConscript_contents) + +test.run(chdir='work2', arguments=".") + +test.must_match(['work2', 'build', 'Test.dsp'], """\ +This is just a placeholder file. +The real project file is here: +%s +""" % test.workpath('work2', 'src', 'Test.dsp'), + mode='r') + +dsp = test.read(['work2', 'src', 'Test.dsp'], 'r') +expect = test.msvs_substitute(expected_dspfile, '6.0', 'work2', + test.workpath('work2', 'src', 'SConscript')) +# don't compare the pickled data +assert dsp[:len(expect)] == expect, test.diff_substr(expect, dsp) + +test.must_match(['work2', 'build', 'Test.dsw'], """\ +This is just a placeholder file. +The real workspace file is here: +%s +""" % test.workpath('work2', 'src', 'Test.dsw'), + mode='r') + +test.must_exist(test.workpath('work2', 'src', 'Test.dsw')) +dsw = test.read(['work2', 'src', 'Test.dsw'], 'r') +expect = test.msvs_substitute(expected_dswfile, '6.0', 'work2\\src') +assert dsw == expect, test.diff_substr(expect, dsw) + + + test.pass_test() diff --git a/test/MSVS/vs-7.0-files.py b/test/MSVS/vs-7.0-files.py index c04c1123..91445378 100644 --- a/test/MSVS/vs-7.0-files.py +++ b/test/MSVS/vs-7.0-files.py @@ -36,7 +36,7 @@ import sys import TestCmd import TestSCons -test = TestSCons.TestSCons(match = TestCmd.match_re) +test = TestSCons.TestSCons() if sys.platform != 'win32': msg = "Skipping Visual Studio test on non-Windows platform '%s'\n" % sys.platform @@ -129,7 +129,7 @@ expected_vcprojfile = """\ \t\t\t \t\t \t\t +\t\t\tRelativePath=""> \t\t \t \t @@ -138,9 +138,8 @@ expected_vcprojfile = """\ """ -test.subdir('work1') -test.write(['work1', 'SConstruct'], """\ +SConscript_contents = """\ env=Environment(MSVS_VERSION = '7.0') testsrc = ['test.cpp'] @@ -158,19 +157,27 @@ env.MSVSProject(target = 'Test.vcproj', misc = testmisc, buildtarget = 'Test.exe', variant = 'Release') -""") +""" + + + +test.subdir('work1') + +test.write(['work1', 'SConstruct'], SConscript_contents) test.run(chdir='work1', arguments="Test.vcproj") test.must_exist(test.workpath('work1', 'Test.vcproj')) vcproj = test.read(['work1', 'Test.vcproj'], 'r') -expect = test.msvs_substitute(expected_vcprojfile, '7.0', 'work1') +expect = test.msvs_substitute(expected_vcprojfile, '7.0', 'work1', + test.workpath('work1', 'SConstruct')) # don't compare the pickled data assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) test.must_exist(test.workpath('work1', 'Test.sln')) sln = test.read(['work1', 'Test.sln'], 'r') -expect = test.msvs_substitute(expected_slnfile, '7.0', 'work1') +expect = test.msvs_substitute(expected_slnfile, '7.0', 'work1', + test.workpath('work1', 'SConstruct')) # don't compare the pickled data assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) @@ -201,7 +208,9 @@ python = os.path.join('$(PYTHON_ROOT)', os.path.split(sys.executable)[1]) test.must_exist(test.workpath('work1', 'Test.vcproj')) vcproj = test.read(['work1', 'Test.vcproj'], 'r') -expect = test.msvs_substitute(expected_vcprojfile, '7.0', 'work1', python=python) +expect = test.msvs_substitute(expected_vcprojfile, '7.0', 'work1', + test.workpath('work1', 'SConstruct'), + python=python) # don't compare the pickled data assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) @@ -209,4 +218,42 @@ os.environ['PYTHON_ROOT'] = '' +test.subdir('work2', ['work2', 'src']) + +test.write(['work2', 'SConstruct'], """\ +SConscript('src/SConscript', build_dir='build') +""") + +test.write(['work2', 'src', 'SConscript'], SConscript_contents) + +test.run(chdir='work2', arguments=".") + +test.must_match(['work2', 'build', 'Test.vcproj'], """\ +This is just a placeholder file. +The real project file is here: +%s +""" % test.workpath('work2', 'src', 'Test.vcproj'), + mode='r') + +vcproj = test.read(['work2', 'src', 'Test.vcproj'], 'r') +expect = test.msvs_substitute(expected_vcprojfile, '7.0', 'work2', + test.workpath('work2', 'src', 'SConscript')) +# don't compare the pickled data +assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) + +test.must_match(['work2', 'build', 'Test.sln'], """\ +This is just a placeholder file. +The real workspace file is here: +%s +""" % test.workpath('work2', 'src', 'Test.sln'), + mode='r') + +test.must_exist(test.workpath('work2', 'src', 'Test.sln')) +sln = test.read(['work2', 'src', 'Test.sln'], 'r') +expect = test.msvs_substitute(expected_slnfile, '7.0', 'work2\\src') +# don't compare the pickled data +assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + + test.pass_test() diff --git a/test/MSVS/vs-7.1-files.py b/test/MSVS/vs-7.1-files.py index 71670faf..5b5799b9 100644 --- a/test/MSVS/vs-7.1-files.py +++ b/test/MSVS/vs-7.1-files.py @@ -36,7 +36,7 @@ import sys import TestCmd import TestSCons -test = TestSCons.TestSCons(match = TestCmd.match_re) +test = TestSCons.TestSCons() if sys.platform != 'win32': msg = "Skipping Visual Studio test on non-Windows platform '%s'\n" % sys.platform @@ -131,7 +131,7 @@ expected_vcprojfile = """\ \t\t\t \t\t \t\t +\t\t\tRelativePath=""> \t\t \t \t @@ -141,9 +141,7 @@ expected_vcprojfile = """\ -test.subdir('work1') - -test.write(['work1', 'SConstruct'], """\ +SConscript_contents = """\ env=Environment(MSVS_VERSION = '7.1') testsrc = ['test.cpp'] @@ -161,19 +159,27 @@ env.MSVSProject(target = 'Test.vcproj', misc = testmisc, buildtarget = 'Test.exe', variant = 'Release') -""") +""" + + + +test.subdir('work1') + +test.write(['work1', 'SConstruct'], SConscript_contents) test.run(chdir='work1', arguments="Test.vcproj") test.must_exist(test.workpath('work1', 'Test.vcproj')) vcproj = test.read(['work1', 'Test.vcproj'], 'r') -expect = test.msvs_substitute(expected_vcprojfile, '7.1', 'work1') +expect = test.msvs_substitute(expected_vcprojfile, '7.1', 'work1', + test.workpath('work1', 'SConstruct')) # don't compare the pickled data assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) test.must_exist(test.workpath('work1', 'Test.sln')) sln = test.read(['work1', 'Test.sln'], 'r') -expect = test.msvs_substitute(expected_slnfile, '7.1', 'work1') +expect = test.msvs_substitute(expected_slnfile, '7.1', 'work1', + test.workpath('work1', 'SConstruct')) # don't compare the pickled data assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) @@ -204,7 +210,9 @@ python = os.path.join('$(PYTHON_ROOT)', os.path.split(sys.executable)[1]) test.must_exist(test.workpath('work1', 'Test.vcproj')) vcproj = test.read(['work1', 'Test.vcproj'], 'r') -expect = test.msvs_substitute(expected_vcprojfile, '7.1', 'work1', python=python) +expect = test.msvs_substitute(expected_vcprojfile, '7.1', 'work1', + test.workpath('work1', 'SConstruct'), + python=python) # don't compare the pickled data assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) @@ -212,4 +220,42 @@ os.environ['PYTHON_ROOT'] = '' +test.subdir('work2', ['work2', 'src']) + +test.write(['work2', 'SConstruct'], """\ +SConscript('src/SConscript', build_dir='build') +""") + +test.write(['work2', 'src', 'SConscript'], SConscript_contents) + +test.run(chdir='work2', arguments=".") + +test.must_match(['work2', 'build', 'Test.vcproj'], """\ +This is just a placeholder file. +The real project file is here: +%s +""" % test.workpath('work2', 'src', 'Test.vcproj'), + mode='r') + +vcproj = test.read(['work2', 'src', 'Test.vcproj'], 'r') +expect = test.msvs_substitute(expected_vcprojfile, '7.0', 'work2', + test.workpath('work2', 'src', 'SConscript')) +# don't compare the pickled data +assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) + +test.must_match(['work2', 'build', 'Test.sln'], """\ +This is just a placeholder file. +The real workspace file is here: +%s +""" % test.workpath('work2', 'src', 'Test.sln'), + mode='r') + +test.must_exist(test.workpath('work2', 'src', 'Test.sln')) +sln = test.read(['work2', 'src', 'Test.sln'], 'r') +expect = test.msvs_substitute(expected_slnfile, '7.0', 'work2\\src') +# don't compare the pickled data +assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + + test.pass_test() -- 2.26.2