Update MSVS tests with BuildDir logic.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 7 Oct 2005 10:53:07 +0000 (10:53 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 7 Oct 2005 10:53:07 +0000 (10:53 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1359 fdb21ef1-2011-0410-befe-b5e4ea1792b1

etc/TestSCons.py
test/MSVS/vs-6.0-files.py
test/MSVS/vs-7.0-files.py
test/MSVS/vs-7.1-files.py

index e0fd12fb2c8ebb044ba5a88560431fc97be7140d..b49afaddf67f04b2d71a8684af32d204dca2f2ac 100644 (file)
@@ -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, "'", "&apos;")
 
         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
index fdc8ef2c96819a00219437fbe168a6a6427ed397..8792cb0952d73cec9278007b8e3660c617292d89 100644 (file)
@@ -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()
index c04c11230cf5df5a0ab4074061011f990e31cd53..9144537860b3af49d45c8591a4308458af65c66d 100644 (file)
@@ -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()
index 71670faf9f307cb0338eae95883c037ea0e64475..5b5799b9e3796d338f3ae012468a06b6de6b5b30 100644 (file)
@@ -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()