| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Functions
test_cmt2cmake Namespace Reference

## Classes
class | PackWrap
class | ProjWrap

## Functions
def | buildDir
def | getCalls
def | test_not_a_package
def | test_pack_header
def | test_pack_deps
def | test_pack_no_deps
def | test_pack_ext_deps
def | test_install_headers
def | test_install_python
def | test_install_python2
def | test_install_scripts
def | test_qmtest
def | test_libraries
def | test_libraries_2
def | test_libraries_3
def | test_libraries_fix_src_path
def | test_subdir_links
def | test_subdir_links_hat
def | test_subdir_links_missing
def | test_subdir_links_update
def | test_subdir_headers
def | test_subdir_headers_update
def | test_write_file
def | test_write_file_exists
def | test_god_1
def | test_god_2
def | test_god_3
def | test_god_4
def | test_god_5
def | test_god_6
def | test_god_7
def | test_reflex
def | test_reflex_2
def | test_reflex_3
def | test_linkopts
def | test_application
def | test_pyqt_patterns
def | test_line_cont
def | test_line_copy_relax
def | test_project
def | test_data_pkg_1
def | test_data_pkg_2
def | test_data_pkg_3
def | test_heptools_1
def | test_heptools_2
def | test_heptools_3
def | test_heptools_4
def | test_alias

## Function Documentation

def test_cmt2cmake.buildDir | ( |  | files,
|  |  | rootdir = `os.curdir`
| ) |  |

    Create a directory structure from the content of files.

    @param files: a dictionary or list of pairs mapping a filename to the content
                  if the content is a dictionary, recurse
    @param rootdir: base directory

Definition at line 35 of file test_cmt2cmake.py.

35
36 def buildDir(files, rootdir=os.curdir):
37 '''
38 Create a directory structure from the content of files.
39
40 @param files: a dictionary or list of pairs mapping a filename to the content
41 if the content is a dictionary, recurse
42 @param rootdir: base directory
43 '''
44 if type(files) is dict:
45 files = files.items()
46
47 # ensure that the root exists (to allow empty directories)
48 if not os.path.exists(rootdir):
49 os.makedirs(rootdir)
50
51 # create all the entries
52 for filename, data in files:
53 filename = os.path.join(rootdir, filename)
54 if type(data) is dict:
55 buildDir(data, filename)
56 else:
57 d = os.path.dirname(filename)
58 if not os.path.exists(d):
59 os.makedirs(d)
60 f = open(filename, "w")
61 if data:
62 f.write(data)
63 f.close()

def test_cmt2cmake.getCalls | ( |  | function,
|  |  | cmakelists
| ) |  |

    extracts the arguments to all the calls to a cmake function

Definition at line 101 of file test_cmt2cmake.py.

101
102 def getCalls(function, cmakelists):
103 '''
104 extracts the arguments to all the calls to a cmake function
105 '''
106 exp = re.compile(r'\b{0}\s*\(([^)]*)\)'.format(function), flags=re.MULTILINE)
107 return [m.group(1) for m in exp.finditer(cmakelists)]
108
109 #
110 # Tests
111 #

def test_cmt2cmake.test_alias | ( |  | ) |

Definition at line 1435 of file test_cmt2cmake.py.

1435
1436 def test_alias():
1437 requirements = '''
1438 package Test
1439 version v1r0
1440
1441 alias MyCommand "Command"
1442 alias pypaw "pyroot -i "
1443 '''
1444 pkg = PackWrap("Test", requirements, files={})
1445
1446 cmakelists = pkg.generate()
1447 print cmakelists
1448
1449 calls = getCalls("gaudi_alias", cmakelists)
1450 assert len(calls) == 2
1451
1452 calls = sorted([x.strip().split() for x in calls])
1453
1454 assert calls[0] == ['MyCommand', 'Command'], calls[0]
1455
1456 assert calls[1] == ['pypaw', 'pyroot', '-i'], calls[1]
1457

def test_cmt2cmake.test_application | ( |  | ) |

Definition at line 1077 of file test_cmt2cmake.py.

1077
1078 def test_application():
1079 requirements = '''
1080 package Test
1081 version v1r0
1082
1083 application MyApp1 ../src/app1/*.cpp
1084
1085 application MyApp2 -group=tests ../src/app2/*.cpp
1086
1087 application MyApp3 -check ../src/app3/*.cpp
1088
1089 application MyApp4 ../tests/src/app4.cpp
1090
1091 application MyTestApp app5a.cpp app5b.cpp
1092 '''
1093 pkg = PackWrap("Test", requirements, files={})
1094
1095 cmakelists = pkg.generate()
1096 print cmakelists
1097
1098 calls = getCalls("gaudi_add_executable", cmakelists)
1099 assert len(calls) == 5, "gaudi_add_executable wrong count %d" % len(calls)
1100
1101 l = calls[0].strip().split()
1102 assert l[0] == 'MyApp1'
1103 assert l[1:] == ['src/app1/*.cpp']
1104
1105 l = calls[1].strip().split()
1106 assert l[0] == 'MyApp2'
1107 assert l[1:] == ['src/app2/*.cpp']
1108
1109 l = calls[2].strip().split()
1110 assert l[0] == 'MyApp3'
1111 assert l[1:] == ['src/app3/*.cpp']
1112
1113 l = calls[3].strip().split()
1114 assert l[0] == 'MyApp4'
1115 assert l[1:] == ['tests/src/app4.cpp']
1116
1117 l = calls[4].strip().split()
1118 assert l[0] == 'MyTestApp'
1119 assert l[1:] == ['src/app5a.cpp', 'src/app5b.cpp']
1120
1121 calls = getCalls("if", cmakelists)
1122 assert calls == ['GAUDI_BUILD_TESTS'] * 4

def test_cmt2cmake.test_data_pkg_1 | ( |  | ) |

Definition at line 1234 of file test_cmt2cmake.py.

1234
1235 def test_data_pkg_1():
1236 proj_cmt = '''
1237 project TestProject
1238 '''
1239 files = {"TestProjectSys": {"cmt": {"requirements": "version v1r0"}},
1240 "Package1": {"cmt": {"requirements":
1241 '''
1242 version v1r0
1243
1244 use DtPkg v7r* Another
1245 use DataPack v*
1246 use SpecialThing *
1247 '''}},
1248 }
1249 proj = ProjWrap("TestProject", proj_cmt, files=files)
1250
1251 cmakelists = proj.generate()
1252 print cmakelists
1253
1254 calls = getCalls("find_package", cmakelists)
1255 assert len(calls) == 1, "find_package wrong count %d" % len(calls)
1256
1257 l = calls[0].strip().split()
1258 assert l == ['GaudiProject']
1259
1260 calls = getCalls("gaudi_project", cmakelists)
1261 assert len(calls) == 1, "gaudi_project wrong count %d" % len(calls)
1262
1263 l = calls[0].strip().split()
1264 assert l == ['TestProject', 'v1r0', 'DATA',
1265 'Another/DtPkg', 'VERSION', 'v7r*',
1266 'DataPack',
1267 'SpecialThing']

def test_cmt2cmake.test_data_pkg_2 | ( |  | ) |

