|
Gaudi Framework, version v23r4 |
| Home | Generated: Mon Sep 17 2012 |
Classes | |
| class | PackWrap |
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_strip_src |
| 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_reflex |
| def | test_reflex_2 |
| def | test_reflex_3 |
| def | test_linkopts |
| def | test_application |
| def | test_pyqt_patterns |
| 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 28 of file test_cmt2cmake.py.
00029 : 00030 ''' 00031 Create a directory structure from the content of files. 00032 00033 @param files: a dictionary or list of pairs mapping a filename to the content 00034 if the content is a dictionary, recurse 00035 @param rootdir: base directory 00036 ''' 00037 if type(files) is dict: 00038 files = files.items() 00039 00040 # ensure that the root exists (to allow empty directories) 00041 if not os.path.exists(rootdir): 00042 os.makedirs(rootdir) 00043 00044 # create all the entries 00045 for filename, data in files: 00046 filename = os.path.join(rootdir, filename) 00047 if type(data) is dict: 00048 buildDir(data, filename) 00049 else: 00050 d = os.path.dirname(filename) 00051 if not os.path.exists(d): 00052 os.makedirs(d) 00053 f = open(filename, "w") 00054 if data: 00055 f.write(data) 00056 f.close()
| def test_cmt2cmake::getCalls | ( | function, | |
| cmakelists | |||
| ) |
extracts the arguments to all the calls to a cmake function
Definition at line 75 of file test_cmt2cmake.py.
| def test_cmt2cmake::test_application | ( | ) |
Definition at line 1001 of file test_cmt2cmake.py.
01002 : 01003 requirements = ''' 01004 package Test 01005 version v1r0 01006 01007 application MyApp1 ../src/app1/*.cpp 01008 01009 application MyApp2 -group=tests ../src/app2/*.cpp 01010 01011 application MyApp3 -check ../src/app3/*.cpp 01012 01013 application MyApp4 ../tests/src/app4.cpp 01014 01015 application MyTestApp app5a.cpp app5b.cpp 01016 ''' 01017 pkg = PackWrap("Test", requirements, files={}) 01018 01019 cmakelists = pkg.generate() 01020 print cmakelists 01021 01022 calls = getCalls("gaudi_add_executable", cmakelists) 01023 assert len(calls) == 5, "gaudi_add_executable wrong count %d" % len(calls) 01024 01025 l = calls[0].strip().split() 01026 assert l[0] == 'MyApp1' 01027 assert l[1:] == ['app1/*.cpp'] 01028 01029 l = calls[1].strip().split() 01030 assert l[0] == 'MyApp2' 01031 assert l[1:] == ['app2/*.cpp'] 01032 01033 l = calls[2].strip().split() 01034 assert l[0] == 'MyApp3' 01035 assert l[1:] == ['app3/*.cpp'] 01036 01037 l = calls[3].strip().split() 01038 assert l[0] == 'MyApp4' 01039 assert l[1:] == ['../tests/src/app4.cpp'] 01040 01041 l = calls[4].strip().split() 01042 assert l[0] == 'MyTestApp' 01043 assert l[1:] == ['app5a.cpp', 'app5b.cpp'] 01044 01045 calls = getCalls("if", cmakelists) 01046 assert calls == ['BUILD_TESTS'] * 4
| def test_cmt2cmake::test_god_1 | ( | ) |
Definition at line 681 of file test_cmt2cmake.py.
00682 : 00683 # some corner cases 00684 # FIXME: we should actually test the warning messages 00685 requirements = ''' 00686 package Test 00687 version v1r0 00688 00689 apply_pattern god_headers files=../xml/*.xml 00690 ''' 00691 pkg = PackWrap("Test", requirements, files={}) 00692 00693 cmakelists = pkg.generate() 00694 print cmakelists 00695 00696 calls = getCalls("include", cmakelists) 00697 assert calls 00698 l = calls[0].strip() 00699 assert l == 'GaudiObjDesc' 00700 00701 calls = getCalls("god_build_headers", cmakelists) 00702 assert len(calls) == 1, "god_build_headers wrong count %d" % len(calls) 00703 00704 l = calls[0].strip() 00705 assert l == 'xml/*.xml'
| def test_cmt2cmake::test_god_2 | ( | ) |
Definition at line 706 of file test_cmt2cmake.py.
00707 : 00708 requirements = ''' 00709 package Test 00710 version v1r0 00711 00712 apply_pattern god_dictionary files=../xml/*.xml 00713 ''' 00714 pkg = PackWrap("Test", requirements, files={}) 00715 00716 cmakelists = pkg.generate() 00717 print cmakelists 00718 00719 calls = getCalls("include", cmakelists) 00720 assert calls 00721 l = calls[0].strip() 00722 assert l == 'GaudiObjDesc' 00723 00724 calls = getCalls("god_build_dictionary", cmakelists) 00725 assert len(calls) == 1, "god_build_dictionary wrong count %d" % len(calls) 00726 00727 l = calls[0].strip() 00728 assert l == 'xml/*.xml'
| def test_cmt2cmake::test_god_3 | ( | ) |
Definition at line 729 of file test_cmt2cmake.py.
00730 : 00731 requirements = ''' 00732 package Test 00733 version v1r0 00734 00735 use Boost v* LCG_Interfaces 00736 00737 apply_pattern god_headers files=../xml/*.xml 00738 apply_pattern god_dictionary files=../xml/*.xml 00739 ''' 00740 pkg = PackWrap("Test", requirements, files={}) 00741 00742 cmakelists = pkg.generate() 00743 print cmakelists 00744 00745 calls = getCalls("include", cmakelists) 00746 assert calls 00747 l = calls[0].strip() 00748 assert l == 'GaudiObjDesc' 00749 00750 calls = getCalls("god_build_headers", cmakelists) 00751 assert len(calls) == 1, "god_build_headers wrong count %d" % len(calls) 00752 00753 calls = getCalls("god_build_dictionary", cmakelists) 00754 assert len(calls) == 1, "god_build_dictionary wrong count %d" % len(calls) 00755 00756 l = calls[0].strip().split() 00757 assert l[0] == 'xml/*.xml' 00758 assert 'LINK_LIBRARIES' in l 00759 assert l[l.index('LINK_LIBRARIES')+1] == 'Boost' 00760 assert 'INCLUDE_DIRS' in l 00761 assert l[l.index('INCLUDE_DIRS')+1] == 'Boost'
| def test_cmt2cmake::test_god_4 | ( | ) |
Definition at line 762 of file test_cmt2cmake.py.
00763 : 00764 requirements = ''' 00765 package Test 00766 version v1r0 00767 00768 use Boost v* LCG_Interfaces 00769 00770 library Lib *.cpp 00771 apply_pattern linker_library library=Lib 00772 00773 apply_pattern god_headers files=../xml/*.xml 00774 apply_pattern god_dictionary files=../xml/*.xml 00775 ''' 00776 pkg = PackWrap("Test", requirements, files={}) 00777 00778 cmakelists = pkg.generate() 00779 print cmakelists 00780 00781 calls = getCalls("include", cmakelists) 00782 assert calls 00783 l = calls[0].strip() 00784 assert l == 'GaudiObjDesc' 00785 00786 calls = getCalls("god_build_headers", cmakelists) 00787 assert len(calls) == 1, "god_build_headers wrong count %d" % len(calls) 00788 00789 calls = getCalls("gaudi_add_library", cmakelists) 00790 assert len(calls) == 1, "gaudi_add_library wrong count %d" % len(calls) 00791 00792 calls = getCalls("god_build_dictionary", cmakelists) 00793 assert len(calls) == 1, "god_build_dictionary wrong count %d" % len(calls) 00794 00795 l = calls[0].strip().split() 00796 assert l[0] == 'xml/*.xml' 00797 assert 'LINK_LIBRARIES' in l 00798 i = l.index('LINK_LIBRARIES')+1 00799 assert l[i:i+2] == ['Boost', 'Lib'] 00800 assert 'INCLUDE_DIRS' in l 00801 assert l[l.index('INCLUDE_DIRS')+1] == 'Boost' 00802 00803 hdr = cmakelists.find('god_build_headers') 00804 lib = cmakelists.find('gaudi_add_library') 00805 dct = cmakelists.find('god_build_dictionary') 00806 assert hdr < lib and lib < dct, "wrong order of calls"
| def test_cmt2cmake::test_god_5 | ( | ) |
Definition at line 807 of file test_cmt2cmake.py.
00808 : 00809 requirements = ''' 00810 package Test 00811 version v1r0 00812 00813 apply_pattern god_headers files=../xml/*.xml 00814 macro TestObj2Doth_GODflags " -s ../Test/ " 00815 ''' 00816 pkg = PackWrap("Test", requirements, files={}) 00817 00818 cmakelists = pkg.generate() 00819 print cmakelists 00820 00821 calls = getCalls("include", cmakelists) 00822 assert calls 00823 l = calls[0].strip() 00824 assert l == 'GaudiObjDesc' 00825 00826 calls = getCalls("god_build_headers", cmakelists) 00827 assert len(calls) == 1, "god_build_headers wrong count %d" % len(calls) 00828 00829 l = calls[0].strip().split() 00830 assert l[0] == 'xml/*.xml' 00831 assert 'DESTINATION' in l 00832 assert l[l.index('DESTINATION')+1] == 'Test'
| def test_cmt2cmake::test_god_6 | ( | ) |
Definition at line 833 of file test_cmt2cmake.py.
00834 : 00835 requirements = ''' 00836 package Test 00837 version v1r0 00838 00839 document customdict TestCustomDict ../dict/TestCustomDict.h 00840 00841 apply_pattern god_dictionary files=../xml/*.xml 00842 ''' 00843 pkg = PackWrap("Test", requirements, files={}) 00844 00845 cmakelists = pkg.generate() 00846 print cmakelists 00847 00848 calls = getCalls("include", cmakelists) 00849 assert calls 00850 l = calls[0].strip() 00851 assert l == 'GaudiObjDesc' 00852 00853 calls = getCalls("god_build_dictionary", cmakelists) 00854 assert len(calls) == 1, "god_build_dictionary wrong count %d" % len(calls) 00855 00856 l = calls[0].strip().split() 00857 assert l == ['xml/*.xml', 'EXTEND', 'dict/TestCustomDict.h']
| def test_cmt2cmake::test_install_headers | ( | ) |
Definition at line 190 of file test_cmt2cmake.py.
00191 : 00192 requirements = ''' 00193 #============================================================================ 00194 package Tell1Kernel 00195 version v1r12p1 00196 00197 # Structure, i.e. directories to process. 00198 #============================================================================ 00199 branches cmt doc Tell1Kernel 00200 00201 # Used packages 00202 #============================================================================ 00203 use GaudiPolicy v* 00204 00205 apply_pattern install_more_includes more=Tell1Kernel 00206 ''' 00207 pkg = PackWrap("Tell1Kernel", requirements, files={"Tell1Kernel/hdr.h": None}) 00208 00209 cmakelists = pkg.generate() 00210 print cmakelists 00211 00212 calls = getCalls("gaudi_install_headers", cmakelists) 00213 assert calls 00214 00215 args = set() 00216 for call in calls: 00217 args.update(call.strip().split()) 00218 expected = set(['Tell1Kernel']) 00219 assert args == expected
| def test_cmt2cmake::test_install_python | ( | ) |
Definition at line 220 of file test_cmt2cmake.py.
00221 : 00222 requirements = ''' 00223 package Test 00224 version v1r0 00225 00226 apply_pattern install_python_modules 00227 ''' 00228 pkg = PackWrap("Test", requirements, files={"python/Test/__init__.py": None}) 00229 00230 cmakelists = pkg.generate() 00231 print cmakelists 00232 00233 calls = getCalls("gaudi_install_python_modules", cmakelists) 00234 assert calls
| def test_cmt2cmake::test_install_python2 | ( | ) |
Definition at line 235 of file test_cmt2cmake.py.
00236 : 00237 requirements = ''' 00238 package Test 00239 version v1r0 00240 00241 macro TestConfUserModules "Test.CustomModule1 Test.CustomModule2" 00242 00243 apply_pattern install_python_modules 00244 ''' 00245 pkg = PackWrap("Test", requirements, files={"python/Test/__init__.py": None}) 00246 00247 cmakelists = pkg.generate() 00248 print cmakelists 00249 00250 calls = getCalls("gaudi_install_python_modules", cmakelists) 00251 assert calls 00252 00253 calls = getCalls("set_property", cmakelists) 00254 assert calls 00255 args = calls[0].strip().split() 00256 assert args == ['DIRECTORY', 'PROPERTY', 'CONFIGURABLE_USER_MODULES', 'Test.CustomModule1', 'Test.CustomModule2'], args
| def test_cmt2cmake::test_install_scripts | ( | ) |
Definition at line 257 of file test_cmt2cmake.py.
00258 : 00259 requirements = ''' 00260 package Test 00261 version v1r0 00262 00263 apply_pattern install_scripts 00264 ''' 00265 pkg = PackWrap("Test", requirements, files={"scripts/someScript": None}) 00266 00267 cmakelists = pkg.generate() 00268 print cmakelists 00269 00270 calls = getCalls("gaudi_install_scripts", cmakelists) 00271 assert calls
| def test_cmt2cmake::test_libraries | ( | ) |
Definition at line 291 of file test_cmt2cmake.py.
00292 : 00293 requirements = ''' 00294 package Test 00295 version v1r0 00296 00297 library TestLib lib/*.cpp 00298 apply_pattern linker_library library=TestLib 00299 00300 library TestComp component/*.cpp 00301 apply_pattern component_library library=TestComp 00302 00303 library TestTestLib test/lib/*.cpp -group=tests 00304 apply_pattern linker_library library=TestTestLib 00305 00306 library TestTestComp test/component/*.cpp -group=tests 00307 apply_pattern component_library library=TestTestComp 00308 00309 apply_pattern install_more_includes more=TestIncludes 00310 ''' 00311 pkg = PackWrap("Test", requirements, files={'TestIncludes': {}}) 00312 00313 print 'components', pkg.component_libraries 00314 print 'linker', pkg.linker_libraries 00315 print 'libraries', pkg.libraries 00316 00317 assert pkg.component_libraries == set(['TestComp', 'TestTestComp']) 00318 assert pkg.linker_libraries == set(['TestLib', 'TestTestLib']) 00319 assert pkg.libraries 00320 00321 cmakelists = pkg.generate() 00322 print cmakelists 00323 00324 calls = getCalls("gaudi_add_library", cmakelists) 00325 assert len(calls) == 2, "gaudi_add_library wrong count %d" % len(calls) 00326 l = calls[0] 00327 assert re.match(r' *TestLib\b', l) 00328 assert re.search(r'\bPUBLIC_HEADERS +TestIncludes', l) 00329 l = calls[1] 00330 assert re.match(r' *TestTestLib\b', l) 00331 assert re.search(r'\bPUBLIC_HEADERS +TestIncludes', l) 00332 assert re.search(r'\bLINK_LIBRARIES +TestLib', l) 00333 00334 calls = getCalls("gaudi_add_module", cmakelists) 00335 assert len(calls) == 2, "gaudi_add_module wrong count %d" % len(calls) 00336 00337 l = calls[0] 00338 assert re.match(r' *TestComp\b', l) 00339 assert not re.search(r'\bPUBLIC_HEADERS\b', l) 00340 assert re.search(r'\bLINK_LIBRARIES +TestLib', l) 00341 l = calls[1] 00342 assert re.match(r' *TestTestComp\b', l) 00343 assert not re.search(r'\bPUBLIC_HEADERS', l) 00344 assert re.search(r'\bLINK_LIBRARIES +TestLib +TestTestLib', l)
| def test_cmt2cmake::test_libraries_2 | ( | ) |
Definition at line 345 of file test_cmt2cmake.py.
00346 : 00347 requirements = ''' 00348 package Test 00349 version v1r0 00350 00351 use Boost v* LCG_Interfaces 00352 use XercesC v* LCG_Interfaces -no_auto_imports 00353 00354 library Lib1 lib1/*.cpp 00355 apply_pattern component_library library=Lib1 00356 00357 library Lib2 lib2/*.cpp -import=XercesC 00358 apply_pattern component_library library=Lib2 00359 00360 # We do not use variables 00361 library Lib3 lib3/*.cpp a_variable=some_value 00362 apply_pattern component_library library=Lib3 00363 ''' 00364 pkg = PackWrap("Test", requirements, files={}) 00365 00366 print 'components', pkg.component_libraries 00367 print 'libraries', pkg.libraries 00368 00369 assert pkg.component_libraries == set(['Lib1', 'Lib2', 'Lib3']) 00370 assert pkg.libraries 00371 00372 cmakelists = pkg.generate() 00373 print cmakelists 00374 00375 calls = getCalls("gaudi_add_module", cmakelists) 00376 assert len(calls) == 3, "gaudi_add_module wrong count %d" % len(calls) 00377 00378 l = calls[0] 00379 assert re.match(r' *Lib1\b', l) 00380 assert not re.search(r'\bPUBLIC_HEADERS\b', l) 00381 assert re.search(r'\bLINK_LIBRARIES +Boost', l) 00382 assert re.search(r'\bINCLUDE_DIRS +Boost', l) 00383 l = calls[1] 00384 assert re.match(r' *Lib2\b', l) 00385 assert not re.search(r'\bPUBLIC_HEADERS', l) 00386 assert re.search(r'\bLINK_LIBRARIES +Boost +XercesC', l) 00387 assert re.search(r'\bINCLUDE_DIRS +Boost +XercesC', l) 00388 l = calls[2] 00389 assert re.match(r' *Lib3\b', l) 00390 assert not re.search(r'\bPUBLIC_HEADERS', l) 00391 assert re.search(r'\bLINK_LIBRARIES +Boost', l) 00392 assert re.search(r'\bINCLUDE_DIRS +Boost', l)
| def test_cmt2cmake::test_libraries_3 | ( | ) |
Definition at line 393 of file test_cmt2cmake.py.
00394 : 00395 # some corner cases 00396 # FIXME: we should actually test the warning messages 00397 requirements = ''' 00398 package Test 00399 version v1r0 00400 00401 library Lib1 00402 apply_pattern component_library library=Lib1 00403 00404 library Lib2 lib2/*.cpp 00405 apply_pattern linker_library library=Lib2 00406 00407 library Lib3 lib3/*.cpp 00408 00409 library Lib4 lib4/*.cpp 00410 apply_pattern linker_library library="Lib4" 00411 00412 ''' 00413 pkg = PackWrap("Test", requirements, files={}) 00414 00415 print 'components', pkg.component_libraries 00416 print 'linker', pkg.linker_libraries 00417 print 'libraries', pkg.libraries 00418 00419 assert pkg.component_libraries == set(['Lib1']) 00420 assert pkg.linker_libraries == set(['Lib2', 'Lib4']) 00421 assert len(pkg.libraries) == 4 00422 00423 cmakelists = pkg.generate() 00424 print cmakelists 00425 00426 calls = getCalls("gaudi_add_module", cmakelists) 00427 assert len(calls) == 1, "gaudi_add_module wrong count %d" % len(calls) 00428 00429 l = calls[0] 00430 assert re.match(r' *Lib1\b', l) 00431 assert not re.search(r'\bPUBLIC_HEADERS\b', l) 00432 00433 calls = getCalls("gaudi_add_library", cmakelists) 00434 assert len(calls) == 3, "gaudi_add_module wrong count %d" % len(calls) 00435 00436 l = calls[0] 00437 assert re.match(r' *Lib2\b', l) 00438 assert re.search(r'\bNO_PUBLIC_HEADERS', l) 00439 00440 l = calls[1] 00441 assert re.match(r' *Lib3\b', l) 00442 assert re.search(r'\bNO_PUBLIC_HEADERS', l) 00443 00444 l = calls[2] 00445 assert re.match(r' *Lib4\b', l) 00446 assert re.search(r'\bNO_PUBLIC_HEADERS', l)
| def test_cmt2cmake::test_libraries_strip_src | ( | ) |
Definition at line 447 of file test_cmt2cmake.py.
00448 : 00449 requirements = ''' 00450 package Test 00451 version v1r0 00452 00453 library TestLib ../src/subdir/*.cpp 00454 apply_pattern linker_library library=TestLib 00455 ''' 00456 pkg = PackWrap("Test", requirements, files={'TestIncludes': {}}) 00457 00458 assert pkg.linker_libraries == set(['TestLib']) 00459 00460 cmakelists = pkg.generate() 00461 print cmakelists 00462 00463 calls = getCalls("gaudi_add_library", cmakelists) 00464 assert len(calls) == 1, "gaudi_add_library wrong count %d" % len(calls) 00465 l = calls[0].strip().split() 00466 assert l[0] == 'TestLib' 00467 assert l[1] == 'subdir/*.cpp'
| def test_cmt2cmake::test_linkopts | ( | ) |
Definition at line 975 of file test_cmt2cmake.py.
00976 : 00977 requirements = ''' 00978 package Test 00979 version v1r0 00980 00981 use ROOT v* LCG_Interfaces 00982 use Boost v* LCG_Interfaces 00983 00984 macro_append ROOT_linkopts " -lMathCore" 00985 macro_append Boost_linkopts " $(Boost_linkopts_filesystem)" 00986 00987 ''' 00988 pkg = PackWrap("Test", requirements, files={}) 00989 00990 cmakelists = pkg.generate() 00991 print cmakelists 00992 00993 calls = getCalls("find_package", cmakelists) 00994 assert len(calls) == 2, "find_package wrong count %d" % len(calls) 00995 00996 l = calls[0].strip().split() 00997 assert l == ['Boost', 'COMPONENTS', 'filesystem'] # find_package are sorted 00998 00999 l = calls[1].strip().split() 01000 assert l == ['ROOT', 'COMPONENTS', 'MathCore'] # find_package are sorted
| def test_cmt2cmake::test_not_a_package | ( | ) |
Definition at line 86 of file test_cmt2cmake.py.
| def test_cmt2cmake::test_pack_deps | ( | ) |
Definition at line 119 of file test_cmt2cmake.py.
00120 : 00121 requirements = """ 00122 package Test 00123 version v1r0 00124 00125 # series of uses 00126 use GaudiKernel v* 00127 use GaudiAlg * 00128 use GaudiPolicy * 00129 use GaudiCoreSvc v* # comment 00130 use GaudiUtils * -no_auto_imports 00131 00132 use LHCbKernel v* Kernel 00133 """ 00134 pkg = PackWrap("Test", requirements) 00135 00136 cmakelists = pkg.generate() 00137 print cmakelists 00138 00139 calls = getCalls("gaudi_depends_on_subdirs", cmakelists) 00140 assert calls, "gaudi_depends_on_subdirs not called" 00141 00142 args = set() 00143 for call in calls: 00144 args.update(call.strip().split()) 00145 expected = set(['GaudiKernel', 'GaudiAlg', 'GaudiCoreSvc', 00146 'GaudiUtils', 'Kernel/LHCbKernel']) 00147 assert args == expected
| def test_cmt2cmake::test_pack_ext_deps | ( | ) |
Definition at line 163 of file test_cmt2cmake.py.
00164 : 00165 requirements = """ 00166 package Test 00167 version v1r0 00168 00169 # series of uses 00170 use Boost v* LCG_Interfaces 00171 use Python v* LCG_Interfaces 00172 use XercesC v* LCG_Interfaces -no_auto_imports 00173 """ 00174 pkg = PackWrap("Test", requirements) 00175 00176 cmakelists = pkg.generate() 00177 print cmakelists 00178 00179 expected = set(['Boost', 'XercesC']) 00180 00181 calls = getCalls("find_package", cmakelists) 00182 assert calls, "find_pacakge not called" 00183 assert len(calls) == len(expected) 00184 00185 args = set() 00186 for call in calls: 00187 args.add(call.strip().split()[0]) 00188 print args 00189 assert args == expected
| def test_cmt2cmake::test_pack_header | ( | ) |
Definition at line 98 of file test_cmt2cmake.py.
00099 : 00100 requirements = """ 00101 package ThisIsAPackage 00102 version v123r456 00103 00104 branches cmt branches are ignored 00105 macro test parsing of \\ 00106 multi line 00107 """ 00108 pkg = PackWrap("ThisIsAPackage", requirements) 00109 00110 cmakelists = pkg.generate() 00111 print cmakelists 00112 00113 calls = getCalls("gaudi_subdir", cmakelists) 00114 assert calls, "gaudi_subdir not called" 00115 assert len(calls) == 1, "gaudi_subdir called more than once" 00116 00117 args = calls[0].strip().split() 00118 assert args == ["ThisIsAPackage", "v123r456"]
| def test_cmt2cmake::test_pack_no_deps | ( | ) |
Definition at line 148 of file test_cmt2cmake.py.
00149 : 00150 requirements = """ 00151 package Test 00152 version v1r0 00153 00154 # no uses 00155 """ 00156 pkg = PackWrap("Test", requirements) 00157 00158 cmakelists = pkg.generate() 00159 print cmakelists 00160 00161 calls = getCalls("gaudi_depends_on_subdirs", cmakelists) 00162 assert not calls, "gaudi_depends_on_subdirs called"
| def test_cmt2cmake::test_pyqt_patterns | ( | ) |
Definition at line 1047 of file test_cmt2cmake.py.
01048 : 01049 requirements = ''' 01050 package Test 01051 version v1r0 01052 01053 use pygraphics v* LCG_Interfaces -no_auto_imports 01054 use Qt v* LCG_Interfaces -no_auto_imports 01055 01056 apply_pattern install_python_modules 01057 01058 apply_pattern PyQtResource qrc_files=../qt_resources/*.qrc outputdir=../python/Test/QtApp 01059 apply_pattern PyQtUIC ui_files=../qt_resources/*.ui outputdir=../python/Test/QtApp 01060 macro_append Test_python_dependencies " PyQtResource PyQtUIC " 01061 ''' 01062 pkg = PackWrap("Test", requirements, files={}) 01063 01064 cmakelists = pkg.generate() 01065 print cmakelists 01066 01067 calls = getCalls("gen_pyqt_resource", cmakelists) 01068 assert len(calls) == 1, "gen_pyqt_resource wrong count %d" % len(calls) 01069 l = calls[0].strip().split() 01070 assert l == ['Test.QtApp.Resources', 'Test/QtApp', 'qt_resources/*.qrc'] 01071 01072 calls = getCalls("gen_pyqt_uic", cmakelists) 01073 assert len(calls) == 1, "gen_pyqt_uic wrong count %d" % len(calls) 01074 l = calls[0].strip().split() 01075 assert l == ['Test.QtApp.UI', 'Test/QtApp', 'qt_resources/*.ui']
| def test_cmt2cmake::test_qmtest | ( | ) |
Definition at line 272 of file test_cmt2cmake.py.
00273 : 00274 requirements = ''' 00275 package Test 00276 version v1r0 00277 00278 apply_pattern QMTest 00279 ''' 00280 pkg = PackWrap("Test", requirements, files={"tests/qmtest/test.qms/a_test.qmt": None}) 00281 00282 cmakelists = pkg.generate() 00283 print cmakelists 00284 00285 calls = getCalls("gaudi_add_test", cmakelists) 00286 assert calls, "no test added" 00287 assert len(calls) == 1, "gaudi_add_test called more than once" 00288 00289 args = calls[0].strip().split() 00290 assert args == ["QMTest", "QMTEST"]
| def test_cmt2cmake::test_reflex | ( | ) |
Definition at line 858 of file test_cmt2cmake.py.
00859 : 00860 requirements = ''' 00861 package Test 00862 version v1r0 00863 00864 use ROOT v* LCG_Interfaces 00865 00866 apply_pattern reflex_dictionary \\ 00867 dictionary=Test \\ 00868 headerfiles=$(TESTROOT)/dict/TestDict.h \\ 00869 selectionfile=$(TESTROOT)/dict/TestDict.xml 00870 00871 apply_pattern reflex_dictionary \\ 00872 dictionary=Test2 \\ 00873 headerfiles=$(TESTROOT)/dict/Test2Dict.h \\ 00874 selectionfile=$(TESTROOT)/dict/Test2Dict.xml \\ 00875 options="-DOPTION" 00876 ''' 00877 pkg = PackWrap("Test", requirements, files={}) 00878 00879 cmakelists = pkg.generate() 00880 print cmakelists 00881 00882 calls = getCalls("gaudi_add_dictionary", cmakelists) 00883 assert len(calls) == 2, "gaudi_add_dictionary wrong count %d" % len(calls) 00884 00885 l = calls[0].strip().split() 00886 assert l[0:3] == ['Test', 'dict/TestDict.h', 'dict/TestDict.xml'] 00887 assert 'LINK_LIBRARIES' in l 00888 assert l[l.index('LINK_LIBRARIES')+1] == 'ROOT' 00889 assert 'INCLUDE_DIRS' in l 00890 assert l[l.index('INCLUDE_DIRS')+1] == 'ROOT' 00891 00892 l = calls[1].strip().split() 00893 assert l[0:3] == ['Test2', 'dict/Test2Dict.h', 'dict/Test2Dict.xml'] 00894 assert 'LINK_LIBRARIES' in l 00895 assert l[l.index('LINK_LIBRARIES')+1] == 'ROOT' 00896 assert 'INCLUDE_DIRS' in l 00897 assert l[l.index('INCLUDE_DIRS')+1] == 'ROOT' 00898 assert 'OPTIONS' in l 00899 assert l[l.index('OPTIONS')+1:] == ['"-DOPTION"'] 00900
| def test_cmt2cmake::test_reflex_2 | ( | ) |
Definition at line 901 of file test_cmt2cmake.py.
00902 : 00903 requirements = ''' 00904 package Test 00905 version v1r0 00906 00907 use ROOT v* LCG_Interfaces 00908 00909 library Test *.ccp 00910 apply_pattern component_library library=Test 00911 00912 apply_pattern reflex_dictionary \\ 00913 dictionary=Test \\ 00914 headerfiles=$(TESTROOT)/dict/TestDict.h \\ 00915 selectionfile=$(TESTROOT)/dict/TestDict.xml 00916 ''' 00917 pkg = PackWrap("Test", requirements, files={}) 00918 00919 cmakelists = pkg.generate() 00920 print cmakelists 00921 00922 calls = getCalls("gaudi_add_module", cmakelists) 00923 assert len(calls) == 1, "gaudi_add_module wrong count %d" % len(calls) 00924 00925 l = calls[0].strip().split() 00926 assert l[0] == 'Test' 00927 00928 calls = getCalls("gaudi_add_dictionary", cmakelists) 00929 assert len(calls) == 1, "gaudi_add_dictionary wrong count %d" % len(calls) 00930 00931 l = calls[0].strip().split() 00932 assert l[0:3] == ['Test', 'dict/TestDict.h', 'dict/TestDict.xml']
| def test_cmt2cmake::test_reflex_3 | ( | ) |
Definition at line 933 of file test_cmt2cmake.py.
00934 : 00935 requirements = ''' 00936 package Test 00937 version v1r0 00938 00939 use ROOT v* LCG_Interfaces 00940 use COOL v* LCG_Interfaces -no_auto_imports 00941 use CORAL v* LCG_Interfaces -no_auto_imports 00942 use Boost v* LCG_Interfaces -no_auto_imports 00943 00944 library Test *.ccp 00945 apply_pattern component_library library=Test 00946 00947 apply_pattern reflex_dictionary \\ 00948 dictionary=Test \\ 00949 headerfiles=$(TESTROOT)/dict/TestDict.h \\ 00950 selectionfile=$(TESTROOT)/dict/TestDict.xml \\ 00951 imports="COOL -import=CORAL -import=Boost" 00952 ''' 00953 pkg = PackWrap("Test", requirements, files={}) 00954 00955 cmakelists = pkg.generate() 00956 print cmakelists 00957 00958 calls = getCalls("gaudi_add_module", cmakelists) 00959 assert len(calls) == 1, "gaudi_add_module wrong count %d" % len(calls) 00960 00961 l = calls[0].strip().split() 00962 assert l[0] == 'Test' 00963 00964 calls = getCalls("gaudi_add_dictionary", cmakelists) 00965 assert len(calls) == 1, "gaudi_add_dictionary wrong count %d" % len(calls) 00966 00967 l = calls[0].strip().split() 00968 assert l[0:3] == ['Test', 'dict/TestDict.h', 'dict/TestDict.xml'] 00969 assert 'INCLUDE_DIRS' in l 00970 i = l.index('INCLUDE_DIRS') 00971 assert 'LINK_LIBRARIES' in l 00972 j = l.index('LINK_LIBRARIES') 00973 assert set(l[i+1:j]) == set(['ROOT', 'COOL', 'CORAL', 'Boost']) 00974 assert set(l[j+1:]) == set(['ROOT', 'COOL', 'CORAL', 'Boost'])
| def test_cmt2cmake::test_subdir_headers | ( | ) |
Definition at line 604 of file test_cmt2cmake.py.
00605 : 00606 if 'GaudiDummy' in cmt2cmake.known_subdirs: 00607 del cmt2cmake.known_subdirs['GaudiDummy'] 00608 00609 requirements = ''' 00610 package GaudiDummy 00611 version v1r0 00612 00613 use JustHeaders v* 00614 use JustHeaders v* Hat 00615 00616 library Dummy *.cpp 00617 apply_pattern linker_library library=Dummy 00618 ''' 00619 pkg = PackWrap("GaudiDummy", requirements, files={'Dummy':{}}) 00620 00621 cmakelists = pkg.generate() 00622 print cmakelists 00623 00624 calls = getCalls("gaudi_add_library", cmakelists) 00625 assert len(calls) == 1, "gaudi_add_library wrong count %d" % len(calls) 00626 00627 l = calls[0].strip().split() 00628 assert l[0] == 'Dummy' 00629 assert 'INCLUDE_DIRS' in l 00630 links = set(l[l.index('INCLUDE_DIRS')+1:]) 00631 assert links == set(['JustHeaders', 'Hat/JustHeaders'])
| def test_cmt2cmake::test_subdir_headers_update | ( | ) |
Definition at line 632 of file test_cmt2cmake.py.
00633 : 00634 if 'GaudiDummy' in cmt2cmake.known_subdirs: 00635 del cmt2cmake.known_subdirs['GaudiDummy'] 00636 00637 requirements = ''' 00638 package GaudiDummy 00639 version v1r0 00640 00641 apply_pattern install_more_includes more=Dummy 00642 ''' 00643 PackWrap("GaudiDummy", requirements, files={'Dummy':{}}) 00644 00645 assert cmt2cmake.known_subdirs['GaudiDummy']['includes'] == True 00646 assert not cmt2cmake.known_subdirs['GaudiDummy']['libraries']
| def test_cmt2cmake::test_subdir_links | ( | ) |
Definition at line 468 of file test_cmt2cmake.py.
00469 : 00470 requirements = ''' 00471 package Test 00472 version v1r0 00473 00474 use Boost v* LCG_Interfaces 00475 use XercesC v* LCG_Interfaces -no_auto_imports 00476 00477 use GaudiKernel * 00478 use GaudiUtils * -no_auto_imports 00479 00480 00481 library Lib1 *.cpp 00482 apply_pattern component_library library=Lib1 00483 00484 library Lib2 *.cpp -import=XercesC 00485 apply_pattern component_library library=Lib2 00486 00487 library Lib3 *.cpp -import=GaudiUtils 00488 apply_pattern component_library library=Lib3 00489 ''' 00490 pkg = PackWrap("Test", requirements, files={}) 00491 00492 print 'components', pkg.component_libraries 00493 print 'linker', pkg.linker_libraries 00494 print 'libraries', pkg.libraries 00495 00496 assert pkg.component_libraries == set(['Lib1', 'Lib2', 'Lib3']) 00497 assert len(pkg.libraries) == 3 00498 00499 cmakelists = pkg.generate() 00500 print cmakelists 00501 00502 calls = getCalls("gaudi_add_module", cmakelists) 00503 assert len(calls) == 3, "gaudi_add_module wrong count %d" % len(calls) 00504 00505 l = calls[0].strip().split() 00506 assert l[0] == 'Lib1' 00507 links = set(l[l.index('LINK_LIBRARIES')+1:]) 00508 assert links == set(['Boost', 'GaudiKernel']) 00509 00510 l = calls[1].strip().split() 00511 assert l[0] == 'Lib2' 00512 assert 'LINK_LIBRARIES' in l 00513 links = set(l[l.index('LINK_LIBRARIES')+1:]) 00514 assert links == set(['Boost', 'GaudiKernel', 'XercesC']) 00515 00516 l = calls[2].strip().split() 00517 assert l[0] == 'Lib3' 00518 assert 'LINK_LIBRARIES' in l 00519 links = set(l[l.index('LINK_LIBRARIES')+1:]) 00520 assert links == set(['Boost', 'GaudiKernel', 'GaudiUtilsLib'])
| def test_cmt2cmake::test_subdir_links_hat | ( | ) |
Definition at line 521 of file test_cmt2cmake.py.
00522 : 00523 requirements = ''' 00524 package Test 00525 version v1r0 00526 00527 use LHCbKernel * Kernel 00528 use SomeSubdir * Hat -no_auto_imports 00529 00530 library Lib1 *.cpp 00531 apply_pattern component_library library=Lib1 00532 00533 library Lib2 *.cpp -import=SomeSubdir 00534 apply_pattern component_library library=Lib2 00535 ''' 00536 pkg = PackWrap("Test", requirements, files={}) 00537 00538 print 'components', pkg.component_libraries 00539 print 'linker', pkg.linker_libraries 00540 print 'libraries', pkg.libraries 00541 00542 assert pkg.component_libraries == set(['Lib1', 'Lib2']) 00543 assert len(pkg.libraries) == 2 00544 00545 cmakelists = pkg.generate() 00546 print cmakelists 00547 00548 calls = getCalls("gaudi_add_module", cmakelists) 00549 assert len(calls) == 2, "gaudi_add_module wrong count %d" % len(calls) 00550 00551 l = calls[0].strip().split() 00552 assert l[0] == 'Lib1' 00553 links = set(l[l.index('LINK_LIBRARIES')+1:]) 00554 assert links == set(['LHCbKernel']) 00555 00556 l = calls[1].strip().split() 00557 assert l[0] == 'Lib2' 00558 links = set(l[l.index('LINK_LIBRARIES')+1:]) 00559 assert links == set(['LHCbKernel', 'SubdirLib'])
| def test_cmt2cmake::test_subdir_links_missing | ( | ) |
Definition at line 560 of file test_cmt2cmake.py.
00561 : 00562 requirements = ''' 00563 package Test 00564 version v1r0 00565 00566 use UnknownSubdir * 00567 00568 library Lib1 *.cpp 00569 apply_pattern component_library library=Lib1 00570 ''' 00571 pkg = PackWrap("Test", requirements, files={}) 00572 00573 assert pkg.component_libraries == set(['Lib1']) 00574 assert len(pkg.libraries) == 1 00575 00576 cmakelists = pkg.generate() 00577 print cmakelists 00578 00579 calls = getCalls("gaudi_add_module", cmakelists) 00580 assert len(calls) == 1, "gaudi_add_module wrong count %d" % len(calls) 00581 00582 l = calls[0].strip().split() 00583 assert l[0] == 'Lib1' 00584 assert 'LINK_LIBRARIES' not in l 00585 # FIXME: we should test the warning
| def test_cmt2cmake::test_subdir_links_update | ( | ) |
Definition at line 586 of file test_cmt2cmake.py.
00587 : 00588 if 'GaudiDummy' in cmt2cmake.known_subdirs: 00589 del cmt2cmake.known_subdirs['GaudiDummy'] 00590 00591 requirements = ''' 00592 package GaudiDummy 00593 version v1r0 00594 00595 apply_pattern install_more_includes more=Dummy 00596 00597 library Dummy *.cpp 00598 apply_pattern linker_library library=Dummy 00599 ''' 00600 PackWrap("GaudiDummy", requirements, files={'Dummy':{}}) 00601 00602 assert cmt2cmake.known_subdirs['GaudiDummy']['libraries'] == ['Dummy'] 00603 assert cmt2cmake.known_subdirs['GaudiDummy']['includes'] == False
| def test_cmt2cmake::test_write_file | ( | ) |
Definition at line 647 of file test_cmt2cmake.py.
00648 : 00649 requirements = ''' 00650 package Test 00651 version v1r0 00652 00653 library Lib1 *.cpp 00654 apply_pattern component_library library=Lib1 00655 ''' 00656 pkg = PackWrap("Test", requirements, files={}) 00657 00658 cmakelists = pkg.generate() 00659 print cmakelists 00660 00661 cmakefile = os.path.join(pkg.path, 'CMakeLists.txt') 00662 pkg.process() 00663 assert os.path.exists(cmakefile) 00664 assert open(cmakefile).read() == cmakelists
| def test_cmt2cmake::test_write_file_exists | ( | ) |
Definition at line 665 of file test_cmt2cmake.py.
00666 : 00667 requirements = ''' 00668 package Test 00669 version v1r0 00670 00671 library Lib1 *.cpp 00672 apply_pattern component_library library=Lib1 00673 ''' 00674 pkg = PackWrap("Test", requirements, files={'CMakeLists.txt': 'dummy data'}) 00675 00676 cmakefile = os.path.join(pkg.path, 'CMakeLists.txt') 00677 pkg.process() 00678 # FIXME: we should test the warning 00679 assert open(cmakefile).read() == 'dummy data' 00680