Commit [87e5be] default Maximize Restore History

Dropped all of the sub-testX scripts.

The doctest-tools testall script will work from the root source directory now
for both Python 2.5 and 2.6. But it doesn't delete all of the compiled_krb
files first.

So we're not quite done upgrading the testing yet! But there are a lot of
changes to this point, and I wanted to checkpoint everything...

mtnyogi mtnyogi 2009-10-25

added examples/web_framework/testall.exclude
added experimental/testall.exclude
added experimental/__init__.py
added pyke/krb_compiler/testall.exclude
removed Test/CanNotProve/CanNotProve.tst2
removed Test/first/test.py
removed examples/testexamples
removed pyke/testpyke
changed Test/CanNotProve/CanNotProve.tst
changed doc/source/bin/gather_links.py
changed doc/source/bin/get_links.py
changed doc/source/knowledge_bases/special.txt
changed examples/web_framework/profile_server.py
changed examples/web_framework/web_framework.tst
changed examples/web_framework/test.py
changed examples/sqlgen/test.py
changed experimental/metaclass.py
changed pyke/krb_compiler/scanner.py
changed pyke/krb_compiler/kfbparser.py
changed pyke/krb_compiler/krbparser.py
changed pyke/contexts.py
copied Test/testTest -> Test/CanNotProve/CanNotProve2.tst
copied doc/testdocs -> pyke/krb_compiler/generated_files.tst
examples/web_framework/testall.exclude Diff Switch to side-by-side view
Loading...
experimental/testall.exclude Diff Switch to side-by-side view
Loading...
experimental/__init__.py Diff Switch to side-by-side view
Loading...
pyke/krb_compiler/testall.exclude Diff Switch to side-by-side view
Loading...
Test/first/test.py
File was removed.
examples/testexamples
File was removed.
pyke/testpyke
File was removed.
Test/CanNotProve/CanNotProve.tst Diff Switch to side-by-side view
Loading...
doc/source/bin/gather_links.py Diff Switch to side-by-side view
Loading...
doc/source/bin/get_links.py Diff Switch to side-by-side view
Loading...
doc/source/knowledge_bases/special.txt Diff Switch to side-by-side view
Loading...
examples/web_framework/profile_server.py Diff Switch to side-by-side view
Loading...
examples/web_framework/web_framework.tst Diff Switch to side-by-side view
Loading...
examples/web_framework/test.py Diff Switch to side-by-side view
Loading...
examples/sqlgen/test.py Diff Switch to side-by-side view
Loading...
experimental/metaclass.py Diff Switch to side-by-side view
Loading...
pyke/krb_compiler/scanner.py Diff Switch to side-by-side view
Loading...
pyke/krb_compiler/kfbparser.py Diff Switch to side-by-side view
Loading...
pyke/krb_compiler/krbparser.py Diff Switch to side-by-side view
Loading...
pyke/contexts.py Diff Switch to side-by-side view
Loading...
Test/testTest to Test/CanNotProve/CanNotProve2.tst
--- a/Test/testTest
+++ b/Test/CanNotProve/CanNotProve2.tst
@@ -1,76 +1,45 @@
-#!/bin/bash
+# CanNotProve1.tst
 
-# testTest [-p python_command] [ errorfiles_file ]
-#
-# no arguments.
-#
-# run in Test directory to test all .tst files.
-# 
-# exit status > 0 if errors found.
+We're going to create a zipped egg file with a compiled CanNotProve example in
+it and see if pyke can load its compiled files from the zip file.
 
-ERRORFILES="/tmp/testTest.$$"
 
-PYTHON="python2.5 -Wd"
+First, create the egg (in Test/dist) using Test/setup.py:
 
-# Go to Test directory:
-cd `dirname "$0"`
+    >>> import os
+    >>> os.chdir('..')  # up to Test directory
 
-# Add parent directory to PYTHONPATH:
-parent_dir=$(dirname $(pwd))
-if [ "$PYTHONPATH" ]
-then
-    export PYTHONPATH="$parent_dir:$PYTHONPATH"
-else
-    export PYTHONPATH="$parent_dir"
-fi
+    >>> import sys
+    >>> sys.argv = ['Test/setup.py', '--quiet', 'bdist_egg']
+    >>> from Test import setup  # This runs setup.py
 