Definition at line 1268 of file test_cmt2cmake.py.

1268
1269 def test_data_pkg_2():
1270 proj_cmt = '''
1271 project TestProject
1272 '''
1273 files = {"TestProjectSys": {"cmt": {"requirements": "version v1r0"}},
1274 "Package1": {"cmt": {"requirements":
1275 '''
1276 version v1r0
1277
1278 use DataPack v*
1279 '''}},
1280 "Package2": {"cmt": {"requirements":
1281 '''
1282 version v1r0
1283
1284 use SpecialThing *
1285 '''}},
1286 }
1287 proj = ProjWrap("TestProject", proj_cmt, files=files)
1288
1289 cmakelists = proj.generate()
1290 print cmakelists
1291
1292 calls = getCalls("find_package", cmakelists)
1293 assert len(calls) == 1, "find_package wrong count %d" % len(calls)
1294
1295 l = calls[0].strip().split()
1296 assert l == ['GaudiProject']
1297
1298 calls = getCalls("gaudi_project", cmakelists)
1299 assert len(calls) == 1, "gaudi_project wrong count %d" % len(calls)
1300
1301 l = calls[0].strip().split()
1302 assert l == ['TestProject', 'v1r0', 'DATA',
1303 'DataPack',
1304 'SpecialThing']

def test_cmt2cmake.test_data_pkg_3 | ( |  | ) |

Definition at line 1305 of file test_cmt2cmake.py.

1305
1306 def test_data_pkg_3():
1307 proj_cmt = '''
1308 project TestProject
1309 '''
1310 files = {"TestProjectSys": {"cmt": {"requirements": "version v1r0"}},
1311 "Package1": {"cmt": {"requirements":
1312 '''
1313 version v1r0
1314
1315 use DataPack v7r*
1316 '''}},
1317 "Package2": {"cmt": {"requirements":
1318 '''
1319 version v1r0
1320
1321 use DataPack v*
1322 use DtPkg v1r0 Another
1323 '''}},
1324 }
1325 proj = ProjWrap("TestProject", proj_cmt, files=files)
1326
1327 cmakelists = proj.generate()
1328 print cmakelists
1329
1330 calls = getCalls("find_package", cmakelists)
1331 assert len(calls) == 1, "find_package wrong count %d" % len(calls)
1332
1333 l = calls[0].strip().split()
1334 assert l == ['GaudiProject']
1335
1336 calls = getCalls("gaudi_project", cmakelists)
1337 assert len(calls) == 1, "gaudi_project wrong count %d" % len(calls)
1338
1339 l = calls[0].strip().split()
1340 assert l == ['TestProject', 'v1r0', 'DATA',
1341 'Another/DtPkg', 'VERSION', 'v1r0',
1342 'DataPack', 'VERSION', 'v7r*']

def test_cmt2cmake.test_god_1 | ( |  | ) |

Definition at line 731 of file test_cmt2cmake.py.

731
732 def test_god_1():
733 # some corner cases
734 # FIXME: we should actually test the warning messages
735 requirements = '''
736 package Test
737 version v1r0
738
739 apply_pattern god_headers files=../xml/*.xml
740 '''
741 pkg = PackWrap("Test", requirements, files={})
742
743 cmakelists = pkg.generate()
744 print cmakelists
745
746 calls = getCalls("include", cmakelists)
747 assert calls
748 l = calls[0].strip()
749 assert l == 'GaudiObjDesc'
750
751 calls = getCalls("god_build_headers", cmakelists)
752 assert len(calls) == 1, "god_build_headers wrong count %d" % len(calls)
753
754 l = calls[0].strip()
755 assert l == 'xml/*.xml'

def test_cmt2cmake.test_god_2 | ( |  | ) |

Definition at line 756 of file test_cmt2cmake.py.

756
757 def test_god_2():
758 requirements = '''
759 package Test
760 version v1r0
761
762 apply_pattern god_dictionary files=../xml/*.xml
763 '''
764 pkg = PackWrap("Test", requirements, files={})
765
766 cmakelists = pkg.generate()
767 print cmakelists
768
769 calls = getCalls("include", cmakelists)
770 assert calls
771 l = calls[0].strip()
772 assert l == 'GaudiObjDesc'
773
774 calls = getCalls("god_build_dictionary", cmakelists)
775 assert len(calls) == 1, "god_build_dictionary wrong count %d" % len(calls)
776
777 l = calls[0].strip()
778 assert l == 'xml/*.xml'

def test_cmt2cmake.test_god_3 | ( |  | ) |

Definition at line 779 of file test_cmt2cmake.py.

779
780 def test_god_3():
781 requirements = '''
782 package Test
783 version v1r0
784
785 use Boost v* LCG_Interfaces
786
787 apply_pattern god_headers files=../xml/*.xml
788 apply_pattern god_dictionary files=../xml/*.xml
789 '''
790 pkg = PackWrap("Test", requirements, files={})
791
792 cmakelists = pkg.generate()
793 print cmakelists
794
795 calls = getCalls("include", cmakelists)
796 assert calls
797 l = calls[0].strip()
798 assert l == 'GaudiObjDesc'
799
800 calls = getCalls("god_build_headers", cmakelists)
801 assert len(calls) == 1, "god_build_headers wrong count %d" % len(calls)
802
803 calls = getCalls("god_build_dictionary", cmakelists)
804 assert len(calls) == 1, "god_build_dictionary wrong count %d" % len(calls)
805
806 l = calls[0].strip().split()
807 assert l[0] == 'xml/*.xml'
808 assert 'LINK_LIBRARIES' in l
809 assert l[l.index('LINK_LIBRARIES')+1] == 'Boost'
810 assert 'INCLUDE_DIRS' in l
811 assert l[l.index('INCLUDE_DIRS')+1] == 'Boost'

def test_cmt2cmake.test_god_4 | ( |  | ) |

Definition at line 812 of file test_cmt2cmake.py.

812
813 def test_god_4():
814 requirements = '''
815 package Test
816 version v1r0
817
818 use Boost v* LCG_Interfaces
819
820 library Lib *.cpp
821 apply_pattern linker_library library=Lib
822
823 apply_pattern god_headers files=../xml/*.xml
824 apply_pattern god_dictionary files=../xml/*.xml
825 '''
826 pkg = PackWrap("Test", requirements, files={})
827
828 cmakelists = pkg.generate()
829 print cmakelists
830
831 calls = getCalls("include", cmakelists)
832 assert calls
833 l = calls[0].strip()
834 assert l == 'GaudiObjDesc'
835
836 calls = getCalls("god_build_headers", cmakelists)
837 assert len(calls) == 1, "god_build_headers wrong count %d" % len(calls)
838
839 calls = getCalls("gaudi_add_library", cmakelists)
840 assert len(calls) == 1, "gaudi_add_library wrong count %d" % len(calls)
841
842 calls = getCalls("god_build_dictionary", cmakelists)
843 assert len(calls) == 1, "god_build_dictionary wrong count %d" % len(calls)
844
845 l = calls[0].strip().split()
846 assert l[0] == 'xml/*.xml'
847 assert 'LINK_LIBRARIES' in l
848 i = l.index('LINK_LIBRARIES')+1
849 assert l[i:i+2] == ['Boost', 'Lib']
850 assert 'INCLUDE_DIRS' in l
851 assert l[l.index('INCLUDE_DIRS')+1] == 'Boost'
852
853 hdr = cmakelists.find('god_build_headers')
854 lib = cmakelists.find('gaudi_add_library')
855 dct = cmakelists.find('god_build_dictionary')
856 assert hdr < lib and lib < dct, "wrong order of calls"

