Mercurial > fife-parpg
comparison build/win32/build_environments/visual_studio_8/generate_unittests.py @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 import sys, os , pythoncom | |
2 | |
3 def main (from_path, to_path): | |
4 # check if the output-folder exists | |
5 if os.path.exists(to_path) == False: | |
6 os.mkdir(to_path); | |
7 | |
8 # traverse the unit_test-files | |
9 files = os.listdir(from_path) | |
10 guidlist=[] | |
11 filelist=[] | |
12 | |
13 for file in files: | |
14 if (file[-4:] == ".cpp"): | |
15 guidlist.append(writeProject(file[0:-4], to_path)) | |
16 filelist.append(file[0:-4].replace("test_", "testprog_")) | |
17 | |
18 writeSolution(to_path, filelist, guidlist) | |
19 | |
20 def writeProject(file, to_path): | |
21 infile = open("unittest_template.xml", "r") | |
22 outfile = open(to_path + "/" + file.replace("test_", "testprog_") + ".vcproj", "w") | |
23 text = infile.read() | |
24 guid = pythoncom.CreateGuid() | |
25 text = text.replace("__INSERT_NAME_HERE__", file.replace("test_", "testprog_")) | |
26 text = text.replace("__INSERT_FILENAME_HERE__", file) | |
27 text = text.replace("__INSERT_GUID_HERE__", str(guid)) | |
28 outfile.write(text) | |
29 return str(guid) | |
30 | |
31 def writeSolution(to_path, namelist, guidlist): | |
32 solution = open(to_path + "/unit_tests.sln", "w") | |
33 | |
34 solution.write("\xef\xbb\xbf\n") # Specify MSVS 2005 | |
35 solution.write("Microsoft Visual Studio Solution File, Format Version 9.00\n") | |
36 solution.write("# Visual Studio 2005\n") | |
37 | |
38 # add the libfife-project | |
39 solution.write("Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"libfife\", \"..\\fife.vcproj\", \"{96025707-5759-400D-80E5-A1E94C8A79A2}\"\n") | |
40 solution.write("EndProject\n") | |
41 | |
42 # Add the test projects: | |
43 for i in range(len(namelist)): | |
44 solution.write("Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" + namelist[i] + "\", \"" + namelist[i] + ".vcproj\", \"" + guidlist[i] + "\"\n") | |
45 solution.write(" ProjectSection(ProjectDependencies) = postProject\n") | |
46 solution.write(" {96025707-5759-400D-80E5-A1E94C8A79A2} = {96025707-5759-400D-80E5-A1E94C8A79A2}\n") | |
47 solution.write(" EndProjectSection\n") | |
48 solution.write("EndProject\n") | |
49 | |
50 solution.write("Global\n") | |
51 solution.write(" GlobalSection(SolutionConfigurationPlatforms) = preSolution\n") | |
52 solution.write(" Debug_static|Win32 = Debug_static|Win32\n") | |
53 solution.write(" Release_static|Win32 = Release_static|Win32\n") | |
54 solution.write(" EndGlobalSection\n") | |
55 solution.write(" GlobalSection(ProjectConfigurationPlatforms) = postSolution\n") | |
56 | |
57 solution.write(" {96025707-5759-400D-80E5-A1E94C8A79A2}.Debug_static|Win32.ActiveCfg = Debug_static|Win32\n") | |
58 solution.write(" {96025707-5759-400D-80E5-A1E94C8A79A2}.Debug_static|Win32.Build.0 = Debug_static|Win32\n") | |
59 solution.write(" {96025707-5759-400D-80E5-A1E94C8A79A2}.Release_static|Win32.ActiveCfg = Release_static|Win32\n") | |
60 solution.write(" {96025707-5759-400D-80E5-A1E94C8A79A2}.Release_static|Win32.Build.0 = Release_static|Win32\n") | |
61 | |
62 for guid in guidlist: | |
63 solution.write(" " + guid + ".Debug|Win32.ActiveCfg = Debug_static|Win32\n") | |
64 solution.write(" " + guid + ".Debug|Win32.Build.0 = Debug_static|Win32\n") | |
65 solution.write(" " + guid + ".Release|Win32.ActiveCfg = Release_static|Win32\n") | |
66 solution.write(" " + guid + ".Release|Win32.Build.0 = Release_static|Win32\n") | |
67 | |
68 solution.write(" EndGlobalSection\n") | |
69 solution.write(" GlobalSection(SolutionProperties) = preSolution\n") | |
70 solution.write(" HideSolutionNode = FALSE\n") | |
71 solution.write(" EndGlobalSection\n") | |
72 solution.write("EndGlobal\n") | |
73 | |
74 # call main function | |
75 main ("../../../../tests/core_tests", "./unit_tests") |