445 |
445 |
446 self.assertTrue(lines == 1, "Wrong number of lines generated.") |
446 self.assertTrue(lines == 1, "Wrong number of lines generated.") |
447 |
447 |
448 finally: |
448 finally: |
449 if result_file1 != None: result_file1.close() |
449 if result_file1 != None: result_file1.close() |
|
450 |
|
451 def test_simple_generate_prj7_with_funcs_as_filters(self): |
|
452 |
|
453 self.remove_if_exists(os.path.normpath("output/output/test7a.txt")) |
|
454 self.remove_if_exists(os.path.normpath("output/output/test7b.txt")) |
|
455 self.remove_if_exists(os.path.normpath("output/output/test7c.txt")) |
|
456 |
|
457 (config,impl) = self.load_impl('Layer1/implml/file7.templateml') |
|
458 gc = plugin.GenerationContext(configuration=config) |
|
459 impl.generate(gc) |
|
460 |
|
461 self.assert_exists_and_contains_something(os.path.normpath("output/output/test7a.txt")) |
|
462 self.assert_exists_and_contains_something(os.path.normpath("output/output/test7b.txt")) |
|
463 self.assert_exists_and_contains_something(os.path.normpath("output/output/test7c.txt")) |
|
464 |
|
465 result_file1 = None |
|
466 result_file2 = None |
|
467 result_file3 = None |
|
468 |
|
469 try: |
|
470 result_file1 = open(os.path.normpath("output/output/test7a.txt")) |
|
471 result_file2 = open(os.path.normpath("output/output/test7b.txt")) |
|
472 result_file3 = open(os.path.normpath("output/output/test7c.txt")) |
|
473 |
|
474 if result_file1 != None: |
|
475 for line in result_file1: |
|
476 self.assertTrue(line == "3 + 4 = 7") |
|
477 else: |
|
478 self.fail("No result file found: output/output/test7a.txt") |
|
479 |
|
480 if result_file2 != None: |
|
481 for line in result_file2: |
|
482 self.assertTrue(line == "3 ** 4 = 81") |
|
483 else: |
|
484 self.fail("No result file found: output/output/test7b.txt") |
|
485 |
|
486 if result_file3 != None: |
|
487 for line in result_file3: |
|
488 self.assertTrue((line.strip() == "2!=3") or (line.strip() == "5=5")) |
|
489 else: |
|
490 self.fail("No result file found: output/output/test7c.txt") |
|
491 finally: |
|
492 if result_file1 != None: result_file1.close() |
|
493 if result_file2 != None: result_file2.close() |
|
494 if result_file2 != None: result_file3.close() |
|
495 |
|
496 |
|
497 def test_simple_generate_prj8_with_funcs_as_filters_under_output_elems(self): |
|
498 |
|
499 self.remove_if_exists(os.path.normpath("output/output/test8a.txt")) |
|
500 self.remove_if_exists(os.path.normpath("output/output/test8b.txt")) |
|
501 |
|
502 (config,impl) = self.load_impl('Layer1/implml/file8.templateml') |
|
503 gc = plugin.GenerationContext(configuration=config) |
|
504 impl.generate(gc) |
|
505 |
|
506 self.assert_exists_and_contains_something(os.path.normpath("output/output/test8a.txt")) |
|
507 self.assert_exists_and_contains_something(os.path.normpath("output/output/test8b.txt")) |
|
508 #self.assertTrue(os.path.exists(os.path.normpath("output/output/test8a.txt"))) |
|
509 #self.assertTrue(os.path.exists(os.path.normpath("output/output/test8b.txt"))) |
|
510 |
|
511 result_file1 = None |
|
512 result_file2 = None |
|
513 |
|
514 try: |
|
515 result_file1 = open(os.path.normpath("output/output/test8a.txt")) |
|
516 result_file2 = open(os.path.normpath("output/output/test8b.txt")) |
|
517 |
|
518 if result_file1 != None: |
|
519 for line in result_file1: |
|
520 self.assertTrue(line == "3 + 4 = 7") |
|
521 else: |
|
522 self.fail("No result file found: output/output/test8a.txt") |
|
523 |
|
524 if result_file2 != None: |
|
525 for line in result_file2: |
|
526 self.assertTrue(line == "3 ** 4 = 81") |
|
527 else: |
|
528 self.fail("No result file found: output/output/test8b.txt") |
|
529 |
|
530 finally: |
|
531 if result_file1 != None: result_file1.close() |
|
532 if result_file2 != None: result_file2.close() |
|
533 |
|
534 def test_filters_in_output_not_visible_to_other_outputs(self): |
|
535 self.remove_if_exists(os.path.normpath("output/output/test9a.txt")) |
|
536 self.remove_if_exists(os.path.normpath("output/output/test9b.txt")) |
|
537 (config,impl) = self.load_impl('Layer1/implml/file9.templateml') |
|
538 gc = plugin.GenerationContext(configuration=config) |
|
539 impl.generate(gc) |
|
540 self.assert_exists_and_contains_something(os.path.normpath("output/output/test9a.txt")) |
|
541 result_file1 = None |
|
542 try: |
|
543 result_file1 = open(os.path.normpath("output/output/test9a.txt")) |
|
544 |
|
545 if result_file1 != None: |
|
546 for line in result_file1: |
|
547 self.assertTrue(line == "3 + 4 = 7") |
|
548 else: |
|
549 self.fail("No result file found: output/output/test9a.txt") |
|
550 finally: |
|
551 if result_file1 != None: result_file1.close() |
|
552 |
|
553 # an empty file must be created |
|
554 self.assert_file_content_equals(os.path.normpath("output/output/test9b.txt"), "", ignore_endline_style=True) |
450 |
555 |
451 def test_generate_prj1(self): |
556 def test_generate_prj1(self): |
452 |
557 |
453 self.remove_if_exists(os.path.normpath("output/output/test5a.txt")) |
558 self.remove_if_exists(os.path.normpath("output/output/test5a.txt")) |
454 |
559 |