def test_cmt2cmake.test_god_5 | ( |  | ) |

Definition at line 857 of file test_cmt2cmake.py.

857
858 def test_god_5():
859 requirements = '''
860 package Test
861 version v1r0
862
863 apply_pattern god_headers files=../xml/*.xml
864 macro TestObj2Doth_GODflags " -s ../Test/ "
865 '''
866 pkg = PackWrap("Test", requirements, files={})
867
868 cmakelists = pkg.generate()
869 print cmakelists
870
871 calls = getCalls("include", cmakelists)
872 assert calls
873 l = calls[0].strip()
874 assert l == 'GaudiObjDesc'
875
876 calls = getCalls("god_build_headers", cmakelists)
877 assert len(calls) == 1, "god_build_headers wrong count %d" % len(calls)
878
879 l = calls[0].strip().split()
880 assert l[0] == 'xml/*.xml'
881 assert 'DESTINATION' in l
882 assert l[l.index('DESTINATION')+1] == 'Test'

def test_cmt2cmake.test_god_6 | ( |  | ) |

Definition at line 883 of file test_cmt2cmake.py.

883
884 def test_god_6():
885 requirements = '''
886 package Test
887 version v1r0
888
889 apply_pattern god_headers files=../xml/*.xml
890 macro TestObj2Doth_GODflags " -s ../src/ "
891 '''
892 pkg = PackWrap("Test", requirements, files={})
893
894 cmakelists = pkg.generate()
895 print cmakelists
896
897 calls = getCalls("include", cmakelists)
898 assert calls
899 l = calls[0].strip()
900 assert l == 'GaudiObjDesc'
901
902 calls = getCalls("god_build_headers", cmakelists)
903 assert len(calls) == 1, "god_build_headers wrong count %d" % len(calls)
904
905 l = calls[0].strip().split()
906 assert l[0] == 'xml/*.xml'
907 assert 'PRIVATE' in l
908 assert 'DESTINTAION' not in l

def test_cmt2cmake.test_god_7 | ( |  | ) |

Definition at line 909 of file test_cmt2cmake.py.

909
910 def test_god_7():
911 requirements = '''
912 package Test
913 version v1r0
914
915 document customdict TestCustomDict ../dict/TestCustomDict.h
916
917 apply_pattern god_dictionary files=../xml/*.xml
918 '''
919 pkg = PackWrap("Test", requirements, files={})
920
921 cmakelists = pkg.generate()
922 print cmakelists
923
924 calls = getCalls("include", cmakelists)
925 assert calls
926 l = calls[0].strip()
927 assert l == 'GaudiObjDesc'
928
929 calls = getCalls("god_build_dictionary", cmakelists)
930 assert len(calls) == 1, "god_build_dictionary wrong count %d" % len(calls)
931
932 l = calls[0].strip().split()
933 assert l == ['xml/*.xml', 'EXTEND', 'dict/TestCustomDict.h']

def test_cmt2cmake.test_heptools_1 | ( |  | ) |

Definition at line 1343 of file test_cmt2cmake.py.

1343
1344 def test_heptools_1():
1345 # check the case of LCGCMT in the project.cmt
1346 proj_cmt = '''
1347 project TestProjectHT
1348
1349 use LCGCMT LCGCMT_64a
1350 '''
1351 files = {"TestProjectHTSys": {"cmt": {"requirements": "version v1r0"}}}
1352 proj = ProjWrap("TestProjectHT", proj_cmt, files=files)
1353
1354 k = repr(('TestProjectHT', 'v1r0'))
1355 assert k not in cmt2cmake.cache
1356
1357 toolchain = proj.generateToolchain()
1358 print toolchain
1359
1360 calls = getCalls("set", toolchain)
1361 assert len(calls) == 2, "set wrong count %d" % len(calls)
1362
1363 l = calls[0].strip().split()
1364 assert l == ['heptools_version', '64a']
1365
1366 assert k in cmt2cmake.cache
1367 assert cmt2cmake.cache[k] == {'heptools': '64a'}

def test_cmt2cmake.test_heptools_2 | ( |  | ) |

Definition at line 1368 of file test_cmt2cmake.py.

1368
1369 def test_heptools_2():
1370 # check the case of LCGCMT in a used project (already in the cache)
1371 proj_cmt = '''
1372 project TestProjectHT
1373
1374 use BASEPROJECT BASEPROJECT_v1r0
1375 '''
1376 files = {"TestProjectHTSys": {"cmt": {"requirements": "version v2r0"}}}
1377 proj = ProjWrap("TestProjectHT", proj_cmt, files=files)
1378
1379 k = repr(('TestProjectHT', 'v2r0'))
1380 assert k not in cmt2cmake.cache
1381
1382 toolchain = proj.generateToolchain()
1383 print toolchain
1384
1385 calls = getCalls("set", toolchain)
1386 assert len(calls) == 2, "set wrong count %d" % len(calls)
1387
1388 l = calls[0].strip().split()
1389 assert l == ['heptools_version', '65']
1390
1391 assert k in cmt2cmake.cache
1392 assert cmt2cmake.cache[k] == {'heptools': '65'}

def test_cmt2cmake.test_heptools_3 | ( |  | ) |

Definition at line 1393 of file test_cmt2cmake.py.

1393
1394 def test_heptools_3():
1395 # check the case of LCGCMT not declared, but in the cache for us
1396 proj_cmt = '''
1397 project TestProjectHT
1398 '''
1399 files = {"TestProjectHTSys": {"cmt": {"requirements": "version v3r0"}}}
1400 proj = ProjWrap("TestProjectHT", proj_cmt, files=files)
1401
1402 k = repr(('TestProjectHT', 'v3r0'))
1403 assert k in cmt2cmake.cache
1404
1405 toolchain = proj.generateToolchain()
1406 print toolchain
1407
1408 calls = getCalls("set", toolchain)
1409 assert len(calls) == 2, "set wrong count %d" % len(calls)
1410
1411 l = calls[0].strip().split()
1412 assert l == ['heptools_version', '23']
1413
1414 assert k in cmt2cmake.cache
1415 assert cmt2cmake.cache[k] == {'heptools': '23'}

def test_cmt2cmake.test_heptools_4 | ( |  | ) |

Definition at line 1416 of file test_cmt2cmake.py.

1416
1417 def test_heptools_4():
1418 # check the case of LCGCMT not found
1419 proj_cmt = '''
1420 project TestProjectHT
1421 '''
1422 files = {"TestProjectHTSys": {"cmt": {"requirements": "version v4r0"}}}
1423 proj = ProjWrap("TestProjectHT", proj_cmt, files=files)
1424
1425 k = repr(('TestProjectHT', 'v4r0'))
1426 assert k not in cmt2cmake.cache
1427
1428 toolchain = proj.generateToolchain()
1429 assert toolchain is None
1430
1431 assert k not in cmt2cmake.cache
1432
1433
1434

