diff options
author | Joseph Brill <48932340+jcbrill@users.noreply.github.com> | 2024-10-28 16:54:42 (GMT) |
---|---|---|
committer | Joseph Brill <48932340+jcbrill@users.noreply.github.com> | 2024-10-28 16:54:42 (GMT) |
commit | 55849419b8a1365d5918386c085be55bc9cddd3a (patch) | |
tree | d2e0059d6df70d4997c0a674b3fe03f1e528a8f2 /test | |
parent | ca866a25eb7caa2ff4c15048271441c1d8d2ba75 (diff) | |
download | SCons-55849419b8a1365d5918386c085be55bc9cddd3a.zip SCons-55849419b8a1365d5918386c085be55bc9cddd3a.tar.gz SCons-55849419b8a1365d5918386c085be55bc9cddd3a.tar.bz2 |
Add optional keyword argument auto_filter_projects to MSVSSolution.
Changes:
* Detect solution file names and nodes in projects argument list. Behavior based on the auto_filter_projects value. By default, raise an exception.
* Update TestSConsMSVS and multiple project auto_build_solution tests.
* Update documentation, CHANGES.txt, and RELEASE.txt.
Diffstat (limited to 'test')
-rw-r--r-- | test/MSVS/vs-mult-auto-guid.py | 228 | ||||
-rw-r--r-- | test/MSVS/vs-mult-auto-vardir-guid.py | 244 | ||||
-rw-r--r-- | test/MSVS/vs-mult-auto-vardir.py | 222 | ||||
-rw-r--r-- | test/MSVS/vs-mult-auto.py | 204 |
4 files changed, 487 insertions, 411 deletions
diff --git a/test/MSVS/vs-mult-auto-guid.py b/test/MSVS/vs-mult-auto-guid.py index 1328f54..412c379 100644 --- a/test/MSVS/vs-mult-auto-guid.py +++ b/test/MSVS/vs-mult-auto-guid.py @@ -32,111 +32,129 @@ import TestSConsMSVS test = None for vc_version in TestSConsMSVS.get_tested_proj_file_vc_versions(): - test = TestSConsMSVS.TestSConsMSVS() - - # Make the test infrastructure think we have this version of MSVS installed. - test._msvs_versions = [vc_version] - - dirs = ['inc1', 'inc2'] - major, minor = test.parse_vc_version(vc_version) - project_ext = '.vcproj' if major <= 9 else '.vcxproj' - - project_file_1 = 'Test_1' + project_ext - project_file_2 = 'Test_2' + project_ext - - filters_file_1 = project_file_1 + '.filters' - filters_file_2 = project_file_2 + '.filters' - filters_file_expected = major >= 10 - - solution_file = 'Test.sln' - solution_file_1 = 'Test_1.sln' - solution_file_2 = 'Test_2.sln' - - if major >= 10: - project_guid_1 = "{F7D7CE55-37BF-51DE-8942-9377B2BE8387}" - project_guid_2 = "{8D17BC73-09FD-5B69-BBBF-1E40E0C63456}" - else: - project_guid_1 = "{53EE9FA7-6300-55B8-8A0E-A3DC40983390}" - project_guid_2 = "{57358E9B-126D-53F6-AD5A-559AB4A8EE62}" - - expected_vcprojfile_1 = test.get_expected_projects_proj_file_contents( - vc_version, dirs, project_file_1, project_guid_1, - ) - - expected_vcprojfile_2 = test.get_expected_projects_proj_file_contents( - vc_version, dirs, project_file_2, project_guid_2, - ) - - expected_slnfile = test.get_expected_projects_sln_file_contents( - vc_version, - project_file_1, - project_file_2, - ) - - expected_slnfile_1 = test.get_expected_sln_file_contents( - vc_version, - project_file_1, - ) - - expected_slnfile_2 = test.get_expected_sln_file_contents( - vc_version, - project_file_2, - ) - - SConstruct_contents = test.get_expected_projects_sconscript_file_contents( - vc_version=vc_version, - project_file_1=project_file_1, - project_file_2=project_file_2, - solution_file=solution_file, - autobuild_solution=1, - default_guids=True, - ) - - test.write('SConstruct', SConstruct_contents) - - test.run(arguments=".") - - test.must_exist(test.workpath(project_file_1)) - vcproj = test.read(project_file_1, 'r') - expect = test.msvs_substitute(expected_vcprojfile_1, vc_version, None, 'SConstruct', project_guid=project_guid_1) - # don't compare the pickled data - assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - - test.must_exist(test.workpath(project_file_2)) - vcproj = test.read(project_file_2, 'r') - expect = test.msvs_substitute(expected_vcprojfile_2, vc_version, None, 'SConstruct', project_guid=project_guid_2) - # don't compare the pickled data - assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - - test.must_exist(test.workpath(solution_file)) - sln = test.read(solution_file, 'r') - expect = test.msvs_substitute_projects( - expected_slnfile, subdir='src', - project_guid_1=project_guid_1, project_guid_2=project_guid_2 - ) - # don't compare the pickled data - assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - test.must_exist(test.workpath(solution_file_1)) - sln = test.read(solution_file_1, 'r') - expect = test.msvs_substitute(expected_slnfile_1, vc_version, subdir='src', project_guid=project_guid_1) - # don't compare the pickled data - assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - test.must_exist(test.workpath(solution_file_2)) - sln = test.read(solution_file_2, 'r') - expect = test.msvs_substitute(expected_slnfile_2, vc_version, subdir='src', project_guid=project_guid_2) - # don't compare the pickled data - assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - if filters_file_expected: - test.must_exist(test.workpath(filters_file_1)) - test.must_exist(test.workpath(filters_file_2)) - else: - test.must_not_exist(test.workpath(filters_file_1)) - test.must_not_exist(test.workpath(filters_file_2)) - - # TODO: clean tests + + for autofilter_projects in (None, False, True): + + test = TestSConsMSVS.TestSConsMSVS() + + # Make the test infrastructure think we have this version of MSVS installed. + test._msvs_versions = [vc_version] + + dirs = ['inc1', 'inc2'] + major, minor = test.parse_vc_version(vc_version) + project_ext = '.vcproj' if major <= 9 else '.vcxproj' + + project_file_1 = 'Test_1' + project_ext + project_file_2 = 'Test_2' + project_ext + + filters_file_1 = project_file_1 + '.filters' + filters_file_2 = project_file_2 + '.filters' + filters_file_expected = major >= 10 + + solution_file = 'Test.sln' + solution_file_1 = 'Test_1.sln' + solution_file_2 = 'Test_2.sln' + + if major >= 10: + project_guid_1 = "{F7D7CE55-37BF-51DE-8942-9377B2BE8387}" + project_guid_2 = "{8D17BC73-09FD-5B69-BBBF-1E40E0C63456}" + else: + project_guid_1 = "{53EE9FA7-6300-55B8-8A0E-A3DC40983390}" + project_guid_2 = "{57358E9B-126D-53F6-AD5A-559AB4A8EE62}" + + if major >= 10: + solution_guid_1 = "{73ABD7C4-0A64-5192-97C3-252B70C8D1B1}" + solution_guid_2 = "{142F0D4F-9896-5808-AAB4-A80F5661B1FE}" + else: + solution_guid_1 = "{73ABD7C4-0A64-5192-97C3-252B70C8D1B1}" + solution_guid_2 = "{142F0D4F-9896-5808-AAB4-A80F5661B1FE}" + + expected_vcprojfile_1 = test.get_expected_projects_proj_file_contents( + vc_version, dirs, project_file_1, project_guid_1, + ) + + expected_vcprojfile_2 = test.get_expected_projects_proj_file_contents( + vc_version, dirs, project_file_2, project_guid_2, + ) + + expected_slnfile = test.get_expected_projects_sln_file_contents( + vc_version, + project_file_1, + project_file_2, + have_solution_project_nodes=True, + autofilter_solution_project_nodes=autofilter_projects, + ) + + expected_slnfile_1 = test.get_expected_sln_file_contents( + vc_version, + project_file_1, + ) + + expected_slnfile_2 = test.get_expected_sln_file_contents( + vc_version, + project_file_2, + ) + + SConstruct_contents = test.get_expected_projects_sconscript_file_contents( + vc_version=vc_version, + project_file_1=project_file_1, + project_file_2=project_file_2, + solution_file=solution_file, + autobuild_solution=1, + autofilter_projects=autofilter_projects, + default_guids=True, + ) + + test.write('SConstruct', SConstruct_contents) + + if autofilter_projects is None: + test.run(arguments=".", status=2, stderr=r"^.*scons: [*]{3} An msvs solution file was detected in the MSVSSolution 'projects' argument:.+", match=test.match_re_dotall) + continue + + test.run(arguments=".") + + test.must_exist(test.workpath(project_file_1)) + vcproj = test.read(project_file_1, 'r') + expect = test.msvs_substitute(expected_vcprojfile_1, vc_version, None, 'SConstruct', project_guid=project_guid_1) + # don't compare the pickled data + assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) + + test.must_exist(test.workpath(project_file_2)) + vcproj = test.read(project_file_2, 'r') + expect = test.msvs_substitute(expected_vcprojfile_2, vc_version, None, 'SConstruct', project_guid=project_guid_2) + # don't compare the pickled data + assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) + + test.must_exist(test.workpath(solution_file)) + sln = test.read(solution_file, 'r') + expect = test.msvs_substitute_projects( + expected_slnfile, subdir='src', + project_guid_1=project_guid_1, project_guid_2=project_guid_2, + solution_guid_1=solution_guid_1, solution_guid_2=solution_guid_2, + ) + # don't compare the pickled data + assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + test.must_exist(test.workpath(solution_file_1)) + sln = test.read(solution_file_1, 'r') + expect = test.msvs_substitute(expected_slnfile_1, vc_version, subdir='src', project_guid=project_guid_1) + # don't compare the pickled data + assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + test.must_exist(test.workpath(solution_file_2)) + sln = test.read(solution_file_2, 'r') + expect = test.msvs_substitute(expected_slnfile_2, vc_version, subdir='src', project_guid=project_guid_2) + # don't compare the pickled data + assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + if filters_file_expected: + test.must_exist(test.workpath(filters_file_1)) + test.must_exist(test.workpath(filters_file_2)) + else: + test.must_not_exist(test.workpath(filters_file_1)) + test.must_not_exist(test.workpath(filters_file_2)) + + # TODO: clean tests if test: test.pass_test() diff --git a/test/MSVS/vs-mult-auto-vardir-guid.py b/test/MSVS/vs-mult-auto-vardir-guid.py index 026a2e8..87d2332 100644 --- a/test/MSVS/vs-mult-auto-vardir-guid.py +++ b/test/MSVS/vs-mult-auto-vardir-guid.py @@ -32,147 +32,165 @@ import TestSConsMSVS test = None for vc_version in TestSConsMSVS.get_tested_proj_file_vc_versions(): - test = TestSConsMSVS.TestSConsMSVS() - - # Make the test infrastructure think we have this version of MSVS installed. - test._msvs_versions = [vc_version] - - dirs = ['inc1', 'inc2'] - major, minor = test.parse_vc_version(vc_version) - project_ext = '.vcproj' if major <= 9 else '.vcxproj' - - project_file_1 = 'Test_1' + project_ext - project_file_2 = 'Test_2' + project_ext - - filters_file_1 = project_file_1 + '.filters' - filters_file_2 = project_file_2 + '.filters' - filters_file_expected = major >= 10 - - solution_file = 'Test.sln' - solution_file_1 = 'Test_1.sln' - solution_file_2 = 'Test_2.sln' - - if major >= 10: - project_guid_1 = "{5A243E49-07F0-54C3-B3FD-1DBDF1BA5C9E}" - project_guid_2 = "{E20E17C7-251E-5246-8FD1-5D51978A0A5D}" - else: - project_guid_1 = "{AB46DD68-8CD8-5832-B784-65B216B94739}" - project_guid_2 = "{03EB0BC3-DA68-5825-9EBB-D8713304E739}" - - expected_vcprojfile_1 = test.get_expected_projects_proj_file_contents( - vc_version, dirs, project_file_1, project_guid_1, - ) - - expected_vcprojfile_2 = test.get_expected_projects_proj_file_contents( - vc_version, dirs, project_file_2, project_guid_2, - ) - - expected_slnfile = test.get_expected_projects_sln_file_contents( - vc_version, - project_file_1, - project_file_2, - ) - - expected_slnfile_1 = test.get_expected_sln_file_contents( - vc_version, - project_file_1, - ) - - expected_slnfile_2 = test.get_expected_sln_file_contents( - vc_version, - project_file_2, - ) - - SConscript_contents = test.get_expected_projects_sconscript_file_contents( - vc_version=vc_version, - project_file_1=project_file_1, - project_file_2=project_file_2, - solution_file=solution_file, - autobuild_solution=1, - default_guids=True, - ) - - test.subdir('src') - - test.write('SConstruct', """\ + + for autofilter_projects in (None, False, True): + + test = TestSConsMSVS.TestSConsMSVS() + + # Make the test infrastructure think we have this version of MSVS installed. + test._msvs_versions = [vc_version] + + dirs = ['inc1', 'inc2'] + major, minor = test.parse_vc_version(vc_version) + project_ext = '.vcproj' if major <= 9 else '.vcxproj' + + project_file_1 = 'Test_1' + project_ext + project_file_2 = 'Test_2' + project_ext + + filters_file_1 = project_file_1 + '.filters' + filters_file_2 = project_file_2 + '.filters' + filters_file_expected = major >= 10 + + solution_file = 'Test.sln' + solution_file_1 = 'Test_1.sln' + solution_file_2 = 'Test_2.sln' + + if major >= 10: + project_guid_1 = "{5A243E49-07F0-54C3-B3FD-1DBDF1BA5C9E}" + project_guid_2 = "{E20E17C7-251E-5246-8FD1-5D51978A0A5D}" + else: + project_guid_1 = "{AB46DD68-8CD8-5832-B784-65B216B94739}" + project_guid_2 = "{03EB0BC3-DA68-5825-9EBB-D8713304E739}" + + if major >= 10: + solution_guid_1 = "{5E5E4F5D-3E6A-5958-81C6-D4B8B8C633FA}" + solution_guid_2 = "{ECBCA12A-191D-54EC-BA78-F14249171130}" + else: + solution_guid_1 = "{5E5E4F5D-3E6A-5958-81C6-D4B8B8C633FA}" + solution_guid_2 = "{ECBCA12A-191D-54EC-BA78-F14249171130}" + + expected_vcprojfile_1 = test.get_expected_projects_proj_file_contents( + vc_version, dirs, project_file_1, project_guid_1, + ) + + expected_vcprojfile_2 = test.get_expected_projects_proj_file_contents( + vc_version, dirs, project_file_2, project_guid_2, + ) + + expected_slnfile = test.get_expected_projects_sln_file_contents( + vc_version, + project_file_1, + project_file_2, + have_solution_project_nodes=True, + autofilter_solution_project_nodes=autofilter_projects, + ) + + expected_slnfile_1 = test.get_expected_sln_file_contents( + vc_version, + project_file_1, + ) + + expected_slnfile_2 = test.get_expected_sln_file_contents( + vc_version, + project_file_2, + ) + + SConscript_contents = test.get_expected_projects_sconscript_file_contents( + vc_version=vc_version, + project_file_1=project_file_1, + project_file_2=project_file_2, + solution_file=solution_file, + autobuild_solution=1, + autofilter_projects=autofilter_projects, + default_guids=True, + ) + + test.subdir('src') + + test.write('SConstruct', """\ SConscript('src/SConscript', variant_dir='build') """) - test.write(['src', 'SConscript'], SConscript_contents) - - test.run(arguments=".") - - test.must_exist(test.workpath('src', project_file_1)) - vcproj = test.read(['src', project_file_1], 'r') - expect = test.msvs_substitute(expected_vcprojfile_1, vc_version, None, 'SConstruct', project_guid=project_guid_1) - # don't compare the pickled data - assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - - test.must_exist(test.workpath('src', project_file_2)) - vcproj = test.read(['src', project_file_2], 'r') - expect = test.msvs_substitute(expected_vcprojfile_2, vc_version, None, 'SConstruct', project_guid=project_guid_2) - # don't compare the pickled data - assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - - test.must_exist(test.workpath('src', solution_file)) - sln = test.read(['src', solution_file], 'r') - expect = test.msvs_substitute_projects( - expected_slnfile, subdir='src', - project_guid_1=project_guid_1, project_guid_2=project_guid_2 - ) - # don't compare the pickled data - assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - test.must_exist(test.workpath('src', solution_file_1)) - sln = test.read(['src', solution_file_1], 'r') - expect = test.msvs_substitute(expected_slnfile_1, vc_version, subdir='src', project_guid=project_guid_1) - # don't compare the pickled data - assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - test.must_exist(test.workpath('src', solution_file_2)) - sln = test.read(['src', solution_file_2], 'r') - expect = test.msvs_substitute(expected_slnfile_2, vc_version, subdir='src', project_guid=project_guid_2) - # don't compare the pickled data - assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - if filters_file_expected: - test.must_exist(test.workpath('src', filters_file_1)) - test.must_exist(test.workpath('src', filters_file_2)) - else: - test.must_not_exist(test.workpath('src', filters_file_1)) - test.must_not_exist(test.workpath('src', filters_file_2)) - - test.must_match(['build', project_file_1], """\ + test.write(['src', 'SConscript'], SConscript_contents) + + if autofilter_projects is None: + test.run(arguments=".", status=2, stderr=r"^.*scons: [*]{3} An msvs solution file was detected in the MSVSSolution 'projects' argument:.+", match=test.match_re_dotall) + continue + + test.run(arguments=".") + + test.must_exist(test.workpath('src', project_file_1)) + vcproj = test.read(['src', project_file_1], 'r') + expect = test.msvs_substitute(expected_vcprojfile_1, vc_version, None, 'SConstruct', project_guid=project_guid_1) + # don't compare the pickled data + assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) + + test.must_exist(test.workpath('src', project_file_2)) + vcproj = test.read(['src', project_file_2], 'r') + expect = test.msvs_substitute(expected_vcprojfile_2, vc_version, None, 'SConstruct', project_guid=project_guid_2) + # don't compare the pickled data + assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) + + test.must_exist(test.workpath('src', solution_file)) + sln = test.read(['src', solution_file], 'r') + expect = test.msvs_substitute_projects( + expected_slnfile, subdir='src', + project_guid_1=project_guid_1, project_guid_2=project_guid_2, + solution_guid_1=solution_guid_1, solution_guid_2=solution_guid_2, + ) + # don't compare the pickled data + assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + test.must_exist(test.workpath('src', solution_file_1)) + sln = test.read(['src', solution_file_1], 'r') + expect = test.msvs_substitute(expected_slnfile_1, vc_version, subdir='src', project_guid=project_guid_1) + # don't compare the pickled data + assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + test.must_exist(test.workpath('src', solution_file_2)) + sln = test.read(['src', solution_file_2], 'r') + expect = test.msvs_substitute(expected_slnfile_2, vc_version, subdir='src', project_guid=project_guid_2) + # don't compare the pickled data + assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + if filters_file_expected: + test.must_exist(test.workpath('src', filters_file_1)) + test.must_exist(test.workpath('src', filters_file_2)) + else: + test.must_not_exist(test.workpath('src', filters_file_1)) + test.must_not_exist(test.workpath('src', filters_file_2)) + + test.must_match(['build', project_file_1], """\ This is just a placeholder file. The real project file is here: %s """ % test.workpath('src', project_file_1), mode='r') - test.must_match(['build', project_file_2], """\ + test.must_match(['build', project_file_2], """\ This is just a placeholder file. The real project file is here: %s """ % test.workpath('src', project_file_2), mode='r') - test.must_match(['build', solution_file], """\ + test.must_match(['build', solution_file], """\ This is just a placeholder file. The real workspace file is here: %s """ % test.workpath('src', solution_file), mode='r') - test.must_match(['build', solution_file_1], """\ + test.must_match(['build', solution_file_1], """\ This is just a placeholder file. The real workspace file is here: %s """ % test.workpath('src', solution_file_1), mode='r') - test.must_match(['build', solution_file_2], """\ + test.must_match(['build', solution_file_2], """\ This is just a placeholder file. The real workspace file is here: %s """ % test.workpath('src', solution_file_2), mode='r') - # TODO: clean tests + # TODO: clean tests if test: test.pass_test() diff --git a/test/MSVS/vs-mult-auto-vardir.py b/test/MSVS/vs-mult-auto-vardir.py index 9a83474..b4d2109 100644 --- a/test/MSVS/vs-mult-auto-vardir.py +++ b/test/MSVS/vs-mult-auto-vardir.py @@ -35,136 +35,156 @@ project_guid_2 = TestSConsMSVS.PROJECT_GUID_2 test = None for vc_version in TestSConsMSVS.get_tested_proj_file_vc_versions(): - test = TestSConsMSVS.TestSConsMSVS() - # Make the test infrastructure think we have this version of MSVS installed. - test._msvs_versions = [vc_version] - - dirs = ['inc1', 'inc2'] - major, minor = test.parse_vc_version(vc_version) - project_ext = '.vcproj' if major <= 9 else '.vcxproj' - - project_file_1 = 'Test_1' + project_ext - project_file_2 = 'Test_2' + project_ext - - filters_file_1 = project_file_1 + '.filters' - filters_file_2 = project_file_2 + '.filters' - filters_file_expected = major >= 10 - - solution_file = 'Test.sln' - solution_file_1 = 'Test_1.sln' - solution_file_2 = 'Test_2.sln' - - expected_vcprojfile_1 = test.get_expected_projects_proj_file_contents( - vc_version, dirs, project_file_1, project_guid_1, - ) - - expected_vcprojfile_2 = test.get_expected_projects_proj_file_contents( - vc_version, dirs, project_file_2, project_guid_2, - ) - - expected_slnfile = test.get_expected_projects_sln_file_contents( - vc_version, - project_file_1, - project_file_2, - ) - - expected_slnfile_1 = test.get_expected_sln_file_contents( - vc_version, - project_file_1, - ) - - expected_slnfile_2 = test.get_expected_sln_file_contents( - vc_version, - project_file_2, - ) - - SConscript_contents = test.get_expected_projects_sconscript_file_contents( - vc_version=vc_version, - project_file_1=project_file_1, - project_file_2=project_file_2, - solution_file=solution_file, - autobuild_solution=1, - ) - - test.subdir('src') - - test.write('SConstruct', """\ + for autofilter_projects in (None, False, True): + + test = TestSConsMSVS.TestSConsMSVS() + + # Make the test infrastructure think we have this version of MSVS installed. + test._msvs_versions = [vc_version] + + dirs = ['inc1', 'inc2'] + major, minor = test.parse_vc_version(vc_version) + project_ext = '.vcproj' if major <= 9 else '.vcxproj' + + project_file_1 = 'Test_1' + project_ext + project_file_2 = 'Test_2' + project_ext + + filters_file_1 = project_file_1 + '.filters' + filters_file_2 = project_file_2 + '.filters' + filters_file_expected = major >= 10 + + solution_file = 'Test.sln' + solution_file_1 = 'Test_1.sln' + solution_file_2 = 'Test_2.sln' + + if major >= 10: + solution_guid_1 = "{5E5E4F5D-3E6A-5958-81C6-D4B8B8C633FA}" + solution_guid_2 = "{ECBCA12A-191D-54EC-BA78-F14249171130}" + else: + solution_guid_1 = "{5E5E4F5D-3E6A-5958-81C6-D4B8B8C633FA}" + solution_guid_2 = "{ECBCA12A-191D-54EC-BA78-F14249171130}" + + expected_vcprojfile_1 = test.get_expected_projects_proj_file_contents( + vc_version, dirs, project_file_1, project_guid_1, + ) + + expected_vcprojfile_2 = test.get_expected_projects_proj_file_contents( + vc_version, dirs, project_file_2, project_guid_2, + ) + + expected_slnfile = test.get_expected_projects_sln_file_contents( + vc_version, + project_file_1, + project_file_2, + have_solution_project_nodes=True, + autofilter_solution_project_nodes=autofilter_projects, + ) + + expected_slnfile_1 = test.get_expected_sln_file_contents( + vc_version, + project_file_1, + ) + + expected_slnfile_2 = test.get_expected_sln_file_contents( + vc_version, + project_file_2, + ) + + SConscript_contents = test.get_expected_projects_sconscript_file_contents( + vc_version=vc_version, + project_file_1=project_file_1, + project_file_2=project_file_2, + solution_file=solution_file, + autobuild_solution=1, + autofilter_projects=autofilter_projects, + ) + + test.subdir('src') + + test.write('SConstruct', """\ SConscript('src/SConscript', variant_dir='build') """) - test.write(['src', 'SConscript'], SConscript_contents) - - test.run(arguments=".") - - test.must_exist(test.workpath('src', project_file_1)) - vcproj = test.read(['src', project_file_1], 'r') - expect = test.msvs_substitute(expected_vcprojfile_1, vc_version, None, 'SConstruct', project_guid=project_guid_1) - # don't compare the pickled data - assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - - test.must_exist(test.workpath('src', project_file_2)) - vcproj = test.read(['src', project_file_2], 'r') - expect = test.msvs_substitute(expected_vcprojfile_2, vc_version, None, 'SConstruct', project_guid=project_guid_2) - # don't compare the pickled data - assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - - test.must_exist(test.workpath('src', solution_file)) - sln = test.read(['src', solution_file], 'r') - expect = test.msvs_substitute_projects(expected_slnfile, subdir='src') - # don't compare the pickled data - assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - test.must_exist(test.workpath('src', solution_file_1)) - sln = test.read(['src', solution_file_1], 'r') - expect = test.msvs_substitute(expected_slnfile_1, vc_version, subdir='src', project_guid=project_guid_1) - # don't compare the pickled data - assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - test.must_exist(test.workpath('src', solution_file_2)) - sln = test.read(['src', solution_file_2], 'r') - expect = test.msvs_substitute(expected_slnfile_2, vc_version, subdir='src', project_guid=project_guid_2) - # don't compare the pickled data - assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - if filters_file_expected: - test.must_exist(test.workpath('src', filters_file_1)) - test.must_exist(test.workpath('src', filters_file_2)) - else: - test.must_not_exist(test.workpath('src', filters_file_1)) - test.must_not_exist(test.workpath('src', filters_file_2)) - - test.must_match(['build', project_file_1], """\ + test.write(['src', 'SConscript'], SConscript_contents) + + if autofilter_projects is None: + test.run(arguments=".", status=2, stderr=r"^.*scons: [*]{3} An msvs solution file was detected in the MSVSSolution 'projects' argument:.+", match=test.match_re_dotall) + continue + + test.run(arguments=".") + + test.must_exist(test.workpath('src', project_file_1)) + vcproj = test.read(['src', project_file_1], 'r') + expect = test.msvs_substitute(expected_vcprojfile_1, vc_version, None, 'SConstruct', project_guid=project_guid_1) + # don't compare the pickled data + assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) + + test.must_exist(test.workpath('src', project_file_2)) + vcproj = test.read(['src', project_file_2], 'r') + expect = test.msvs_substitute(expected_vcprojfile_2, vc_version, None, 'SConstruct', project_guid=project_guid_2) + # don't compare the pickled data + assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) + + test.must_exist(test.workpath('src', solution_file)) + sln = test.read(['src', solution_file], 'r') + expect = test.msvs_substitute_projects( + expected_slnfile, subdir='src', + solution_guid_1=solution_guid_1, solution_guid_2=solution_guid_2, + ) + # don't compare the pickled data + assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + test.must_exist(test.workpath('src', solution_file_1)) + sln = test.read(['src', solution_file_1], 'r') + expect = test.msvs_substitute(expected_slnfile_1, vc_version, subdir='src', project_guid=project_guid_1) + # don't compare the pickled data + assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + test.must_exist(test.workpath('src', solution_file_2)) + sln = test.read(['src', solution_file_2], 'r') + expect = test.msvs_substitute(expected_slnfile_2, vc_version, subdir='src', project_guid=project_guid_2) + # don't compare the pickled data + assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + if filters_file_expected: + test.must_exist(test.workpath('src', filters_file_1)) + test.must_exist(test.workpath('src', filters_file_2)) + else: + test.must_not_exist(test.workpath('src', filters_file_1)) + test.must_not_exist(test.workpath('src', filters_file_2)) + + test.must_match(['build', project_file_1], """\ This is just a placeholder file. The real project file is here: %s """ % test.workpath('src', project_file_1), mode='r') - test.must_match(['build', project_file_2], """\ + test.must_match(['build', project_file_2], """\ This is just a placeholder file. The real project file is here: %s """ % test.workpath('src', project_file_2), mode='r') - test.must_match(['build', solution_file], """\ + test.must_match(['build', solution_file], """\ This is just a placeholder file. The real workspace file is here: %s """ % test.workpath('src', solution_file), mode='r') - test.must_match(['build', solution_file_1], """\ + test.must_match(['build', solution_file_1], """\ This is just a placeholder file. The real workspace file is here: %s """ % test.workpath('src', solution_file_1), mode='r') - test.must_match(['build', solution_file_2], """\ + test.must_match(['build', solution_file_2], """\ This is just a placeholder file. The real workspace file is here: %s """ % test.workpath('src', solution_file_2), mode='r') - # TODO: clean tests + # TODO: clean tests if test: test.pass_test() diff --git a/test/MSVS/vs-mult-auto.py b/test/MSVS/vs-mult-auto.py index 4b071c2..57f1145 100644 --- a/test/MSVS/vs-mult-auto.py +++ b/test/MSVS/vs-mult-auto.py @@ -35,98 +35,118 @@ project_guid_2 = TestSConsMSVS.PROJECT_GUID_2 test = None for vc_version in TestSConsMSVS.get_tested_proj_file_vc_versions(): - test = TestSConsMSVS.TestSConsMSVS() - - # Make the test infrastructure think we have this version of MSVS installed. - test._msvs_versions = [vc_version] - - dirs = ['inc1', 'inc2'] - major, minor = test.parse_vc_version(vc_version) - project_ext = '.vcproj' if major <= 9 else '.vcxproj' - - project_file_1 = 'Test_1' + project_ext - project_file_2 = 'Test_2' + project_ext - - filters_file_1 = project_file_1 + '.filters' - filters_file_2 = project_file_2 + '.filters' - filters_file_expected = major >= 10 - - solution_file = 'Test.sln' - solution_file_1 = 'Test_1.sln' - solution_file_2 = 'Test_2.sln' - - expected_vcprojfile_1 = test.get_expected_projects_proj_file_contents( - vc_version, dirs, project_file_1, project_guid_1, - ) - - expected_vcprojfile_2 = test.get_expected_projects_proj_file_contents( - vc_version, dirs, project_file_2, project_guid_2, - ) - - expected_slnfile = test.get_expected_projects_sln_file_contents( - vc_version, - project_file_1, - project_file_2, - ) - - expected_slnfile_1 = test.get_expected_sln_file_contents( - vc_version, - project_file_1, - ) - - expected_slnfile_2 = test.get_expected_sln_file_contents( - vc_version, - project_file_2, - ) - - SConstruct_contents = test.get_expected_projects_sconscript_file_contents( - vc_version=vc_version, - project_file_1=project_file_1, - project_file_2=project_file_2, - solution_file=solution_file, - autobuild_solution=1, - ) - - test.write('SConstruct', SConstruct_contents) - - test.run(arguments=".") - - test.must_exist(test.workpath(project_file_1)) - vcproj = test.read(project_file_1, 'r') - expect = test.msvs_substitute(expected_vcprojfile_1, vc_version, None, 'SConstruct', project_guid=project_guid_1) - # don't compare the pickled data - assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - - test.must_exist(test.workpath(project_file_2)) - vcproj = test.read(project_file_2, 'r') - expect = test.msvs_substitute(expected_vcprojfile_2, vc_version, None, 'SConstruct', project_guid=project_guid_2) - # don't compare the pickled data - assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) - - test.must_exist(test.workpath(solution_file)) - sln = test.read(solution_file, 'r') - expect = test.msvs_substitute_projects(expected_slnfile, subdir='src') - # don't compare the pickled data - assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - test.must_exist(test.workpath(solution_file_1)) - sln = test.read(solution_file_1, 'r') - expect = test.msvs_substitute(expected_slnfile_1, vc_version, subdir='src', project_guid=project_guid_1) - # don't compare the pickled data - assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - test.must_exist(test.workpath(solution_file_2)) - sln = test.read(solution_file_2, 'r') - expect = test.msvs_substitute(expected_slnfile_2, vc_version, subdir='src', project_guid=project_guid_2) - # don't compare the pickled data - assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) - - if filters_file_expected: - test.must_exist(test.workpath(filters_file_1)) - test.must_exist(test.workpath(filters_file_2)) - else: - test.must_not_exist(test.workpath(filters_file_1)) - test.must_not_exist(test.workpath(filters_file_2)) + + for autofilter_projects in (None, False, True): + + test = TestSConsMSVS.TestSConsMSVS() + + # Make the test infrastructure think we have this version of MSVS installed. + test._msvs_versions = [vc_version] + + dirs = ['inc1', 'inc2'] + major, minor = test.parse_vc_version(vc_version) + project_ext = '.vcproj' if major <= 9 else '.vcxproj' + + project_file_1 = 'Test_1' + project_ext + project_file_2 = 'Test_2' + project_ext + + filters_file_1 = project_file_1 + '.filters' + filters_file_2 = project_file_2 + '.filters' + filters_file_expected = major >= 10 + + solution_file = 'Test.sln' + solution_file_1 = 'Test_1.sln' + solution_file_2 = 'Test_2.sln' + + if major >= 10: + solution_guid_1 = "{73ABD7C4-0A64-5192-97C3-252B70C8D1B1}" + solution_guid_2 = "{142F0D4F-9896-5808-AAB4-A80F5661B1FE}" + else: + solution_guid_1 = "{73ABD7C4-0A64-5192-97C3-252B70C8D1B1}" + solution_guid_2 = "{142F0D4F-9896-5808-AAB4-A80F5661B1FE}" + + expected_vcprojfile_1 = test.get_expected_projects_proj_file_contents( + vc_version, dirs, project_file_1, project_guid_1, + ) + + expected_vcprojfile_2 = test.get_expected_projects_proj_file_contents( + vc_version, dirs, project_file_2, project_guid_2, + ) + + expected_slnfile = test.get_expected_projects_sln_file_contents( + vc_version, + project_file_1, + project_file_2, + have_solution_project_nodes=True, + autofilter_solution_project_nodes=autofilter_projects, + ) + + expected_slnfile_1 = test.get_expected_sln_file_contents( + vc_version, + project_file_1, + ) + + expected_slnfile_2 = test.get_expected_sln_file_contents( + vc_version, + project_file_2, + ) + + SConstruct_contents = test.get_expected_projects_sconscript_file_contents( + vc_version=vc_version, + project_file_1=project_file_1, + project_file_2=project_file_2, + solution_file=solution_file, + autobuild_solution=1, + autofilter_projects=autofilter_projects, + ) + + test.write('SConstruct', SConstruct_contents) + + if autofilter_projects is None: + test.run(arguments=".", status=2, stderr=r"^.*scons: [*]{3} An msvs solution file was detected in the MSVSSolution 'projects' argument:.+", match=test.match_re_dotall) + continue + + test.run(arguments=".") + + test.must_exist(test.workpath(project_file_1)) + vcproj = test.read(project_file_1, 'r') + expect = test.msvs_substitute(expected_vcprojfile_1, vc_version, None, 'SConstruct', project_guid=project_guid_1) + # don't compare the pickled data + assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) + + test.must_exist(test.workpath(project_file_2)) + vcproj = test.read(project_file_2, 'r') + expect = test.msvs_substitute(expected_vcprojfile_2, vc_version, None, 'SConstruct', project_guid=project_guid_2) + # don't compare the pickled data + assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj) + + test.must_exist(test.workpath(solution_file)) + sln = test.read(solution_file, 'r') + expect = test.msvs_substitute_projects( + expected_slnfile, subdir='src', + solution_guid_1=solution_guid_1, solution_guid_2=solution_guid_2, + ) + # don't compare the pickled data + assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + test.must_exist(test.workpath(solution_file_1)) + sln = test.read(solution_file_1, 'r') + expect = test.msvs_substitute(expected_slnfile_1, vc_version, subdir='src', project_guid=project_guid_1) + # don't compare the pickled data + assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + test.must_exist(test.workpath(solution_file_2)) + sln = test.read(solution_file_2, 'r') + expect = test.msvs_substitute(expected_slnfile_2, vc_version, subdir='src', project_guid=project_guid_2) + # don't compare the pickled data + assert sln[:len(expect)] == expect, test.diff_substr(expect, sln) + + if filters_file_expected: + test.must_exist(test.workpath(filters_file_1)) + test.must_exist(test.workpath(filters_file_2)) + else: + test.must_not_exist(test.workpath(filters_file_1)) + test.must_not_exist(test.workpath(filters_file_2)) # TODO: clean tests |