| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
test_cmt2cmake.py
Go to the documentation of this file.
1 from tempfile import mkdtemp
2 import shutil
3 import os
4 import re
5
6 # use a private cache for the tests
7 os.environ['CMT2CMAKECACHE'] = 'test.cache'
8 if os.path.exists('test.cache'):
9 os.remove('test.cache')
10
11 import cmt2cmake
12 cmt2cmake.open_cache()
13
14 # prepare the cache for the tests
15 cmt2cmake.cache['GaudiKernel'] = {'libraries': ['GaudiKernel'],
16 'includes': False}
17 cmt2cmake.cache['GaudiUtils'] = {'libraries': ['GaudiUtilsLib'],
18 'includes': False}
19 cmt2cmake.cache['LHCbKernel'] = {'libraries': ['LHCbKernel'],
20 'includes': False}
21 cmt2cmake.cache['SomeSubdir'] = {'libraries': ['SubdirLib'],
22 'includes': False}
23 cmt2cmake.cache['JustHeaders'] = {'libraries': [],
24 'includes': True}
25 cmt2cmake.cache[repr(('Baseproject', 'v1r0'))] = {'heptools': '65'}
26 cmt2cmake.cache[repr(('TestProjectHT', 'v3r0'))] = {'heptools': '23'}
27
28
29 cmt2cmake.data_packages = set(['DataPack', 'Another/DtPkg', 'SpecialThing'])
30
31 #
32 # Helpers
33 #
34
35 def buildDir(files, rootdir=os.curdir):
36 '''
37 Create a directory structure from the content of files.
38
39 @param files: a dictionary or list of pairs mapping a filename to the content
40 if the content is a dictionary, recurse
41 @param rootdir: base directory
42 '''
43 if type(files) is dict:
44 files = files.items()
45
46 # ensure that the root exists (to allow empty directories)
47 if not os.path.exists(rootdir):
48 os.makedirs(rootdir)
49
50 # create all the entries
51 for filename, data in files:
52 filename = os.path.join(rootdir, filename)
53 if type(data) is dict:
54 buildDir(data, filename)
55 else:
56 d = os.path.dirname(filename)
57 if not os.path.exists(d):
58 os.makedirs(d)
59 f = open(filename, "w")
60 if data:
61 f.write(data)
62 f.close()
63
64 class PackWrap(cmt2cmake.Package):
65 """
66 Helper class to test the Package.
67 """
68 def __init__(self, name, requirements, files=None):
69 if not files:
70 files = {}
71 files["cmt/requirements"] = requirements
72
73 self.tmpdir = mkdtemp()
74 rootdir = os.path.join(self.tmpdir, name)
75 buildDir(files, rootdir)
76
77 super(PackWrap, self).__init__(rootdir)
78
79 def __del__(self):
80 shutil.rmtree(self.tmpdir, ignore_errors=False)
81
82 class ProjWrap(cmt2cmake.Project):
83 """
84 Helper class to test the Project.
85 """
86 def __init__(self, name, proj_cmt, files=None):
87 if not files:
88 files = {}
89 files["cmt/project.cmt"] = proj_cmt
90
91 self.tmpdir = mkdtemp()
92 rootdir = os.path.join(self.tmpdir, name)
93 buildDir(files, rootdir)
94
95 super(ProjWrap, self).__init__(rootdir)
96
97 def __del__(self):
98 shutil.rmtree(self.tmpdir, ignore_errors=False)
99
100
101 def getCalls(function, cmakelists):
102 '''
103 extracts the arguments to all the calls to a cmake function
104 '''
105 exp = re.compile(r'\b{0}\s*\(([^)]*)\)'.format(function), flags=re.MULTILINE)
106 return [m.group(1) for m in exp.finditer(cmakelists)]
107
108 #
109 # Tests
110 #
111
112 def test_not_a_package():
113 d = mkdtemp()
114 buildDir({'NoPackage': {'a_file.txt': None}}, d)
115 try:
116 cmt2cmake.Package(os.path.join(d, 'NoPackage'))
117 assert False, 'bad package not recognized'
118 except ValueError:
119 pass
120 finally:
121 shutil.rmtree(d)
122
123
124 def test_pack_header():
125 requirements = """
126 package ThisIsAPackage
127 version v123r456
128
129 branches cmt branches are ignored
130 macro test parsing of \\
131 multi line
132 """
133 pkg = PackWrap("ThisIsAPackage", requirements)
134
135 cmakelists = pkg.generate()
136 print cmakelists
137
138 calls = getCalls("gaudi_subdir", cmakelists)
139 assert calls, "gaudi_subdir not called"
140 assert len(calls) == 1, "gaudi_subdir called more than once"
141
142 args = calls[0].strip().split()
143 assert args == ["ThisIsAPackage", "v123r456"], args
144
145 def test_pack_deps():
146 requirements = """
147 package Test
148 version v1r0
149
150 # series of uses
151 use GaudiKernel v*
152 use GaudiAlg *
153 use GaudiPolicy *
154 use GaudiCoreSvc v* # comment
155 use GaudiUtils * -no_auto_imports
156
157 use LHCbKernel v* Kernel
158 """
159 pkg = PackWrap("Test", requirements)
160
161 cmakelists = pkg.generate()
162 print cmakelists
163
164 calls = getCalls("gaudi_depends_on_subdirs", cmakelists)
165 assert calls, "gaudi_depends_on_subdirs not called"
166
167 args = set()
168 for call in calls:
169 args.update(call.strip().split())
170 expected = set(['GaudiKernel', 'GaudiAlg', 'GaudiCoreSvc',
171 'GaudiUtils', 'Kernel/LHCbKernel'])
172 assert args == expected
173
174 def test_pack_no_deps():
175 requirements = """
176 package Test
177 version v1r0
178
179 # no uses
180 """
181 pkg = PackWrap("Test", requirements)
182
183 cmakelists = pkg.generate()
184 print cmakelists
185
186 calls = getCalls("gaudi_depends_on_subdirs", cmakelists)
187 assert not calls, "gaudi_depends_on_subdirs called"
188
189 def test_pack_ext_deps():
190 requirements = """
191 package Test
192 version v1r0
193
194 # series of uses
195 use Boost v* LCG_Interfaces
196 use Python v* LCG_Interfaces
197 use XercesC v* LCG_Interfaces -no_auto_imports
198 """
199 pkg = PackWrap("Test", requirements)
200
201 cmakelists = pkg.generate()
202 print cmakelists
203
204 expected = set(['Boost', 'XercesC'])
205
206 calls = getCalls("find_package", cmakelists)
207 assert calls, "find_pacakge not called"
208 assert len(calls) == len(expected)
209
210 args = set()
211 for call in calls:
212 args.add(call.strip().split()[0])
213 print args
214 assert args == expected
215
216 def test_install_headers():
217 requirements = '''
218 #============================================================================
219 package Tell1Kernel
220 version v1r12p1
221
222 # Structure, i.e. directories to process.
223 #============================================================================
224 branches cmt doc Tell1Kernel
225
226 # Used packages
227 #============================================================================
228 use GaudiPolicy v*
229
230 apply_pattern install_more_includes more=Tell1Kernel
231 '''
232 pkg = PackWrap("Tell1Kernel", requirements, files={"Tell1Kernel/hdr.h": None})
233
234 cmakelists = pkg.generate()
235 print cmakelists
236
237 calls = getCalls("gaudi_install_headers", cmakelists)
238 assert calls
239
240 args = set()
241 for call in calls:
242 args.update(call.strip().split())
243 expected = set(['Tell1Kernel'])
244 assert args == expected
245
246 def test_install_python():
247 requirements = '''
248 package Test
249 version v1r0
250
251 apply_pattern install_python_modules
252 '''
253 pkg = PackWrap("Test", requirements, files={"python/Test/__init__.py": None})
254
255 cmakelists = pkg.generate()
256 print cmakelists
257
258 calls = getCalls("gaudi_install_python_modules", cmakelists)
259 assert calls
260
261 def test_install_python2():
262 requirements = '''
263 package Test
264 version v1r0
265
266 macro TestConfUserModules "Test.CustomModule1 Test.CustomModule2"
267
268 apply_pattern install_python_modules
269 '''
270 pkg = PackWrap("Test", requirements, files={"python/Test/__init__.py": None})
271
272 cmakelists = pkg.generate()
273 print cmakelists
274
275 calls = getCalls("gaudi_install_python_modules", cmakelists)
276 assert calls
277
278 calls = getCalls("set_property", cmakelists)
279 assert calls
280 args = calls[0].strip().split()
281 assert args == ['DIRECTORY', 'PROPERTY', 'CONFIGURABLE_USER_MODULES', 'Test.CustomModule1', 'Test.CustomModule2'], args
282
283 def test_install_scripts():
284 requirements = '''
285 package Test
286 version v1r0
287
288 apply_pattern install_scripts
289 '''
290 pkg = PackWrap("Test", requirements, files={"scripts/someScript": None})
291
292 cmakelists = pkg.generate()
293 print cmakelists
294
295 calls = getCalls("gaudi_install_scripts", cmakelists)
296 assert calls
297
298 def test_qmtest():
299 requirements = '''
300 package Test
301 version v1r0
302
303 apply_pattern QMTest
304 '''
305 pkg = PackWrap("Test", requirements, files={"tests/qmtest/test.qms/a_test.qmt": None})
306
307 cmakelists = pkg.generate()
308 print cmakelists
309
310 calls = getCalls("gaudi_add_test", cmakelists)
311 assert calls, "no test added"
312 assert len(calls) == 1, "gaudi_add_test called more than once"
313
314 args = calls[0].strip().split()
315 assert args == ["QMTest", "QMTEST"]
316
317 def test_libraries():
318 requirements = '''
319 package Test
320 version v1r0
321
322 library TestLib lib/*.cpp
323 apply_pattern linker_library library=TestLib
324
325 library TestComp component/*.cpp
326 apply_pattern component_library library=TestComp
327
328 library TestTestLib test/lib/*.cpp -group=tests
329 apply_pattern linker_library library=TestTestLib
330
331 library TestTestComp test/component/*.cpp -group=tests
332 apply_pattern component_library library=TestTestComp
333
334 apply_pattern install_more_includes more=TestIncludes
335 '''
336 pkg = PackWrap("Test", requirements, files={'TestIncludes': {}})
337
338 print 'components', pkg.component_libraries
339 print 'linker', pkg.linker_libraries
340 print 'libraries', pkg.libraries
341
342 assert pkg.component_libraries == set(['TestComp', 'TestTestComp'])
343 assert pkg.linker_libraries == set(['TestLib', 'TestTestLib'])
344 assert pkg.libraries
345
346 cmakelists = pkg.generate()
347 print cmakelists
348
349 calls = getCalls("gaudi_add_library", cmakelists)
350 assert len(calls) == 2, "gaudi_add_library wrong count %d" % len(calls)
351 l = calls[0]
352 assert re.match(r' *TestLib\b', l)
353 assert re.search(r'\bPUBLIC_HEADERS +TestIncludes', l)
354 l = calls[1]
355 assert re.match(r' *TestTestLib\b', l)
356 assert re.search(r'\bPUBLIC_HEADERS +TestIncludes', l)
357 assert re.search(r'\bLINK_LIBRARIES +TestLib', l)
358
359 calls = getCalls("gaudi_add_module", cmakelists)
360 assert len(calls) == 2, "gaudi_add_module wrong count %d" % len(calls)
361
362 l = calls[0]
363 assert re.match(r' *TestComp\b', l)
364 assert not re.search(r'\bPUBLIC_HEADERS\b', l)
365 assert re.search(r'\bLINK_LIBRARIES +TestLib', l)
366 l = calls[1]
367 assert re.match(r' *TestTestComp\b', l)
368 assert not re.search(r'\bPUBLIC_HEADERS', l)
369 assert re.search(r'\bLINK_LIBRARIES +TestLib +TestTestLib', l)
370
371 def test_libraries_2():
372 requirements = '''
373 package Test
374 version v1r0
375
376 use Boost v* LCG_Interfaces
377 use XercesC v* LCG_Interfaces -no_auto_imports
378
379 library Lib1 lib1/*.cpp
380 apply_pattern component_library library=Lib1
381
382 library Lib2 lib2/*.cpp -import=XercesC
383 apply_pattern component_library library=Lib2
384
385 # We do not use variables
386 library Lib3 lib3/*.cpp a_variable=some_value
387 apply_pattern component_library library=Lib3
388
389 # test that we can handle the '-import' before the sources
390 library Lib4 -import=XercesC lib4/*.cpp
391 apply_pattern component_library library=Lib4
392 '''
393 pkg = PackWrap("Test", requirements, files={})
394
395 print 'components', pkg.component_libraries
396 print 'libraries', pkg.libraries
397
398 assert pkg.component_libraries == set(['Lib1', 'Lib2', 'Lib3', 'Lib4'])
399 assert pkg.libraries
400
401 cmakelists = pkg.generate()
402 print cmakelists
403
404 calls = getCalls("gaudi_add_module", cmakelists)
405 assert len(calls) == 4, "gaudi_add_module wrong count %d" % len(calls)
406
407 l = calls[0]
408 assert re.match(r' *Lib1\b', l)
409 assert not re.search(r'\bPUBLIC_HEADERS\b', l)
410 assert re.search(r'\bLINK_LIBRARIES +Boost', l)
411 assert re.search(r'\bINCLUDE_DIRS +Boost', l)
412 l = calls[1]
413 assert re.match(r' *Lib2\b', l)
414 assert not re.search(r'\bPUBLIC_HEADERS', l)
415 assert re.search(r'\bLINK_LIBRARIES +Boost +XercesC', l)
416 assert re.search(r'\bINCLUDE_DIRS +Boost +XercesC', l)
417 l = calls[2]
418 assert re.match(r' *Lib3\b', l)
419 assert not re.search(r'\bPUBLIC_HEADERS', l)
420 assert re.search(r'\bLINK_LIBRARIES +Boost', l)
421 assert re.search(r'\bINCLUDE_DIRS +Boost', l)
422 l = calls[3]
423 assert re.match(r' *Lib4\b', l)
424 assert not re.search(r'\bPUBLIC_HEADERS', l)
425 assert re.search(r'\bLINK_LIBRARIES +Boost +XercesC', l)
426 assert re.search(r'\bINCLUDE_DIRS +Boost +XercesC', l)
427
428 def test_libraries_3():
429 # some corner cases
430 # FIXME: we should actually test the warning messages
431 requirements = '''
432 package Test
433 version v1r0
434
435 library Lib1
436 apply_pattern component_library library=Lib1
437
438 library Lib2 lib2/*.cpp
439 apply_pattern linker_library library=Lib2
440
441 library Lib3 lib3/*.cpp
442
443 library Lib4 lib4/*.cpp
444 apply_pattern linker_library library="Lib4"
445
446 '''
447 pkg = PackWrap("Test", requirements, files={})
448
449 print 'components', pkg.component_libraries
450 print 'linker', pkg.linker_libraries
451 print 'libraries', pkg.libraries
452
453 assert pkg.component_libraries == set(['Lib1'])
454 assert pkg.linker_libraries == set(['Lib2', 'Lib4'])
455 assert len(pkg.libraries) == 4
456
457 cmakelists = pkg.generate()
458 print cmakelists
459
460 calls = getCalls("gaudi_add_module", cmakelists)
461 assert len(calls) == 1, "gaudi_add_module wrong count %d" % len(calls)
462
463 l = calls[0]
464 assert re.match(r' *Lib1\b', l)
465 assert not re.search(r'\bPUBLIC_HEADERS\b', l)
466
467 calls = getCalls("gaudi_add_library", cmakelists)
468 assert len(calls) == 3, "gaudi_add_module wrong count %d" % len(calls)
469
470 l = calls[0]
471 assert re.match(r' *Lib2\b', l)
472 assert re.search(r'\bNO_PUBLIC_HEADERS', l)
473
474 l = calls[1]
475 assert re.match(r' *Lib3\b', l)
476 assert re.search(r'\bNO_PUBLIC_HEADERS', l)
477
478 l = calls[2]
479 assert re.match(r' *Lib4\b', l)
480 assert re.search(r'\bNO_PUBLIC_HEADERS', l)
481
482 def test_libraries_fix_src_path():
483 requirements = '''
484 package Test
485 version v1r0
486
487 library TestLib1 ../src/subdir/*.cpp
488 apply_pattern linker_library library=TestLib1
489
490 library TestLib2 ../tests/src/subdir/*.cpp
491 apply_pattern linker_library library=TestLib2
492
493 library TestLib3 subdir/*.cpp
494 apply_pattern linker_library library=TestLib3
495 '''
496 pkg = PackWrap("Test", requirements, files={'TestIncludes': {}})
497
498 assert pkg.linker_libraries == set(['TestLib1', 'TestLib2', 'TestLib3'])
499
500 cmakelists = pkg.generate()
501 print cmakelists
502
503 calls = getCalls("gaudi_add_library", cmakelists)
504 assert len(calls) == 3, "gaudi_add_library wrong count %d" % len(calls)
505
506 l = calls[0].strip().split()
507 assert l[0] == 'TestLib1'
508 assert l[1] == 'src/subdir/*.cpp'
509
510 l = calls[1].strip().split()
511 assert l[0] == 'TestLib2'
512 assert l[1] == 'tests/src/subdir/*.cpp'
513
514 l = calls[2].strip().split()
515 assert l[0] == 'TestLib3'
516 assert l[1] == 'src/subdir/*.cpp'
517
518 def test_subdir_links():
519 requirements = '''
520 package Test
521 version v1r0
522
523 use Boost v* LCG_Interfaces
524 use XercesC v* LCG_Interfaces -no_auto_imports
525
526 use GaudiKernel *
527 use GaudiUtils * -no_auto_imports
528
529
530 library Lib1 *.cpp
531 apply_pattern component_library library=Lib1
532
533 library Lib2 *.cpp -import=XercesC
534 apply_pattern component_library library=Lib2
535
536 library Lib3 *.cpp -import=GaudiUtils
537 apply_pattern component_library library=Lib3
538 '''
539 pkg = PackWrap("Test", requirements, files={})
540
541 print 'components', pkg.component_libraries
542 print 'linker', pkg.linker_libraries
543 print 'libraries', pkg.libraries
544
545 assert pkg.component_libraries == set(['Lib1', 'Lib2', 'Lib3'])
546 assert len(pkg.libraries) == 3
547
548 cmakelists = pkg.generate()
549 print cmakelists
550
551 calls = getCalls("gaudi_add_module", cmakelists)
552 assert len(calls) == 3, "gaudi_add_module wrong count %d" % len(calls)
553
554 l = calls[0].strip().split()
555 assert l[0] == 'Lib1'
556 links = set(l[l.index('LINK_LIBRARIES')+1:])
557 assert links == set(['Boost', 'GaudiKernel'])
558
559 l = calls[1].strip().split()
560 assert l[0] == 'Lib2'
561 assert 'LINK_LIBRARIES' in l
562 links = set(l[l.index('LINK_LIBRARIES')+1:])
563 assert links == set(['Boost', 'GaudiKernel', 'XercesC'])
564
565 l = calls[2].strip().split()
566 assert l[0] == 'Lib3'
567 assert 'LINK_LIBRARIES' in l
568 links = set(l[l.index('LINK_LIBRARIES')+1:])
569 assert links == set(['Boost', 'GaudiKernel', 'GaudiUtilsLib'])
570
571 def test_subdir_links_hat():
572 requirements = '''
573 package Test
574 version v1r0
575
576 use LHCbKernel * Kernel
577 use SomeSubdir * Hat -no_auto_imports
578
579 library Lib1 *.cpp
580 apply_pattern component_library library=Lib1
581
582 library Lib2 *.cpp -import=SomeSubdir
583 apply_pattern component_library library=Lib2
584 '''
585 pkg = PackWrap("Test", requirements, files={})
586
587 print 'components', pkg.component_libraries
588 print 'linker', pkg.linker_libraries
589 print 'libraries', pkg.libraries
590
591 assert pkg.component_libraries == set(['Lib1', 'Lib2'])
592 assert len(pkg.libraries) == 2
593
594 cmakelists = pkg.generate()
595 print cmakelists
596
597 calls = getCalls("gaudi_add_module", cmakelists)
598 assert len(calls) == 2, "gaudi_add_module wrong count %d" % len(calls)
599
600 l = calls[0].strip().split()
601 assert l[0] == 'Lib1'
602 links = set(l[l.index('LINK_LIBRARIES')+1:])
603 assert links == set(['LHCbKernel'])
604
605 l = calls[1].strip().split()
606 assert l[0] == 'Lib2'
607 links = set(l[l.index('LINK_LIBRARIES')+1:])
608 assert links == set(['LHCbKernel', 'SubdirLib'])
609
610 def test_subdir_links_missing():
611 requirements = '''
612 package Test
613 version v1r0
614
615 use UnknownSubdir *
616
617 library Lib1 *.cpp
618 apply_pattern component_library library=Lib1
619 '''
620 pkg = PackWrap("Test", requirements, files={})
621
622 assert pkg.component_libraries == set(['Lib1'])
623 assert len(pkg.libraries) == 1
624
625 cmakelists = pkg.generate()
626 print cmakelists
627
628 calls = getCalls("gaudi_add_module", cmakelists)
629 assert len(calls) == 1, "gaudi_add_module wrong count %d" % len(calls)
630
631 l = calls[0].strip().split()
632 assert l[0] == 'Lib1'
633 assert 'LINK_LIBRARIES' not in l
634 # FIXME: we should test the warning
635
636 def test_subdir_links_update():
637 if 'GaudiDummy' in cmt2cmake.cache:
638 del cmt2cmake.cache['GaudiDummy']
639
640 requirements = '''
641 package GaudiDummy
642 version v1r0
643
644 apply_pattern install_more_includes more=Dummy
645
646 library Dummy *.cpp
647 apply_pattern linker_library library=Dummy
648 '''
649 PackWrap("GaudiDummy", requirements, files={'Dummy':{}})
650
651 assert cmt2cmake.cache['GaudiDummy']['libraries'] == ['Dummy']
652 assert cmt2cmake.cache['GaudiDummy']['includes'] == False
653
654 def test_subdir_headers():
655 if 'GaudiDummy' in cmt2cmake.cache:
656 del cmt2cmake.cache['GaudiDummy']
657
658 requirements = '''
659 package GaudiDummy
660 version v1r0
661
662 use JustHeaders v*
663 use JustHeaders v* Hat
664
665 library Dummy *.cpp
666 apply_pattern linker_library library=Dummy
667 '''
668 pkg = PackWrap("GaudiDummy", requirements, files={'Dummy':{}})
669
670 cmakelists = pkg.generate()
671 print cmakelists
672
673 calls = getCalls("gaudi_add_library", cmakelists)
674 assert len(calls) == 1, "gaudi_add_library wrong count %d" % len(calls)
675
676 l = calls[0].strip().split()
677 assert l[0] == 'Dummy'
678 assert 'INCLUDE_DIRS' in l
679 links = set(l[l.index('INCLUDE_DIRS')+1:])
680 assert links == set(['JustHeaders', 'Hat/JustHeaders'])
681
682 def test_subdir_headers_update():
683 if 'GaudiDummy' in cmt2cmake.cache:
684 del cmt2cmake.cache['GaudiDummy']
685
686 requirements = '''
687 package GaudiDummy
688 version v1r0
689
690 apply_pattern install_more_includes more=Dummy
691 '''
692 PackWrap("GaudiDummy", requirements, files={'Dummy':{}})
693
694 assert cmt2cmake.cache['GaudiDummy']['includes'] == True
695 assert not cmt2cmake.cache['GaudiDummy']['libraries']
696
697 def test_write_file():
698 requirements = '''
699 package Test
700 version v1r0
701
702 library Lib1 *.cpp
703 apply_pattern component_library library=Lib1
704 '''
705 pkg = PackWrap("Test", requirements, files={})
706
707 cmakelists = pkg.generate()
708 print cmakelists
709
710 cmakefile = os.path.join(pkg.path, 'CMakeLists.txt')
711 pkg.process()
712 assert os.path.exists(cmakefile)
713 assert open(cmakefile).read() == cmakelists
714
715 def test_write_file_exists():
716 requirements = '''
717 package Test
718 version v1r0
719
720 library Lib1 *.cpp
721 apply_pattern component_library library=Lib1
722 '''
723 pkg = PackWrap("Test", requirements, files={'CMakeLists.txt': 'dummy data'})
724
725 cmakefile = os.path.join(pkg.path, 'CMakeLists.txt')
726 pkg.process()
727 # FIXME: we should test the warning
728 assert open(cmakefile).read() == 'dummy data'
729
730
731 def test_god_1():
732 # some corner cases
733 # FIXME: we should actually test the warning messages
734 requirements = '''
735 package Test
736 version v1r0
737
738 apply_pattern god_headers files=../xml/*.xml
739 '''
740 pkg = PackWrap("Test", requirements, files={})
741
742 cmakelists = pkg.generate()
743 print cmakelists
744
745 calls = getCalls("include", cmakelists)
746 assert calls
747 l = calls[0].strip()
748 assert l == 'GaudiObjDesc'
749
750 calls = getCalls("god_build_headers", cmakelists)
751 assert len(calls) == 1, "god_build_headers wrong count %d" % len(calls)
752
753 l = calls[0].strip()
754 assert l == 'xml/*.xml'
755
756 def test_god_2():
757 requirements = '''
758 package Test
759 version v1r0
760
761 apply_pattern god_dictionary files=../xml/*.xml
762 '''
763 pkg = PackWrap("Test", requirements, files={})
764
765 cmakelists = pkg.generate()
766 print cmakelists
767
768 calls = getCalls("include", cmakelists)
769 assert calls
770 l = calls[0].strip()
771 assert l == 'GaudiObjDesc'
772
773 calls = getCalls("god_build_dictionary", cmakelists)
774 assert len(calls) == 1, "god_build_dictionary wrong count %d" % len(calls)
775
776 l = calls[0].strip()
777 assert l == 'xml/*.xml'
778
779 def test_god_3():
780 requirements = '''
781 package Test
782 version v1r0
783
784 use Boost v* LCG_Interfaces
785
786 apply_pattern god_headers files=../xml/*.xml
787 apply_pattern god_dictionary files=../xml/*.xml
788 '''
789 pkg = PackWrap("Test", requirements, files={})
790
791 cmakelists = pkg.generate()
792 print cmakelists
793
794 calls = getCalls("include", cmakelists)
795 assert calls
796 l = calls[0].strip()
797 assert l == 'GaudiObjDesc'
798
799 calls = getCalls("god_build_headers", cmakelists)
800 assert len(calls) == 1, "god_build_headers wrong count %d" % len(calls)
801
802 calls = getCalls("god_build_dictionary", cmakelists)
803 assert len(calls) == 1, "god_build_dictionary wrong count %d" % len(calls)
804
805 l = calls[0].strip().split()
806 assert l[0] == 'xml/*.xml'
807 assert 'LINK_LIBRARIES' in l
808 assert l[l.index('LINK_LIBRARIES')+1] == 'Boost'
809 assert 'INCLUDE_DIRS' in l
810 assert l[l.index('INCLUDE_DIRS')+1] == 'Boost'
811
812 def test_god_4():
813 requirements = '''
814 package Test
815 version v1r0
816
817 use Boost v* LCG_Interfaces
818
819 library Lib *.cpp
820 apply_pattern linker_library library=Lib
821
822 apply_pattern god_headers files=../xml/*.xml
823 apply_pattern god_dictionary files=../xml/*.xml
824 '''
825 pkg = PackWrap("Test", requirements, files={})
826
827 cmakelists = pkg.generate()
828 print cmakelists
829
830 calls = getCalls("include", cmakelists)
831 assert calls
832 l = calls[0].strip()
833 assert l == 'GaudiObjDesc'
834
835 calls = getCalls("god_build_headers", cmakelists)
836 assert len(calls) == 1, "god_build_headers wrong count %d" % len(calls)
837
838 calls = getCalls("gaudi_add_library", cmakelists)
839 assert len(calls) == 1, "gaudi_add_library wrong count %d" % len(calls)
840
841 calls = getCalls("god_build_dictionary", cmakelists)
842 assert len(calls) == 1, "god_build_dictionary wrong count %d" % len(calls)
843
844 l = calls[0].strip().split()
845 assert l[0] == 'xml/*.xml'
846 assert 'LINK_LIBRARIES' in l
847 i = l.index('LINK_LIBRARIES')+1
848 assert l[i:i+2] == ['Boost', 'Lib']
849 assert 'INCLUDE_DIRS' in l
850 assert l[l.index('INCLUDE_DIRS')+1] == 'Boost'
851
852 hdr = cmakelists.find('god_build_headers')
853 lib = cmakelists.find('gaudi_add_library')
854 dct = cmakelists.find('god_build_dictionary')
855 assert hdr < lib and lib < dct, "wrong order of calls"
856
857 def test_god_5():
858 requirements = '''
859 package Test
860 version v1r0
861
862 apply_pattern god_headers files=../xml/*.xml
863 macro TestObj2Doth_GODflags " -s ../Test/ "
864 '''
865 pkg = PackWrap("Test", requirements, files={})
866
867 cmakelists = pkg.generate()
868 print cmakelists
869
870 calls = getCalls("include", cmakelists)
871 assert calls
872 l = calls[0].strip()
873 assert l == 'GaudiObjDesc'
874
875 calls = getCalls("god_build_headers", cmakelists)
876 assert len(calls) == 1, "god_build_headers wrong count %d" % len(calls)
877
878 l = calls[0].strip().split()
879 assert l[0] == 'xml/*.xml'
880 assert 'DESTINATION' in l
881 assert l[l.index('DESTINATION')+1] == 'Test'
882
883 def test_god_6():
884 requirements = '''
885 package Test
886 version v1r0
887
888 apply_pattern god_headers files=../xml/*.xml
889 macro TestObj2Doth_GODflags " -s ../src/ "
890 '''
891 pkg = PackWrap("Test", requirements, files={})
892
893 cmakelists = pkg.generate()
894 print cmakelists
895
896 calls = getCalls("include", cmakelists)
897 assert calls
898 l = calls[0].strip()
899 assert l == 'GaudiObjDesc'
900
901 calls = getCalls("god_build_headers", cmakelists)
902 assert len(calls) == 1, "god_build_headers wrong count %d" % len(calls)
903
904 l = calls[0].strip().split()
905 assert l[0] == 'xml/*.xml'
906 assert 'PRIVATE' in l
907 assert 'DESTINTAION' not in l
908
909 def test_god_7():
910 requirements = '''
911 package Test
912 version v1r0
913
914 document customdict TestCustomDict ../dict/TestCustomDict.h
915
916 apply_pattern god_dictionary files=../xml/*.xml
917 '''
918 pkg = PackWrap("Test", requirements, files={})
919
920 cmakelists = pkg.generate()
921 print cmakelists
922
923 calls = getCalls("include", cmakelists)
924 assert calls
925 l = calls[0].strip()
926 assert l == 'GaudiObjDesc'
927
928 calls = getCalls("god_build_dictionary", cmakelists)
929 assert len(calls) == 1, "god_build_dictionary wrong count %d" % len(calls)
930
931 l = calls[0].strip().split()
932 assert l == ['xml/*.xml', 'EXTEND', 'dict/TestCustomDict.h']
933
934 def test_reflex():
935 requirements = '''
936 package Test
937 version v1r0
938
939 use ROOT v* LCG_Interfaces
940
941 apply_pattern reflex_dictionary \\
942 dictionary=Test \\
943 headerfiles=$(TESTROOT)/dict/TestDict.h \\
944 selectionfile=$(TESTROOT)/dict/TestDict.xml
945
946 apply_pattern reflex_dictionary \\
947 dictionary=Test2 \\
948 headerfiles=$(TESTROOT)/dict/Test2Dict.h \\
949 selectionfile=$(TESTROOT)/dict/Test2Dict.xml \\
950 options="-DOPTION"
951 '''
952 pkg = PackWrap("Test", requirements, files={})
953
954 cmakelists = pkg.generate()
955 print cmakelists
956
957 calls = getCalls("gaudi_add_dictionary", cmakelists)
958 assert len(calls) == 2, "gaudi_add_dictionary wrong count %d" % len(calls)
959
960 l = calls[0].strip().split()
961 assert l[0:3] == ['Test', 'dict/TestDict.h', 'dict/TestDict.xml']
962 assert 'LINK_LIBRARIES' in l
963 assert l[l.index('LINK_LIBRARIES')+1] == 'ROOT'
964 assert 'INCLUDE_DIRS' in l
965 assert l[l.index('INCLUDE_DIRS')+1] == 'ROOT'
966
967 l = calls[1].strip().split()
968 assert l[0:3] == ['Test2', 'dict/Test2Dict.h', 'dict/Test2Dict.xml']
969 assert 'LINK_LIBRARIES' in l
970 assert l[l.index('LINK_LIBRARIES')+1] == 'ROOT'
971 assert 'INCLUDE_DIRS' in l
972 assert l[l.index('INCLUDE_DIRS')+1] == 'ROOT'
973 assert 'OPTIONS' in l
974 assert l[l.index('OPTIONS')+1:] == ['"-DOPTION"']
975
976
977 def test_reflex_2():
978 requirements = '''
979 package Test
980 version v1r0
981
982 use ROOT v* LCG_Interfaces
983
984 library Test *.ccp
985 apply_pattern component_library library=Test
986
987 apply_pattern reflex_dictionary \\
988 dictionary=Test \\
989 headerfiles=$(TESTROOT)/dict/TestDict.h \\
990 selectionfile=$(TESTROOT)/dict/TestDict.xml
991 '''
992 pkg = PackWrap("Test", requirements, files={})
993
994 cmakelists = pkg.generate()
995 print cmakelists
996
997 calls = getCalls("gaudi_add_module", cmakelists)
998 assert len(calls) == 1, "gaudi_add_module wrong count %d" % len(calls)
999
1000 l = calls[0].strip().split()
1001 assert l[0] == 'Test'
1002
1003 calls = getCalls("gaudi_add_dictionary", cmakelists)
1004 assert len(calls) == 1, "gaudi_add_dictionary wrong count %d" % len(calls)
1005
1006 l = calls[0].strip().split()
1007 assert l[0:3] == ['Test', 'dict/TestDict.h', 'dict/TestDict.xml']
1008
1009 def test_reflex_3():
1010 requirements = '''
1011 package Test
1012 version v1r0
1013
1014 use ROOT v* LCG_Interfaces
1015 use COOL v* LCG_Interfaces -no_auto_imports
1016 use CORAL v* LCG_Interfaces -no_auto_imports
1017 use Boost v* LCG_Interfaces -no_auto_imports
1018
1019 library Test *.ccp
1020 apply_pattern component_library library=Test
1021
1022 apply_pattern reflex_dictionary \\
1023 dictionary=Test \\
1024 headerfiles=$(TESTROOT)/dict/TestDict.h \\
1025 selectionfile=$(TESTROOT)/dict/TestDict.xml \\
1026 imports="COOL -import=CORAL -import=Boost"
1027 '''
1028 pkg = PackWrap("Test", requirements, files={})
1029
1030 cmakelists = pkg.generate()
1031 print cmakelists
1032
1033 calls = getCalls("gaudi_add_module", cmakelists)
1034 assert len(calls) == 1, "gaudi_add_module wrong count %d" % len(calls)
1035
1036 l = calls[0].strip().split()
1037 assert l[0] == 'Test'
1038
1039 calls = getCalls("gaudi_add_dictionary", cmakelists)
1040 assert len(calls) == 1, "gaudi_add_dictionary wrong count %d" % len(calls)
1041
1042 l = calls[0].strip().split()
1043 assert l[0:3] == ['Test', 'dict/TestDict.h', 'dict/TestDict.xml']
1044 assert 'INCLUDE_DIRS' in l
1045 i = l.index('INCLUDE_DIRS')
1046 assert 'LINK_LIBRARIES' in l
1047 j = l.index('LINK_LIBRARIES')
1048 assert set(l[i+1:j]) == set(['ROOT', 'COOL', 'CORAL', 'Boost'])
1049 assert set(l[j+1:]) == set(['ROOT', 'COOL', 'CORAL', 'Boost'])
1050
1051 def test_linkopts():
1052 requirements = '''
1053 package Test
1054 version v1r0
1055
1056 use ROOT v* LCG_Interfaces
1057 use Boost v* LCG_Interfaces
1058
1059 macro_append ROOT_linkopts " -lMathCore"
1060 macro_append Boost_linkopts " $(Boost_linkopts_filesystem)"
1061
1062 '''
1063 pkg = PackWrap("Test", requirements, files={})
1064
1065 cmakelists = pkg.generate()
1066 print cmakelists
1067
1068 calls = getCalls("find_package", cmakelists)
1069 assert len(calls) == 2, "find_package wrong count %d" % len(calls)
1070
1071 l = calls[0].strip().split()
1072 assert l == ['Boost', 'COMPONENTS', 'filesystem'] # find_package are sorted
1073
1074 l = calls[1].strip().split()
1075 assert l == ['ROOT', 'COMPONENTS', 'MathCore'] # find_package are sorted
1076
1077 def test_application():
1078 requirements = '''
1079 package Test
1080 version v1r0
1081
1082 application MyApp1 ../src/app1/*.cpp
1083
1084 application MyApp2 -group=tests ../src/app2/*.cpp
1085
1086 application MyApp3 -check ../src/app3/*.cpp
1087
1088 application MyApp4 ../tests/src/app4.cpp
1089
1090 application MyTestApp app5a.cpp app5b.cpp
1091 '''
1092 pkg = PackWrap("Test", requirements, files={})
1093
1094 cmakelists = pkg.generate()
1095 print cmakelists
1096
1097 calls = getCalls("gaudi_add_executable", cmakelists)
1098 assert len(calls) == 5, "gaudi_add_executable wrong count %d" % len(calls)
1099
1100 l = calls[0].strip().split()
1101 assert l[0] == 'MyApp1'
1102 assert l[1:] == ['src/app1/*.cpp']
1103
1104 l = calls[1].strip().split()
1105 assert l[0] == 'MyApp2'
1106 assert l[1:] == ['src/app2/*.cpp']
1107
1108 l = calls[2].strip().split()
1109 assert l[0] == 'MyApp3'
1110 assert l[1:] == ['src/app3/*.cpp']
1111
1112 l = calls[3].strip().split()
1113 assert l[0] == 'MyApp4'
1114 assert l[1:] == ['tests/src/app4.cpp']
1115
1116 l = calls[4].strip().split()
1117 assert l[0] == 'MyTestApp'
1118 assert l[1:] == ['src/app5a.cpp', 'src/app5b.cpp']
1119
1120 calls = getCalls("if", cmakelists)
1121 assert calls == ['GAUDI_BUILD_TESTS'] * 4
1122
1123 def test_pyqt_patterns():
1124 requirements = '''
1125 package Test
1126 version v1r0
1127
1128 use pygraphics v* LCG_Interfaces -no_auto_imports
1129 use Qt v* LCG_Interfaces -no_auto_imports
1130
1131 apply_pattern install_python_modules
1132
1133 apply_pattern PyQtResource qrc_files=../qt_resources/*.qrc outputdir=../python/Test/QtApp
1134 apply_pattern PyQtUIC ui_files=../qt_resources/*.ui outputdir=../python/Test/QtApp
1135 macro_append Test_python_dependencies " PyQtResource PyQtUIC "
1136 '''
1137 pkg = PackWrap("Test", requirements, files={})
1138
1139 cmakelists = pkg.generate()
1140 print cmakelists
1141
1142 calls = getCalls("gen_pyqt_resource", cmakelists)
1143 assert len(calls) == 1, "gen_pyqt_resource wrong count %d" % len(calls)
1144 l = calls[0].strip().split()
1145 assert l == ['Test.QtApp.Resources', 'Test/QtApp', 'qt_resources/*.qrc']
1146
1147 calls = getCalls("gen_pyqt_uic", cmakelists)
1148 assert len(calls) == 1, "gen_pyqt_uic wrong count %d" % len(calls)
1149 l = calls[0].strip().split()
1150 assert l == ['Test.QtApp.UI', 'Test/QtApp', 'qt_resources/*.ui']
1151
1152
1153 def test_line_cont():
1154 requirements = '''
1155 package Test
1156 version v1r0
1157
1158 library Test *.ccp
1159
1160 macro TEST "value" \\
1161
1162 apply_pattern component_library library=Test
1163 '''
1164 pkg = PackWrap("Test", requirements, files={})
1165
1166 cmakelists = pkg.generate()
1167 print cmakelists
1168
1169 calls = getCalls("gaudi_add_module", cmakelists)
1170 assert len(calls) == 1, "gaudi_add_module wrong count %d" % len(calls)
1171
1172
1173 def test_line_copy_relax():
1174 requirements = '''
1175 package Test
1176 version v1r0
1177
1178 use RELAX v* LCG_Interfaces
1179
1180 copy_relax_rootmap dict=CLHEP
1181 copy_relax_rootmap dict=HepMC
1182 copy_relax_rootmap dict=STL
1183 copy_relax_rootmap dict=Math
1184 '''
1185 pkg = PackWrap("Test", requirements, files={})
1186
1187 cmakelists = pkg.generate()
1188 print cmakelists
1189
1190 calls = getCalls("find_package", cmakelists)
1191 assert len(calls) == 1, "find_package wrong count %d" % len(calls)
1192
1193 l = calls[0].strip().split()
1194 assert l == ['RELAX', 'REQUIRED', 'COMPONENTS', 'CLHEP', 'HepMC', 'STL', 'Math']
1195
1196 calls = getCalls("add_custom_target", cmakelists)
1197 assert len(calls) == 1, "add_custom_target wrong count %d" % len(calls)
1198
1199 l = calls[0].strip().split()
1200 assert l == ['RelaxRootmap', 'ALL', 'DEPENDS', '${rootmapfile}']
1201
1202 # No need to check every call, just that the sequence is there
1203
1204
1205 def test_project():
1206 proj_cmt = '''
1207 project LHCB
1208
1209 use GAUDI GAUDI_v23r4
1210 use DBASE
1211 use PARAM
1212
1213 build_strategy with_installarea
1214 setup_strategy root
1215 '''
1216 files = {"LHCbSys": {"cmt": {"requirements": "version v35r2"}}}
1217 proj = ProjWrap("LHCb", proj_cmt, files=files)
1218
1219 cmakelists = proj.generate()
1220 print cmakelists
1221
1222 calls = getCalls("find_package", cmakelists)
1223 assert len(calls) == 1, "find_package wrong count %d" % len(calls)
1224
1225 l = calls[0].strip().split()
1226 assert l == ['GaudiProject']
1227
1228 calls = getCalls("gaudi_project", cmakelists)
1229 assert len(calls) == 1, "gaudi_project wrong count %d" % len(calls)
1230
1231 l = calls[0].strip().split()
1232 assert l == ['LHCb', 'v35r2', 'USE', 'Gaudi', 'v23r4']
1233
1234 def test_data_pkg_1():
1235 proj_cmt = '''
1236 project TestProject
1237 '''
1238 files = {"TestProjectSys": {"cmt": {"requirements": "version v1r0"}},
1239 "Package1": {"cmt": {"requirements":
1240 '''
1241 version v1r0
1242
1243 use DtPkg v7r* Another
1244 use DataPack v*
1245 use SpecialThing *
1246 '''}},
1247 }
1248 proj = ProjWrap("TestProject", proj_cmt, files=files)
1249
1250 cmakelists = proj.generate()
1251 print cmakelists
1252
1253 calls = getCalls("find_package", cmakelists)
1254 assert len(calls) == 1, "find_package wrong count %d" % len(calls)
1255
1256 l = calls[0].strip().split()
1257 assert l == ['GaudiProject']
1258
1259 calls = getCalls("gaudi_project", cmakelists)
1260 assert len(calls) == 1, "gaudi_project wrong count %d" % len(calls)
1261
1262 l = calls[0].strip().split()
1263 assert l == ['TestProject', 'v1r0', 'DATA',
1264 'Another/DtPkg', 'VERSION', 'v7r*',
1265 'DataPack',
1266 'SpecialThing']
1267
1268 def test_data_pkg_2():
1269 proj_cmt = '''
1270 project TestProject
1271 '''
1272 files = {"TestProjectSys": {"cmt": {"requirements": "version v1r0"}},
1273 "Package1": {"cmt": {"requirements":
1274 '''
1275 version v1r0
1276
1277 use DataPack v*
1278 '''}},
1279 "Package2": {"cmt": {"requirements":
1280 '''
1281 version v1r0
1282
1283 use SpecialThing *
1284 '''}},
1285 }
1286 proj = ProjWrap("TestProject", proj_cmt, files=files)
1287
1288 cmakelists = proj.generate()
1289 print cmakelists
1290
1291 calls = getCalls("find_package", cmakelists)
1292 assert len(calls) == 1, "find_package wrong count %d" % len(calls)
1293
1294 l = calls[0].strip().split()
1295 assert l == ['GaudiProject']
1296
1297 calls = getCalls("gaudi_project", cmakelists)
1298 assert len(calls) == 1, "gaudi_project wrong count %d" % len(calls)
1299
1300 l = calls[0].strip().split()
1301 assert l == ['TestProject', 'v1r0', 'DATA',
1302 'DataPack',
1303 'SpecialThing']
1304
1305 def test_data_pkg_3():
1306 proj_cmt = '''
1307 project TestProject
1308 '''
1309 files = {"TestProjectSys": {"cmt": {"requirements": "version v1r0"}},
1310 "Package1": {"cmt": {"requirements":
1311 '''
1312 version v1r0
1313
1314 use DataPack v7r*
1315 '''}},
1316 "Package2": {"cmt": {"requirements":
1317 '''
1318 version v1r0
1319
1320 use DataPack v*
1321 use DtPkg v1r0 Another
1322 '''}},
1323 }
1324 proj = ProjWrap("TestProject", proj_cmt, files=files)
1325
1326 cmakelists = proj.generate()
1327 print cmakelists
1328
1329 calls = getCalls("find_package", cmakelists)
1330 assert len(calls) == 1, "find_package wrong count %d" % len(calls)
1331
1332 l = calls[0].strip().split()
1333 assert l == ['GaudiProject']
1334
1335 calls = getCalls("gaudi_project", cmakelists)
1336 assert len(calls) == 1, "gaudi_project wrong count %d" % len(calls)
1337
1338 l = calls[0].strip().split()
1339 assert l == ['TestProject', 'v1r0', 'DATA',
1340 'Another/DtPkg', 'VERSION', 'v1r0',
1341 'DataPack', 'VERSION', 'v7r*']
1342
1343 def test_heptools_1():
1344 # check the case of LCGCMT in the project.cmt
1345 proj_cmt = '''
1346 project TestProjectHT
1347
1348 use LCGCMT LCGCMT_64a
1349 '''
1350 files = {"TestProjectHTSys": {"cmt": {"requirements": "version v1r0"}}}
1351 proj = ProjWrap("TestProjectHT", proj_cmt, files=files)
1352
1353 k = repr(('TestProjectHT', 'v1r0'))
1354 assert k not in cmt2cmake.cache
1355
1356 toolchain = proj.generateToolchain()
1357 print toolchain
1358
1359 calls = getCalls("set", toolchain)
1360 assert len(calls) == 2, "set wrong count %d" % len(calls)
1361
1362 l = calls[0].strip().split()
1363 assert l == ['heptools_version', '64a']
1364
1365 assert k in cmt2cmake.cache
1366 assert cmt2cmake.cache[k] == {'heptools': '64a'}
1367
1368 def test_heptools_2():
1369 # check the case of LCGCMT in a used project (already in the cache)
1370 proj_cmt = '''
1371 project TestProjectHT
1372
1373 use BASEPROJECT BASEPROJECT_v1r0
1374 '''
1375 files = {"TestProjectHTSys": {"cmt": {"requirements": "version v2r0"}}}
1376 proj = ProjWrap("TestProjectHT", proj_cmt, files=files)
1377
1378 k = repr(('TestProjectHT', 'v2r0'))
1379 assert k not in cmt2cmake.cache
1380
1381 toolchain = proj.generateToolchain()
1382 print toolchain
1383
1384 calls = getCalls("set", toolchain)
1385 assert len(calls) == 2, "set wrong count %d" % len(calls)
1386
1387 l = calls[0].strip().split()
1388 assert l == ['heptools_version', '65']
1389
1390 assert k in cmt2cmake.cache
1391 assert cmt2cmake.cache[k] == {'heptools': '65'}
1392
1393 def test_heptools_3():
1394 # check the case of LCGCMT not declared, but in the cache for us
1395 proj_cmt = '''
1396 project TestProjectHT
1397 '''
1398 files = {"TestProjectHTSys": {"cmt": {"requirements": "version v3r0"}}}
1399 proj = ProjWrap("TestProjectHT", proj_cmt, files=files)
1400
1401 k = repr(('TestProjectHT', 'v3r0'))
1402 assert k in cmt2cmake.cache
1403
1404 toolchain = proj.generateToolchain()
1405 print toolchain
1406
1407 calls = getCalls("set", toolchain)
1408 assert len(calls) == 2, "set wrong count %d" % len(calls)
1409
1410 l = calls[0].strip().split()
1411 assert l == ['heptools_version', '23']
1412
1413 assert k in cmt2cmake.cache
1414 assert cmt2cmake.cache[k] == {'heptools': '23'}
1415
1416 def test_heptools_4():
1417 # check the case of LCGCMT not found
1418 proj_cmt = '''
1419 project TestProjectHT
1420 '''
1421 files = {"TestProjectHTSys": {"cmt": {"requirements": "version v4r0"}}}
1422 proj = ProjWrap("TestProjectHT", proj_cmt, files=files)
1423
1424 k = repr(('TestProjectHT', 'v4r0'))
1425 assert k not in cmt2cmake.cache
1426
1427 toolchain = proj.generateToolchain()
1428 assert toolchain is None
1429
1430 assert k not in cmt2cmake.cache
1431
1432
1433
1434
1435 def test_alias():
1436 requirements = '''
1437 package Test
1438 version v1r0
1439
1440 alias MyCommand "Command"
1441 alias pypaw "pyroot -i "
1442 '''
1443 pkg = PackWrap("Test", requirements, files={})
1444
1445 cmakelists = pkg.generate()
1446 print cmakelists
1447
1448 calls = getCalls("gaudi_alias", cmakelists)
1449 assert len(calls) == 2
1450
1451 calls = sorted([x.strip().split() for x in calls])
1452
1453 assert calls[0] == ['MyCommand', 'Command'], calls[0]
1454
1455 assert calls[1] == ['pypaw', 'pyroot', '-i'], calls[1]
1456
1457
1458 from nose.core import main
1459 main()