def test_cmt2cmake.test_install_headers | ( |  | ) |

Definition at line 216 of file test_cmt2cmake.py.

216
217 def test_install_headers():
218 requirements = '''
219 #============================================================================
220 package Tell1Kernel
221 version v1r12p1
222
223 # Structure, i.e. directories to process.
224 #============================================================================
225 branches cmt doc Tell1Kernel
226
227 # Used packages
228 #============================================================================
229 use GaudiPolicy v*
230
231 apply_pattern install_more_includes more=Tell1Kernel
232 '''
233 pkg = PackWrap("Tell1Kernel", requirements, files={"Tell1Kernel/hdr.h": None})
234
235 cmakelists = pkg.generate()
236 print cmakelists
237
238 calls = getCalls("gaudi_install_headers", cmakelists)
239 assert calls
240
241 args = set()
242 for call in calls:
243 args.update(call.strip().split())
244 expected = set(['Tell1Kernel'])
245 assert args == expected

def test_cmt2cmake.test_install_python | ( |  | ) |

Definition at line 246 of file test_cmt2cmake.py.

246
247 def test_install_python():
248 requirements = '''
249 package Test
250 version v1r0
251
252 apply_pattern install_python_modules
253 '''
254 pkg = PackWrap("Test", requirements, files={"python/Test/__init__.py": None})
255
256 cmakelists = pkg.generate()
257 print cmakelists
258
259 calls = getCalls("gaudi_install_python_modules", cmakelists)
260 assert calls

def test_cmt2cmake.test_install_python2 | ( |  | ) |

Definition at line 261 of file test_cmt2cmake.py.

261
262 def test_install_python2():
263 requirements = '''
264 package Test
265 version v1r0
266
267 macro TestConfUserModules "Test.CustomModule1 Test.CustomModule2"
268
269 apply_pattern install_python_modules
270 '''
271 pkg = PackWrap("Test", requirements, files={"python/Test/__init__.py": None})
272
273 cmakelists = pkg.generate()
274 print cmakelists
275
276 calls = getCalls("gaudi_install_python_modules", cmakelists)
277 assert calls
278
279 calls = getCalls("set_property", cmakelists)
280 assert calls
281 args = calls[0].strip().split()
282 assert args == ['DIRECTORY', 'PROPERTY', 'CONFIGURABLE_USER_MODULES', 'Test.CustomModule1', 'Test.CustomModule2'], args

def test_cmt2cmake.test_install_scripts | ( |  | ) |

Definition at line 283 of file test_cmt2cmake.py.

283
284 def test_install_scripts():
285 requirements = '''
286 package Test
287 version v1r0
288
289 apply_pattern install_scripts
290 '''
291 pkg = PackWrap("Test", requirements, files={"scripts/someScript": None})
292
293 cmakelists = pkg.generate()
294 print cmakelists
295
296 calls = getCalls("gaudi_install_scripts", cmakelists)
297 assert calls

def test_cmt2cmake.test_libraries | ( |  | ) |

Definition at line 317 of file test_cmt2cmake.py.

317
318 def test_libraries():
319 requirements = '''
320 package Test
321 version v1r0
322
323 library TestLib lib/*.cpp
324 apply_pattern linker_library library=TestLib
325
326 library TestComp component/*.cpp
327 apply_pattern component_library library=TestComp
328
329 library TestTestLib test/lib/*.cpp -group=tests
330 apply_pattern linker_library library=TestTestLib
331
332 library TestTestComp test/component/*.cpp -group=tests
333 apply_pattern component_library library=TestTestComp
334
335 apply_pattern install_more_includes more=TestIncludes
336 '''
337 pkg = PackWrap("Test", requirements, files={'TestIncludes': {}})
338
339 print 'components', pkg.component_libraries
340 print 'linker', pkg.linker_libraries
341 print 'libraries', pkg.libraries
342
343 assert pkg.component_libraries == set(['TestComp', 'TestTestComp'])
344 assert pkg.linker_libraries == set(['TestLib', 'TestTestLib'])
345 assert pkg.libraries
346
347 cmakelists = pkg.generate()
348 print cmakelists
349
350 calls = getCalls("gaudi_add_library", cmakelists)
351 assert len(calls) == 2, "gaudi_add_library wrong count %d" % len(calls)
352 l = calls[0]
353 assert re.match(r' *TestLib\b', l)
354 assert re.search(r'\bPUBLIC_HEADERS +TestIncludes', l)
355 l = calls[1]
356 assert re.match(r' *TestTestLib\b', l)
357 assert re.search(r'\bPUBLIC_HEADERS +TestIncludes', l)
358 assert re.search(r'\bLINK_LIBRARIES +TestLib', l)
359
360 calls = getCalls("gaudi_add_module", cmakelists)
361 assert len(calls) == 2, "gaudi_add_module wrong count %d" % len(calls)
362
363 l = calls[0]
364 assert re.match(r' *TestComp\b', l)
365 assert not re.search(r'\bPUBLIC_HEADERS\b', l)
366 assert re.search(r'\bLINK_LIBRARIES +TestLib', l)
367 l = calls[1]
368 assert re.match(r' *TestTestComp\b', l)
369 assert not re.search(r'\bPUBLIC_HEADERS', l)
370 assert re.search(r'\bLINK_LIBRARIES +TestLib +TestTestLib', l)

def test_cmt2cmake.test_libraries_2 | ( |  | ) |

Definition at line 371 of file test_cmt2cmake.py.

371
372 def test_libraries_2():
373 requirements = '''
374 package Test
375 version v1r0
376
377 use Boost v* LCG_Interfaces
378 use XercesC v* LCG_Interfaces -no_auto_imports
379
380 library Lib1 lib1/*.cpp
381 apply_pattern component_library library=Lib1
382
383 library Lib2 lib2/*.cpp -import=XercesC
384 apply_pattern component_library library=Lib2
385
386 # We do not use variables
387 library Lib3 lib3/*.cpp a_variable=some_value
388 apply_pattern component_library library=Lib3
389
390 # test that we can handle the '-import' before the sources
391 library Lib4 -import=XercesC lib4/*.cpp
392 apply_pattern component_library library=Lib4
393 '''
394 pkg = PackWrap("Test", requirements, files={})
395
396 print 'components', pkg.component_libraries
397 print 'libraries', pkg.libraries
398
399 assert pkg.component_libraries == set(['Lib1', 'Lib2', 'Lib3', 'Lib4'])
400 assert pkg.libraries
401
402 cmakelists = pkg.generate()
403 print cmakelists
404
405 calls = getCalls("gaudi_add_module", cmakelists)
406 assert len(calls) == 4, "gaudi_add_module wrong count %d" % len(calls)
407
408 l = calls[0]
409 assert re.match(r' *Lib1\b', l)
410 assert not re.search(r'\bPUBLIC_HEADERS\b', l)
411 assert re.search(r'\bLINK_LIBRARIES +Boost', l)
412 assert re.search(r'\bINCLUDE_DIRS +Boost', l)
413 l = calls[1]
414 assert re.match(r' *Lib2\b', l)
415 assert not re.search(r'\bPUBLIC_HEADERS', l)
416 assert re.search(r'\bLINK_LIBRARIES +Boost +XercesC', l)
417 assert re.search(r'\bINCLUDE_DIRS +Boost +XercesC', l)
418 l = calls[2]
419 assert re.match(r' *Lib3\b', l)
420 assert not re.search(r'\bPUBLIC_HEADERS', l)
421 assert re.search(r'\bLINK_LIBRARIES +Boost', l)
422 assert re.search(r'\bINCLUDE_DIRS +Boost', l)
423 l = calls[3]
424 assert re.match(r' *Lib4\b', l)
425 assert not re.search(r'\bPUBLIC_HEADERS', l)
426 assert re.search(r'\bLINK_LIBRARIES +Boost +XercesC', l)
427 assert re.search(r'\bINCLUDE_DIRS +Boost +XercesC', l)

