diff options
author | Steven Knight <knight@baldmt.com> | 2005-10-07 10:53:07 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2005-10-07 10:53:07 (GMT) |
commit | 151fa152b2abb0808ded783c6597fe7116cfaf66 (patch) | |
tree | 20735b9e7339336d97f60a0c4cccb0c6196a694a | |
parent | edffadf864a9815ef928a689a899f998b242b739 (diff) | |
download | SCons-151fa152b2abb0808ded783c6597fe7116cfaf66.zip SCons-151fa152b2abb0808ded783c6597fe7116cfaf66.tar.gz SCons-151fa152b2abb0808ded783c6597fe7116cfaf66.tar.bz2 |
Update MSVS tests with BuildDir logic.
-rw-r--r-- | etc/TestSCons.py | 6 | ||||
-rw-r--r-- | test/MSVS/vs-6.0-files.py | 58 | ||||
-rw-r--r-- | test/MSVS/vs-7.0-files.py | 63 | ||||
-rw-r--r-- | 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 e0fd12f..b49afad 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>', workpath) result = string.replace(result, r'<PYTHON>', python) + result = string.replace(result, r'<SCONSCRIPT>', sconscript) result = string.replace(result, r'<SCONS_SCRIPT_MAIN>', exec_script_main) result = string.replace(result, r'<SCONS_SCRIPT_MAIN_XML>', 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 fdc8ef2..8792cb0 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="<WORKPATH>\SConstruct" +SOURCE="<SCONSCRIPT>" # 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 c04c112..9144537 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</File> \t\t</Filter> \t\t<File -\t\t\tRelativePath="<WORKPATH>\SConstruct"> +\t\t\tRelativePath="<SCONSCRIPT>"> \t\t</File> \t</Files> \t<Globals> @@ -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 71670fa..5b5799b 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</File> \t\t</Filter> \t\t<File -\t\t\tRelativePath="<WORKPATH>\SConstruct"> +\t\t\tRelativePath="<SCONSCRIPT>"> \t\t</File> \t</Files> \t<Globals> @@ -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() |