Enhance testing: run all executables

Add a #! line at the beginning of each of the existing Python programs
and change these files to be executable. This sets the stage for having
the test script blindly run anything that is executable, adding support
for testing many programming languages.
This commit is contained in:
Bruce Adams
2013-09-24 21:58:27 -04:00
parent 4bae21ffbf
commit 5749c2c50f
18 changed files with 46 additions and 11 deletions

2
01-monolith/tf-01.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import sys, string import sys, string
# the global list of [word, frequency] pairs # the global list of [word, frequency] pairs
word_freqs = [] word_freqs = []

2
02-code-golf/tf-02.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import re, string, sys import re, string, sys
stops = set(open("../stop_words.txt").read().split(",") + list(string.ascii_lowercase)) stops = set(open("../stop_words.txt").read().split(",") + list(string.ascii_lowercase))

2
03-cookbook/tf-03.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import sys, string import sys, string
# The shared mutable data # The shared mutable data

2
04-candy-factory/tf-04.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import sys, re, operator, string import sys, re, operator, string
# #

0
04-candy-factory/tf-04.sh Normal file → Executable file
View File

2
05-kick-your-teammate-forward/tf-05.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import sys, re, operator, string import sys, re, operator, string
# #

2
06-the-one/tf-06.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import sys, re, operator, string import sys, re, operator, string
# #

2
07-things/tf-07.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import sys, re, operator, string import sys, re, operator, string
from abc import ABCMeta from abc import ABCMeta

2
08-letterbox/tf-08.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import sys, re, operator, string import sys, re, operator, string
class DataStorageManager(): class DataStorageManager():

2
09-kinds-of-things/tf-09.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import abc, sys, re, operator, string import abc, sys, re, operator, string
# #

2
10-hollywood/tf-10.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import sys, re, operator, string import sys, re, operator, string
# #

2
11-bulletin-board/tf-11.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import sys, re, operator, string import sys, re, operator, string
# #

2
12-inverse-multiplexer/tf-12.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import sys, re, operator, string import sys, re, operator, string
# #

2
13-double-inverse-multiplexer/tf-13.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import sys, re, operator, string import sys, re, operator, string
# #

2
14-tabular/tf-14.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import sys, re, string, sqlite3 import sys, re, string, sqlite3
# #

2
15-restful/tf-15.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import re, string, sys import re, string, sys
with open("../stop_words.txt") as f: with open("../stop_words.txt") as f:

2
16-asides/tf-16.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/env python
import sys, re, operator, string, time import sys, re, operator, string, time
# #

View File

@@ -11,17 +11,20 @@ files=$(echo *.txt)
for dir in ../[0-9][0-9]-* ; do for dir in ../[0-9][0-9]-* ; do
cd $dir cd $dir
for file in $files ; do for file in $files ; do
exe=$(echo tf-[0-9][0-9].py) for exe in * ; do
msg testing $(basename $dir)/$exe with $file if [ -x $exe ]; then
python $exe ../$file | diff -b - $mydir/$file msg testing $(basename $dir)/$exe with $file
result=$? ./$exe ../$file | diff -b - $mydir/$file
total=$((total+1)) result=$?
if [ $result -ne 0 ]; then total=$((total+1))
failures=$(($failures+1)) if [ $result -ne 0 ]; then
msg FAILED! failures=$(($failures+1))
else msg FAILED!
msg passed. else
fi msg passed.
fi
fi
done
done done
cd $mydir cd $mydir
done done