def test_cmt2cmake.test_libraries_3 | ( |  | ) |

Definition at line 428 of file test_cmt2cmake.py.

428
429 def test_libraries_3():
430 # some corner cases
431 # FIXME: we should actually test the warning messages
432 requirements = '''
433 package Test
434 version v1r0
435
436 library Lib1
437 apply_pattern component_library library=Lib1
438
439 library Lib2 lib2/*.cpp
440 apply_pattern linker_library library=Lib2
441
442 library Lib3 lib3/*.cpp
443
444 library Lib4 lib4/*.cpp
445 apply_pattern linker_library library="Lib4"
446
447 '''
448 pkg = PackWrap("Test", requirements, files={})
449
450 print 'components', pkg.component_libraries
451 print 'linker', pkg.linker_libraries
452 print 'libraries', pkg.libraries
453
454 assert pkg.component_libraries == set(['Lib1'])
455 assert pkg.linker_libraries == set(['Lib2', 'Lib4'])
456 assert len(pkg.libraries) == 4
457
458 cmakelists = pkg.generate()
459 print cmakelists
460
461 calls = getCalls("gaudi_add_module", cmakelists)
462 assert len(calls) == 1, "gaudi_add_module wrong count %d" % len(calls)
463
464 l = calls[0]
465 assert re.match(r' *Lib1\b', l)
466 assert not re.search(r'\bPUBLIC_HEADERS\b', l)
467
468 calls = getCalls("gaudi_add_library", cmakelists)
469 assert len(calls) == 3, "gaudi_add_module wrong count %d" % len(calls)
470
471 l = calls[0]
472 assert re.match(r' *Lib2\b', l)
473 assert re.search(r'\bNO_PUBLIC_HEADERS', l)
474
475 l = calls[1]
476 assert re.match(r' *Lib3\b', l)
477 assert re.search(r'\bNO_PUBLIC_HEADERS', l)
478
479 l = calls[2]
480 assert re.match(r' *Lib4\b', l)
481 assert re.search(r'\bNO_PUBLIC_HEADERS', l)

def test_cmt2cmake.test_libraries_fix_src_path | ( |  | ) |

Definition at line 482 of file test_cmt2cmake.py.

482
483 def test_libraries_fix_src_path():
484 requirements = '''
485 package Test
486 version v1r0
487
488 library TestLib1 ../src/subdir/*.cpp
489 apply_pattern linker_library library=TestLib1
490
491 library TestLib2 ../tests/src/subdir/*.cpp
492 apply_pattern linker_library library=TestLib2
493
494 library TestLib3 subdir/*.cpp
495 apply_pattern linker_library library=TestLib3
496 '''
497 pkg = PackWrap("Test", requirements, files={'TestIncludes': {}})
498
499 assert pkg.linker_libraries == set(['TestLib1', 'TestLib2', 'TestLib3'])
500
501 cmakelists = pkg.generate()
502 print cmakelists
503
504 calls = getCalls("gaudi_add_library", cmakelists)
505 assert len(calls) == 3, "gaudi_add_library wrong count %d" % len(calls)
506
507 l = calls[0].strip().split()
508 assert l[0] == 'TestLib1'
509 assert l[1] == 'src/subdir/*.cpp'
510
511 l = calls[1].strip().split()
512 assert l[0] == 'TestLib2'
513 assert l[1] == 'tests/src/subdir/*.cpp'
514
515 l = calls[2].strip().split()
516 assert l[0] == 'TestLib3'
517 assert l[1] == 'src/subdir/*.cpp'

def test_cmt2cmake.test_line_cont | ( |  | ) |

Definition at line 1153 of file test_cmt2cmake.py.

1153
1154 def test_line_cont():
1155 requirements = '''
1156 package Test
1157 version v1r0
1158
1159 library Test *.ccp
1160
1161 macro TEST "value" \\
1162
1163 apply_pattern component_library library=Test
1164 '''
1165 pkg = PackWrap("Test", requirements, files={})
1166
1167 cmakelists = pkg.generate()
1168 print cmakelists
1169
1170 calls = getCalls("gaudi_add_module", cmakelists)
1171 assert len(calls) == 1, "gaudi_add_module wrong count %d" % len(calls)
1172

def test_cmt2cmake.test_line_copy_relax | ( |  | ) |

Definition at line 1173 of file test_cmt2cmake.py.

1173
1174 def test_line_copy_relax():
1175 requirements = '''
1176 package Test
1177 version v1r0
1178
1179 use RELAX v* LCG_Interfaces
1180
1181 copy_relax_rootmap dict=CLHEP
1182 copy_relax_rootmap dict=HepMC
1183 copy_relax_rootmap dict=STL
1184 copy_relax_rootmap dict=Math
1185 '''
1186 pkg = PackWrap("Test", requirements, files={})
1187
1188 cmakelists = pkg.generate()
1189 print cmakelists
1190
1191 calls = getCalls("find_package", cmakelists)
1192 assert len(calls) == 1, "find_package wrong count %d" % len(calls)
1193
1194 l = calls[0].strip().split()
1195 assert l == ['RELAX', 'REQUIRED', 'COMPONENTS', 'CLHEP', 'HepMC', 'STL', 'Math']
1196
1197 calls = getCalls("add_custom_target", cmakelists)
1198 assert len(calls) == 1, "add_custom_target wrong count %d" % len(calls)
1199
1200 l = calls[0].strip().split()
1201 assert l == ['RelaxRootmap', 'ALL', 'DEPENDS', '${rootmapfile}']
1202
1203 # No need to check every call, just that the sequence is there
1204

def test_cmt2cmake.test_linkopts | ( |  | ) |

Definition at line 1051 of file test_cmt2cmake.py.

1051
1052 def test_linkopts():
1053 requirements = '''
1054 package Test
1055 version v1r0
1056
1057 use ROOT v* LCG_Interfaces
1058 use Boost v* LCG_Interfaces
1059
1060 macro_append ROOT_linkopts " -lMathCore"
1061 macro_append Boost_linkopts " $(Boost_linkopts_filesystem)"
1062
1063 '''
1064 pkg = PackWrap("Test", requirements, files={})
1065
1066 cmakelists = pkg.generate()
1067 print cmakelists
1068
1069 calls = getCalls("find_package", cmakelists)
1070 assert len(calls) == 2, "find_package wrong count %d" % len(calls)
1071
1072 l = calls[0].strip().split()
1073 assert l == ['Boost', 'COMPONENTS', 'filesystem'] # find_package are sorted
1074
1075 l = calls[1].strip().split()
1076 assert l == ['ROOT', 'COMPONENTS', 'MathCore'] # find_package are sorted