-if [ $# -ge 2 -a "x$1" = x-p ]
-then
-    PYTHON="$2"
-    shift 2
-fi
+Now, move up another level (so that 'CanNotProve' is not a subdirectory)
 
-> $ERRORFILES
-NUM_ERRORS=0
+    >>> os.chdir('..')  # up to root source directory
 
-for f in `find . -name '*.tst' -print`
-do
-    #echo Testing "$f"
-    if ! $PYTHON ../doctest_file.py "$f"
-    then
-        echo "$f" >> $ERRORFILES
-        NUM_ERRORS=$(($NUM_ERRORS + 1))
-    fi
-done
+Add the egg to the python path:
 
-if ! $PYTHON setup.py --quiet bdist_egg
-then
-    echo "setup.py" >> $ERRORFILES
-    NUM_ERRORS=$(($NUM_ERRORS + 1))
-else
-    cd ..
-    if ! PYTHONPATH=`echo Test/dist/CanNotProve*.egg` $PYTHON doctest_file.py \
-           Test/CanNotProve/CanNotProve.tst2
-    then
-        echo "CanNotProve/CanNotProve.tst2" >> $ERRORFILES
-        NUM_ERRORS=$(($NUM_ERRORS + 1))
-    else
-        rm -rf Test/CanNotProve.egg-info Test/build Test/dist
-    fi
-    cd Test
-fi
+    >>> import glob
+    >>> sys.path.insert(0, glob.glob('Test/dist/CanNotProve*.egg')[0])
 
-if [ $NUM_ERRORS -eq 0 ]
-then
-    echo "No Errors!"
-    rm -f $ERRORFILES
-else
-    echo "********** ERRORS ************* $NUM_ERRORS files had errors:"
-    cat $ERRORFILES
-    if [ $# -gt 0 ]
-    then
-        sed 's,^\./,Test/,' $ERRORFILES >> "$1"
-    fi
-    rm -f $ERRORFILES
-    exit $NUM_ERRORS
-fi
+Now try the test!
+
+    >>> from CanNotProve import test
+    >>> test.__loader__         # doctest: +ELLIPSIS
+    <zipimporter ...>
+    >>> test.Rule_package = 'CanNotProve'
+    >>> test.dotests()
+
+And finally, delete the files created by Test/setup.py
+
+    >>> def rm_r(dir):
+    ...     for root, dirs, files in os.walk(dir, topdown=False):
+    ...        for name in files:
+    ...            os.remove(os.path.join(root, name))
+    ...        for name in dirs:
+    ...            os.rmdir(os.path.join(root, name))
+    ...     os.rmdir(dir)
+    >>> rm_r('Test/build')
+    >>> rm_r('Test/dist')
+    >>> rm_r('Test/CanNotProve.egg-info')
+
doc/testdocs to pyke/krb_compiler/generated_files.tst
--- a/doc/testdocs
+++ b/pyke/krb_compiler/generated_files.tst
@@ -1,63 +1,30 @@
-#!/bin/bash
+This tests to make sure that all of the files generated by PLY are up to date.
 
-# testdocs [-p python_command] [ errorfiles_file ]
-#
-# no arguments.
-#
-# run in doc directory to test all .txt files.
-# 
-# exit status > 0 if errors found.
+    >>> import os.path
+    >>> def check(src, dest):
+    ...     assert os.path.getmtime(src) <= os.path.getmtime(dest), \
+    ...            dest + " out of date"
+    >>> check('scanner.py', 'scanner_tables.py')
+    >>> check('scanner.py', 'krbparser_tables.py')
+    >>> check('krbparser.py', 'krbparser_tables.py')
+    >>> check('scanner.py', 'kfbparser_tables.py')
+    >>> check('kfbparser.py', 'kfbparser_tables.py')
 
-ERRORFILES="/tmp/testdocs.$$"
-export PYTHONPATH="examples:$PYTHONPATH"
+Check that compiler_bc.py is up to date:
 
-PYTHON="python2.5 -Wd"
+    >>> if not os.path.isdir('compiled_krb'): os.mkdir('compiled_krb')
 
-# Go to doc directory:
-cd `dirname "$0"`
+    >>> from pyke import krb_compiler
+    >>> krb_compiler.compile_krb('compiler', 'compiled_krb', 'compiled_krb',
+    ...                          'compiler.krb')
+    ['compiler_bc.py']
 
-# Add parent directory to PYTHONPATH:
-parent_dir=$(dirname $(pwd))
-if [ "$PYTHONPATH" ]
-then
-    export PYTHONPATH="$parent_dir:$PYTHONPATH"
-else
-    export PYTHONPATH="$parent_dir"
-fi
-
-if [ $# -ge 2 -a "x$1" = x-p ]
-then
-    PYTHON="$2"
-    shift 2
-fi
-
-# Generate __init__.pyc so source/knowledge_bases/special.txt doesn't fail...
-$PYTHON -c 'import __init__'
-
-> $ERRORFILES
-NUM_ERRORS=0
-
-for f in `find source -name '*.txt'`
-do
-    #echo Testing "$f"
-    if ! $PYTHON ../doctest_file.py "$f"
-    then
-        echo "$f" >> $ERRORFILES
-        NUM_ERRORS=$(($NUM_ERRORS + 1))
-    fi
-done
-
-if [ $NUM_ERRORS -eq 0 ]
-then
-    echo "No Errors!"
-    rm -f $ERRORFILES
-else
-    echo "********** ERRORS ************* $NUM_ERRORS files had errors:"
-    cat $ERRORFILES
-    if [ $# -gt 0 ]
-    then
-        sed 's,^,doc/,' $ERRORFILES >> "$1"
-    fi
-    rm -f $ERRORFILES
-    exit $NUM_ERRORS
-fi
+    >>> from __future__ import with_statement
+    >>> import re
+    >>> del_krb_filename = re.compile(r"^Krb_filename = .*")
+    >>> with open('compiler_bc.py') as f:
+    ...     f1_text = del_krb_filename.sub('', f.read(), 1)
+    >>> with open('compiled_krb/compiler_bc.py') as f:
+    ...     f2_text = del_krb_filename.sub('', f.read(), 1)
+    >>> assert f1_text == f2_text, "krb_compiler/compiler.krb not compiled"
+    >>> if f1_text == f2_text: os.remove('compiled_krb/compiler_bc.py')