Commit [efe1d1] default Maximize Restore History

merge with release_1 test changes

mtnyogi mtnyogi 2009-10-28

<< < 1 2 (Page 2 of 2)
added examples/testall.config
added examples/web_framework/testall.config
added experimental/__init__.py
added experimental/testall.config
added pyke/krb_compiler/testall.config
removed Test/CanNotProve/CanNotProve.tst2
removed doctest_file.py
removed examples/testexamples
removed pyke/testpyke
changed pyke/krb_compiler/krbparser_tables.py
changed pyke/krb_compiler/scanner.py
changed pyke/target_pkg.py
changed testall
copied Test/first/test.py -> MANIFEST.in
copied Test/testTest -> Test/CanNotProve/CanNotProve2.tst
copied doc/testdocs -> pyke/krb_compiler/generated_files.tst
examples/testall.config Diff Switch to side-by-side view
Loading...
examples/web_framework/testall.config Diff Switch to side-by-side view
Loading...
experimental/__init__.py Diff Switch to side-by-side view
Loading...
experimental/testall.config Diff Switch to side-by-side view
Loading...
pyke/krb_compiler/testall.config Diff Switch to side-by-side view
Loading...
doctest_file.py
File was removed.
examples/testexamples
File was removed.
pyke/testpyke
File was removed.
pyke/krb_compiler/krbparser_tables.py Diff Switch to side-by-side view
Loading...
pyke/krb_compiler/scanner.py Diff Switch to side-by-side view
Loading...
pyke/target_pkg.py Diff Switch to side-by-side view
Loading...
testall Diff Switch to side-by-side view
Loading...
Test/first/test.py to MANIFEST.in
--- a/Test/first/test.py
+++ b/MANIFEST.in
@@ -1,8 +1,12 @@
-# test.py
-
-from Test import pyketest
-
-Engine = knowledge_engine.engine('Test.first')
-
-class fc_tests(pyketest.fc_tests):
-    engine = Engine
+include *
+graft *
+exclude .hgtags .hgignore
+prune .hg
+#prune build
+prune dist
+prune Test/build
+prune Test/dist
+prune */compiled_krb
+prune */*/compiled_krb
+prune */*/*/compiled_krb
+global-exclude .pyhist *.pyc *.pyo .*.swp *.orig
Test/testTest to Test/CanNotProve/CanNotProve2.tst
--- a/Test/testTest
+++ b/Test/CanNotProve/CanNotProve2.tst
@@ -1,88 +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="python3.1 -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" True
-    then
-        echo "$f" >> $ERRORFILES
-        NUM_ERRORS=$(($NUM_ERRORS + 1))
-    fi
-done
+Add the egg to the python path:
 
-rm -rf build dist
+    >>> import glob
+    >>> sys.path.insert(0, glob.glob('Test/dist/CanNotProve*.egg')[0])
 
-if ! $PYTHON setup.py --quiet bdist
-then
-    echo "setup.py" >> $ERRORFILES
-    NUM_ERRORS=$(($NUM_ERRORS + 1))
-else
-    #echo doing rezip, cwd is $(pwd)
-    mkdir dist/unpack
-    cd dist/unpack
-    tar xzf ../C*
-    top=$(dirname $(pwd))
-    where=$(dirname $(find . -name CanNotProve))
-    (cd $where; zip -rq $top/foobar.egg *)
-    cd ../..
-    #echo done rezip, cwd is $(pwd)
+Now try the test!
 
-    cd ..
-    if ! PYTHONPATH=Test/dist/foobar.egg $PYTHON doctest_file.py \
-           Test/CanNotProve/CanNotProve.tst2
-    then
-        echo "CanNotProve/CanNotProve.tst2" >> $ERRORFILES
-        NUM_ERRORS=$(($NUM_ERRORS + 1))
-    else
-        rm -rf Test/build Test/dist
-    fi
-    cd Test
-fi
+    >>> from CanNotProve import test
+    >>> test.__loader__         # doctest: +ELLIPSIS
+    <zipimporter ...>
+    >>> test.Rule_package = 'CanNotProve'
+    >>> test.dotests()
 
-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
+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="python3.1 -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')
<< < 1 2 (Page 2 of 2)