def test_cmt2cmake.test_not_a_package | ( |  | ) |

Definition at line 112 of file test_cmt2cmake.py.

112
113 def test_not_a_package():
114 d = mkdtemp()
115 buildDir({'NoPackage': {'a_file.txt': None}}, d)
116 try:
117 cmt2cmake.Package(os.path.join(d, 'NoPackage'))
118 assert False, 'bad package not recognized'
119 except ValueError:
120 pass
121 finally:
122 shutil.rmtree(d)
123

def test_cmt2cmake.test_pack_deps | ( |  | ) |

Definition at line 145 of file test_cmt2cmake.py.

145
146 def test_pack_deps():
147 requirements = """
148 package Test
149 version v1r0
150
151 # series of uses
152 use GaudiKernel v*
153 use GaudiAlg *
154 use GaudiPolicy *
155 use GaudiCoreSvc v* # comment
156 use GaudiUtils * -no_auto_imports
157
158 use LHCbKernel v* Kernel
159 """
160 pkg = PackWrap("Test", requirements)
161
162 cmakelists = pkg.generate()
163 print cmakelists
164
165 calls = getCalls("gaudi_depends_on_subdirs", cmakelists)
166 assert calls, "gaudi_depends_on_subdirs not called"
167
168 args = set()
169 for call in calls:
170 args.update(call.strip().split())
171 expected = set(['GaudiKernel', 'GaudiAlg', 'GaudiCoreSvc',
172 'GaudiUtils', 'Kernel/LHCbKernel'])
173 assert args == expected

def test_cmt2cmake.test_pack_ext_deps | ( |  | ) |

Definition at line 189 of file test_cmt2cmake.py.

189
190 def test_pack_ext_deps():
191 requirements = """
192 package Test
193 version v1r0
194
195 # series of uses
196 use Boost v* LCG_Interfaces
197 use Python v* LCG_Interfaces
198 use XercesC v* LCG_Interfaces -no_auto_imports
199 """
200 pkg = PackWrap("Test", requirements)
201
202 cmakelists = pkg.generate()
203 print cmakelists
204
205 expected = set(['Boost', 'XercesC'])
206
207 calls = getCalls("find_package", cmakelists)
208 assert calls, "find_pacakge not called"
209 assert len(calls) == len(expected)
210
211 args = set()
212 for call in calls:
213 args.add(call.strip().split()[0])
214 print args
215 assert args == expected

def test_cmt2cmake.test_pack_header | ( |  | ) |

Definition at line 124 of file test_cmt2cmake.py.

124
125 def test_pack_header():
126 requirements = """
127 package ThisIsAPackage
128 version v123r456
129
130 branches cmt branches are ignored
131 macro test parsing of \\
132 multi line
133 """
134 pkg = PackWrap("ThisIsAPackage", requirements)
135
136 cmakelists = pkg.generate()
137 print cmakelists
138
139 calls = getCalls("gaudi_subdir", cmakelists)
140 assert calls, "gaudi_subdir not called"
141 assert len(calls) == 1, "gaudi_subdir called more than once"
142
143 args = calls[0].strip().split()
144 assert args == ["ThisIsAPackage", "v123r456"], args

def test_cmt2cmake.test_pack_no_deps | ( |  | ) |

Definition at line 174 of file test_cmt2cmake.py.

174
175 def test_pack_no_deps():
176 requirements = """
177 package Test
178 version v1r0
179
180 # no uses
181 """
182 pkg = PackWrap("Test", requirements)
183
184 cmakelists = pkg.generate()
185 print cmakelists
186
187 calls = getCalls("gaudi_depends_on_subdirs", cmakelists)
188 assert not calls, "gaudi_depends_on_subdirs called"

def test_cmt2cmake.test_project | ( |  | ) |

Definition at line 1205 of file test_cmt2cmake.py.

1205
1206 def test_project():
1207 proj_cmt = '''
1208 project LHCB
1209
1210 use GAUDI GAUDI_v23r4
1211 use DBASE
1212 use PARAM
1213
1214 build_strategy with_installarea
1215 setup_strategy root
1216 '''
1217 files = {"LHCbSys": {"cmt": {"requirements": "version v35r2"}}}
1218 proj = ProjWrap("LHCb", proj_cmt, files=files)
1219
1220 cmakelists = proj.generate()
1221 print cmakelists
1222
1223 calls = getCalls("find_package", cmakelists)
1224 assert len(calls) == 1, "find_package wrong count %d" % len(calls)
1225
1226 l = calls[0].strip().split()
1227 assert l == ['GaudiProject']
1228
1229 calls = getCalls("gaudi_project", cmakelists)
1230 assert len(calls) == 1, "gaudi_project wrong count %d" % len(calls)
1231
1232 l = calls[0].strip().split()
1233 assert l == ['LHCb', 'v35r2', 'USE', 'Gaudi', 'v23r4']

def test_cmt2cmake.test_pyqt_patterns | ( |  | ) |

Definition at line 1123 of file test_cmt2cmake.py.

1123
1124 def test_pyqt_patterns():
1125 requirements = '''
1126 package Test
1127 version v1r0
1128
1129 use pygraphics v* LCG_Interfaces -no_auto_imports
1130 use Qt v* LCG_Interfaces -no_auto_imports
1131
1132 apply_pattern install_python_modules
1133
1134 apply_pattern PyQtResource qrc_files=../qt_resources/*.qrc outputdir=../python/Test/QtApp
1135 apply_pattern PyQtUIC ui_files=../qt_resources/*.ui outputdir=../python/Test/QtApp
1136 macro_append Test_python_dependencies " PyQtResource PyQtUIC "
1137 '''
1138 pkg = PackWrap("Test", requirements, files={})
1139
1140 cmakelists = pkg.generate()
1141 print cmakelists
1142
1143 calls = getCalls("gen_pyqt_resource", cmakelists)
1144 assert len(calls) == 1, "gen_pyqt_resource wrong count %d" % len(calls)
1145 l = calls[0].strip().split()
1146 assert l == ['Test.QtApp.Resources', 'Test/QtApp', 'qt_resources/*.qrc']
1147
1148 calls = getCalls("gen_pyqt_uic", cmakelists)
1149 assert len(calls) == 1, "gen_pyqt_uic wrong count %d" % len(calls)
1150 l = calls[0].strip().split()
1151 assert l == ['Test.QtApp.UI', 'Test/QtApp', 'qt_resources/*.ui']
1152

def test_cmt2cmake.test_qmtest | ( |  | ) |

Definition at line 298 of file test_cmt2cmake.py.

