# HG changeset patch
# User Jeroen Demeyer <jdemeyer@cage.ugent.be>
# Date 1289516849 -3600
# Node ID 51391a6883cbcaf213630311da8eee63c89bb5ae
# Parent a96a519334af9afa47f4eab7a0739e1d6ed915e6
#10030: Check that sig_on_count() is 0 after every doctest
diff -r a96a519334af -r 51391a6883cb sage-doctest
a
|
b
|
|
451 | 451 | if ext in ['.py', '.sage']: |
452 | 452 | tmpfiles.append(os.path.join(SAGE_TESTDIR, name + '.pyc')) |
453 | 453 | |
| 454 | # Prefix/suffix for all doctests replacing the starting/ending """ |
| 455 | doc_prefix = 'r""">>> set_random_seed(0L)\n\n>>> change_warning_output(sys.stdout)\n\n' |
| 456 | doc_suffix = '\n>>> sig_on_count()\n0\n"""' |
| 457 | |
454 | 458 | n = 0 |
455 | 459 | while True: |
456 | 460 | i = F.find('"""') |
… |
… |
|
464 | 468 | except SyntaxError: |
465 | 469 | doc = F[i:j+3] |
466 | 470 | if len(doc): |
467 | | doc = '""">>> set_random_seed(0L)\n\n' + '>>> change_warning_output(sys.stdout)\n\n' + doc[3:] |
| 471 | doc = doc_prefix + doc[3:-3] + doc_suffix |
468 | 472 | if random_order: |
469 | 473 | n_str = pad_zeros(new_index(n),10) |
470 | 474 | else: |
471 | 475 | n_str = str(n) |
472 | 476 | s += "def %s_%s():"%(name,n_str) |
473 | 477 | n += 1 |
474 | | s += "\tr"+ doc + "\n\n" |
| 478 | s += "\t"+ doc + "\n\n" |
475 | 479 | F = F[j+3:] |
476 | 480 | |
477 | 481 | if n == 0: |
… |
… |
|
615 | 619 | s += "For whitespace errors, see the file %s"%tmpname |
616 | 620 | return (s, cnt) |
617 | 621 | |
| 622 | |
618 | 623 | def test_file(file, library_code): |
619 | 624 | if os.path.exists(file): |
620 | 625 | name = os.path.basename(file) |
… |
… |
|
653 | 658 | out = ''; err = '' |
654 | 659 | if verbose or gdb or memcheck or massif or cachegrind: |
655 | 660 | import subprocess |
656 | | proc = subprocess.Popen(cmd,shell=True) |
| 661 | proc = subprocess.Popen(cmd, shell=True) |
657 | 662 | while time.time()-tm <= TIMEOUT and proc.poll() == None: |
658 | 663 | time.sleep(0.1) |
659 | 664 | if time.time()-tm >=TIMEOUT: |
… |
… |
|
663 | 668 | else: |
664 | 669 | outf = tempfile.NamedTemporaryFile() |
665 | 670 | import subprocess |
666 | | proc = subprocess.Popen(cmd,shell=True, stdout=outf.file.fileno(), stderr = outf.file.fileno()) |
| 671 | proc = subprocess.Popen(cmd, shell=True, \ |
| 672 | stdout=outf.file.fileno(), stderr = outf.file.fileno()) |
667 | 673 | while time.time()-tm <= TIMEOUT and proc.poll() == None: |
668 | 674 | time.sleep(0.1) |
669 | 675 | if time.time()-tm >=TIMEOUT: |
… |
… |
|
675 | 681 | except KeyboardInterrupt: |
676 | 682 | print "KeyboardInterrupt -- interrupted after %.1f seconds!" % (time.time()-tm) |
677 | 683 | sys.exit(2) |
678 | | if not verbose and 'raise KeyboardInterrupt' in err: |
| 684 | if 'raise KeyboardInterrupt' in err: |
679 | 685 | print "*"*80 + "Control-C pressed -- interrupting doctests." + "*"*80 |
680 | 686 | sys.exit(2) |
681 | 687 | |
… |
… |
|
699 | 705 | s = "*"*70 + "\n" + "Error: TAB character found.\n" + s |
700 | 706 | if e == 255: |
701 | 707 | # The doctesting code raised an exception |
702 | | if not verbose: |
703 | | print "Exception raised by doctesting framework. Use -verbose for details." |
| 708 | print "Exception raised by doctesting framework. Use -verbose for details." |
704 | 709 | sys.exit(8) |
705 | 710 | |
706 | 711 | if numfail == 0 and e > 0: |
… |
… |
|
710 | 715 | print s |
711 | 716 | sys.exit(128) |
712 | 717 | elif e < 0: |
713 | | if not verbose: |
714 | | print "The doctested process was killed by signal %s" % (-e) |
| 718 | print "The doctested process was killed by signal %s" % (-e) |
715 | 719 | sys.exit(4) |
716 | 720 | else: |
717 | 721 | delete_tmpfiles() |