@@ -147,6 +147,16 @@ def test_slnx_no_xml_root(tmpdir):
147147 __test_project_error (tmpdir , "slnx" , content , expected )
148148
149149
150+ def test_slnx_invalid_xml_root (tmpdir ):
151+ content = '<?xml version="1.0" encoding="UTF-8"?>\r \n ' \
152+ "<Invalid>\r \n " \
153+ "</Invalid>\r \n "
154+
155+ expected = "Invalid Visual Studio solution file format"
156+
157+ __test_project_error (tmpdir , "slnx" , content , expected )
158+
159+
150160def test_slnx_no_projects (tmpdir ):
151161 content = '<?xml version="1.0" encoding="UTF-8"?>\r \n ' \
152162 "<Solution>\r \n " \
@@ -161,6 +171,22 @@ def test_slnx_no_projects(tmpdir):
161171 __test_project_error (tmpdir , "slnx" , content , expected )
162172
163173
174+ def test_slnx_no_projects_in_folder (tmpdir ):
175+ content = '<?xml version="1.0" encoding="UTF-8"?>\r \n ' \
176+ "<Solution>\r \n " \
177+ " <Configurations>\r \n " \
178+ ' <Platform Name="x64" />\r \n ' \
179+ ' <Platform Name="x86" />\r \n ' \
180+ " </Configurations>\r \n " \
181+ ' <Folder Name="/common/">\r \n ' \
182+ ' </Folder>\r \n ' \
183+ "</Solution>\r \n "
184+
185+ expected = "no projects found in Visual Studio solution file"
186+
187+ __test_project_error (tmpdir , "slnx" , content , expected )
188+
189+
164190def test_slnx_project_file_not_found (tmpdir ):
165191 content = '<?xml version="1.0" encoding="UTF-8"?>\r \n ' \
166192 "<Solution>\r \n " \
@@ -179,6 +205,26 @@ def test_slnx_project_file_not_found(tmpdir):
179205 __test_project_error (tmpdir , "slnx" , content , expected )
180206
181207
208+ def test_slnx_project_file_in_folder_not_found (tmpdir ):
209+ content = '<?xml version="1.0" encoding="UTF-8"?>\r \n ' \
210+ "<Solution>\r \n " \
211+ " <Configurations>\r \n " \
212+ ' <Platform Name="x64" />\r \n ' \
213+ ' <Platform Name="x86" />\r \n ' \
214+ " </Configurations>\r \n " \
215+ ' <Folder Name="/common/">\r \n ' \
216+ ' <Project Path="common/test.vcxproj" />\r \n ' \
217+ ' </Folder>\r \n ' \
218+ "</Solution>\r \n "
219+
220+ expected = "Visual Studio project file is not a valid XML - XML_ERROR_FILE_NOT_FOUND\n " \
221+ "cppcheck: error: failed to load '{}' from Visual Studio solution" .format (os .path .join (tmpdir , "common/test.vcxproj" ))
222+ if sys .platform == "win32" :
223+ expected = expected .replace ('\\ ' , '/' )
224+
225+ __test_project_error (tmpdir , "slnx" , content , expected )
226+
227+
182228def test_vcxproj_no_xml_root (tmpdir ):
183229 content = '<?xml version="1.0" encoding="utf-8"?>'
184230
0 commit comments