298
299 def test_qmtest():
300 requirements = '''
301 package Test
302 version v1r0
303
304 apply_pattern QMTest
305 '''
306 pkg = PackWrap("Test", requirements, files={"tests/qmtest/test.qms/a_test.qmt": None})
307
308 cmakelists = pkg.generate()
309 print cmakelists
310
311 calls = getCalls("gaudi_add_test", cmakelists)
312 assert calls, "no test added"
313 assert len(calls) == 1, "gaudi_add_test called more than once"
314
315 args = calls[0].strip().split()
316 assert args == ["QMTest", "QMTEST"]

def test_cmt2cmake.test_reflex | ( |  | ) |

Definition at line 934 of file test_cmt2cmake.py.

934
935 def test_reflex():
936 requirements = '''
937 package Test
938 version v1r0
939
940 use ROOT v* LCG_Interfaces
941
942 apply_pattern reflex_dictionary \\
943 dictionary=Test \\
944 headerfiles=$(TESTROOT)/dict/TestDict.h \\
945 selectionfile=$(TESTROOT)/dict/TestDict.xml
946
947 apply_pattern reflex_dictionary \\
948 dictionary=Test2 \\
949 headerfiles=$(TESTROOT)/dict/Test2Dict.h \\
950 selectionfile=$(TESTROOT)/dict/Test2Dict.xml \\
951 options="-DOPTION"
952 '''
953 pkg = PackWrap("Test", requirements, files={})
954
955 cmakelists = pkg.generate()
956 print cmakelists
957
958 calls = getCalls("gaudi_add_dictionary", cmakelists)
959 assert len(calls) == 2, "gaudi_add_dictionary wrong count %d" % len(calls)
960
961 l = calls[0].strip().split()
962 assert l[0:3] == ['Test', 'dict/TestDict.h', 'dict/TestDict.xml']
963 assert 'LINK_LIBRARIES' in l
964 assert l[l.index('LINK_LIBRARIES')+1] == 'ROOT'
965 assert 'INCLUDE_DIRS' in l
966 assert l[l.index('INCLUDE_DIRS')+1] == 'ROOT'
967
968 l = calls[1].strip().split()
969 assert l[0:3] == ['Test2', 'dict/Test2Dict.h', 'dict/Test2Dict.xml']
970 assert 'LINK_LIBRARIES' in l
971 assert l[l.index('LINK_LIBRARIES')+1] == 'ROOT'
972 assert 'INCLUDE_DIRS' in l
973 assert l[l.index('INCLUDE_DIRS')+1] == 'ROOT'
974 assert 'OPTIONS' in l
975 assert l[l.index('OPTIONS')+1:] == ['"-DOPTION"']
976

def test_cmt2cmake.test_reflex_2 | ( |  | ) |

Definition at line 977 of file test_cmt2cmake.py.

977
978 def test_reflex_2():
979 requirements = '''
980 package Test
981 version v1r0
982
983 use ROOT v* LCG_Interfaces
984
985 library Test *.ccp
986 apply_pattern component_library library=Test
987
988 apply_pattern reflex_dictionary \\
989 dictionary=Test \\
990 headerfiles=$(TESTROOT)/dict/TestDict.h \\
991 selectionfile=$(TESTROOT)/dict/TestDict.xml
992 '''
993 pkg = PackWrap("Test", requirements, files={})
994
995 cmakelists = pkg.generate()
996 print cmakelists
997
998 calls = getCalls("gaudi_add_module", cmakelists)
999 assert len(calls) == 1, "gaudi_add_module wrong count %d" % len(calls)
1000
1001 l = calls[0].strip().split()
1002 assert l[0] == 'Test'
1003
1004 calls = getCalls("gaudi_add_dictionary", cmakelists)
1005 assert len(calls) == 1, "gaudi_add_dictionary wrong count %d" % len(calls)
1006
1007 l = calls[0].strip().split()
1008 assert l[0:3] == ['Test', 'dict/TestDict.h', 'dict/TestDict.xml']

def test_cmt2cmake.test_reflex_3 | ( |  | ) |

Definition at line 1009 of file test_cmt2cmake.py.

1009
1010 def test_reflex_3():
1011 requirements = '''
1012 package Test
1013 version v1r0
1014
1015 use ROOT v* LCG_Interfaces
1016 use COOL v* LCG_Interfaces -no_auto_imports
1017 use CORAL v* LCG_Interfaces -no_auto_imports
1018 use Boost v* LCG_Interfaces -no_auto_imports
1019
1020 library Test *.ccp
1021 apply_pattern component_library library=Test
1022
1023 apply_pattern reflex_dictionary \\
1024 dictionary=Test \\
1025 headerfiles=$(TESTROOT)/dict/TestDict.h \\
1026 selectionfile=$(TESTROOT)/dict/TestDict.xml \\
1027 imports="COOL -import=CORAL -import=Boost"
1028 '''
1029 pkg = PackWrap("Test", requirements, files={})
1030
1031 cmakelists = pkg.generate()
1032 print cmakelists
1033
1034 calls = getCalls("gaudi_add_module", cmakelists)
1035 assert len(calls) == 1, "gaudi_add_module wrong count %d" % len(calls)
1036
1037 l = calls[0].strip().split()
1038 assert l[0] == 'Test'
1039
1040 calls = getCalls("gaudi_add_dictionary", cmakelists)
1041 assert len(calls) == 1, "gaudi_add_dictionary wrong count %d" % len(calls)
1042
1043 l = calls[0].strip().split()
1044 assert l[0:3] == ['Test', 'dict/TestDict.h', 'dict/TestDict.xml']
1045 assert 'INCLUDE_DIRS' in l
1046 i = l.index('INCLUDE_DIRS')
1047 assert 'LINK_LIBRARIES' in l
1048 j = l.index('LINK_LIBRARIES')
1049 assert set(l[i+1:j]) == set(['ROOT', 'COOL', 'CORAL', 'Boost'])
1050 assert set(l[j+1:]) == set(['ROOT', 'COOL', 'CORAL', 'Boost'])

def test_cmt2cmake.test_subdir_headers | ( |  | ) |

Definition at line 654 of file test_cmt2cmake.py.

654
655 def test_subdir_headers():
656 if 'GaudiDummy' in cmt2cmake.cache:
657 del cmt2cmake.cache['GaudiDummy']
658
659 requirements = '''
660 package GaudiDummy
661 version v1r0
662
663 use JustHeaders v*
664 use JustHeaders v* Hat
665
666 library Dummy *.cpp
667 apply_pattern linker_library library=Dummy
668 '''
669 pkg = PackWrap("GaudiDummy", requirements, files={'Dummy':{}})
670
671 cmakelists = pkg.generate()
672 print cmakelists
673
674 calls = getCalls("gaudi_add_library", cmakelists)
675 assert len(calls) == 1, "gaudi_add_library wrong count %d" % len(calls)
676
677 l = calls[0].strip().split()
678 assert l[0] == 'Dummy'
679 assert 'INCLUDE_DIRS' in l
680 links = set(l[l.index('INCLUDE_DIRS')+1:])
681 assert links == set(['JustHeaders', 'Hat/JustHeaders'])

def test_cmt2cmake.test_subdir_headers_update | ( |  | ) |

Definition at line 682 of file test_cmt2cmake.py.

682
683 def test_subdir_headers_update():
684 if 'GaudiDummy' in cmt2cmake.cache:
685 del cmt2cmake.cache['GaudiDummy']
686
687 requirements = '''
688 package GaudiDummy
689 version v1r0
690
691 apply_pattern install_more_includes more=Dummy
692 '''
693 PackWrap("GaudiDummy", requirements, files={'Dummy':{}})
694
695 assert cmt2cmake.cache['GaudiDummy']['includes'] == True
696 assert not cmt2cmake.cache['GaudiDummy']['libraries']

def test_cmt2cmake.test_subdir_links | ( |  | ) |

Definition at line 518 of file test_cmt2cmake.py.

518
519 def test_subdir_links():
520 requirements = '''
521 package Test
522 version v1r0
523
524 use Boost v* LCG_Interfaces
525 use XercesC v* LCG_Interfaces -no_auto_imports
526
527 use GaudiKernel *
528 use GaudiUtils * -no_auto_imports
529
530
531 library Lib1 *.cpp
532 apply_pattern component_library library=Lib1
533
534 library Lib2 *.cpp -import=XercesC
535 apply_pattern component_library library=Lib2
536
537 library Lib3 *.cpp -import=GaudiUtils
538 apply_pattern component_library library=Lib3
539 '''
540 pkg = PackWrap("Test", requirements, files={})
541
542 print 'components', pkg.component_libraries
543 print 'linker', pkg.linker_libraries
544 print 'libraries', pkg.libraries
545
546 assert pkg.component_libraries == set(['Lib1', 'Lib2', 'Lib3'])
547 assert len(pkg.libraries) == 3
548
549 cmakelists = pkg.generate()
550 print cmakelists
551
552 calls = getCalls("gaudi_add_module", cmakelists)
553 assert len(calls) == 3, "gaudi_add_module wrong count %d" % len(calls)
554
555 l = calls[0].strip().split()
556 assert l[0] == 'Lib1'
557 links = set(l[l.index('LINK_LIBRARIES')+1:])
558 assert links == set(['Boost', 'GaudiKernel'])
559
560 l = calls[1].strip().split()
561 assert l[0] == 'Lib2'
562 assert 'LINK_LIBRARIES' in l
563 links = set(l[l.index('LINK_LIBRARIES')+1:])
564 assert links == set(['Boost', 'GaudiKernel', 'XercesC'])
565
566 l = calls[2].strip().split()
567 assert l[0] == 'Lib3'
568 assert 'LINK_LIBRARIES' in l
569 links = set(l[l.index('LINK_LIBRARIES')+1:])
570 assert links == set(['Boost', 'GaudiKernel', 'GaudiUtilsLib'])

def test_cmt2cmake.test_subdir_links_hat | ( |  | ) |

Definition at line 571 of file test_cmt2cmake.py.

571
572 def test_subdir_links_hat():
573 requirements = '''
574 package Test
575 version v1r0
576
577 use LHCbKernel * Kernel
578 use SomeSubdir * Hat -no_auto_imports
579
580 library Lib1 *.cpp
581 apply_pattern component_library library=Lib1
582
583 library Lib2 *.cpp -import=SomeSubdir
584 apply_pattern component_library library=Lib2
585 '''
586 pkg = PackWrap("Test", requirements, files={})
587
588 print 'components', pkg.component_libraries
589 print 'linker', pkg.linker_libraries
590 print 'libraries', pkg.libraries
591
592 assert pkg.component_libraries == set(['Lib1', 'Lib2'])
593 assert len(pkg.libraries) == 2
594
595 cmakelists = pkg.generate()
596 print cmakelists
597
598 calls = getCalls("gaudi_add_module", cmakelists)
599 assert len(calls) == 2, "gaudi_add_module wrong count %d" % len(calls)
600
601 l = calls[0].strip().split()
602 assert l[0] == 'Lib1'
603 links = set(l[l.index('LINK_LIBRARIES')+1:])
604 assert links == set(['LHCbKernel'])
605
606 l = calls[1].strip().split()
607 assert l[0] == 'Lib2'
608 links = set(l[l.index('LINK_LIBRARIES')+1:])
609 assert links == set(['LHCbKernel', 'SubdirLib'])

def test_cmt2cmake.test_subdir_links_missing | ( |  | ) |

Definition at line 610 of file test_cmt2cmake.py.

610
611 def test_subdir_links_missing():
612 requirements = '''
613 package Test
614 version v1r0
615
616 use UnknownSubdir *
617
618 library Lib1 *.cpp
619 apply_pattern component_library library=Lib1
620 '''
621 pkg = PackWrap("Test", requirements, files={})
622
623 assert pkg.component_libraries == set(['Lib1'])
624 assert len(pkg.libraries) == 1
625
626 cmakelists = pkg.generate()
627 print cmakelists
628
629 calls = getCalls("gaudi_add_module", cmakelists)
630 assert len(calls) == 1, "gaudi_add_module wrong count %d" % len(calls)
631
632 l = calls[0].strip().split()
633 assert l[0] == 'Lib1'
634 assert 'LINK_LIBRARIES' not in l
635 # FIXME: we should test the warning

def test_cmt2cmake.test_subdir_links_update | ( |  | ) |

Definition at line 636 of file test_cmt2cmake.py.

636
637 def test_subdir_links_update():
638 if 'GaudiDummy' in cmt2cmake.cache:
639 del cmt2cmake.cache['GaudiDummy']
640
641 requirements = '''
642 package GaudiDummy
643 version v1r0
644
645 apply_pattern install_more_includes more=Dummy
646
647 library Dummy *.cpp
648 apply_pattern linker_library library=Dummy
649 '''
650 PackWrap("GaudiDummy", requirements, files={'Dummy':{}})
651
652 assert cmt2cmake.cache['GaudiDummy']['libraries'] == ['Dummy']
653 assert cmt2cmake.cache['GaudiDummy']['includes'] == False

def test_cmt2cmake.test_write_file | ( |  | ) |

Definition at line 697 of file test_cmt2cmake.py.

697
698 def test_write_file():
699 requirements = '''
700 package Test
701 version v1r0
702
703 library Lib1 *.cpp
704 apply_pattern component_library library=Lib1
705 '''
706 pkg = PackWrap("Test", requirements, files={})
707
708 cmakelists = pkg.generate()
709 print cmakelists
710
711 cmakefile = os.path.join(pkg.path, 'CMakeLists.txt')
712 pkg.process()
713 assert os.path.exists(cmakefile)
714 assert open(cmakefile).read() == cmakelists

def test_cmt2cmake.test_write_file_exists | ( |  | ) |

Definition at line 715 of file test_cmt2cmake.py.

715
716 def test_write_file_exists():
717 requirements = '''
718 package Test
719 version v1r0
720
721 library Lib1 *.cpp
722 apply_pattern component_library library=Lib1
723 '''
724 pkg = PackWrap("Test", requirements, files={'CMakeLists.txt': 'dummy data'})
725
726 cmakefile = os.path.join(pkg.path, 'CMakeLists.txt')
727 pkg.process()
728 # FIXME: we should test the warning
729 assert open(cmakefile).read() == 'dummy data'
730