From 5749c2c50fcbd3a0eb81ec0eac04c576fe405c69 Mon Sep 17 00:00:00 2001 From: Bruce Adams Date: Tue, 24 Sep 2013 21:58:27 -0400 Subject: [PATCH] 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. --- 01-monolith/tf-01.py | 2 ++ 02-code-golf/tf-02.py | 2 ++ 03-cookbook/tf-03.py | 2 ++ 04-candy-factory/tf-04.py | 2 ++ 04-candy-factory/tf-04.sh | 0 05-kick-your-teammate-forward/tf-05.py | 2 ++ 06-the-one/tf-06.py | 2 ++ 07-things/tf-07.py | 2 ++ 08-letterbox/tf-08.py | 2 ++ 09-kinds-of-things/tf-09.py | 2 ++ 10-hollywood/tf-10.py | 2 ++ 11-bulletin-board/tf-11.py | 2 ++ 12-inverse-multiplexer/tf-12.py | 2 ++ 13-double-inverse-multiplexer/tf-13.py | 2 ++ 14-tabular/tf-14.py | 2 ++ 15-restful/tf-15.py | 2 ++ 16-asides/tf-16.py | 2 ++ test/test.sh | 25 ++++++++++++++----------- 18 files changed, 46 insertions(+), 11 deletions(-) mode change 100644 => 100755 01-monolith/tf-01.py mode change 100644 => 100755 02-code-golf/tf-02.py mode change 100644 => 100755 03-cookbook/tf-03.py mode change 100644 => 100755 04-candy-factory/tf-04.py mode change 100644 => 100755 04-candy-factory/tf-04.sh mode change 100644 => 100755 05-kick-your-teammate-forward/tf-05.py mode change 100644 => 100755 06-the-one/tf-06.py mode change 100644 => 100755 07-things/tf-07.py mode change 100644 => 100755 08-letterbox/tf-08.py mode change 100644 => 100755 09-kinds-of-things/tf-09.py mode change 100644 => 100755 10-hollywood/tf-10.py mode change 100644 => 100755 11-bulletin-board/tf-11.py mode change 100644 => 100755 12-inverse-multiplexer/tf-12.py mode change 100644 => 100755 13-double-inverse-multiplexer/tf-13.py mode change 100644 => 100755 14-tabular/tf-14.py mode change 100644 => 100755 15-restful/tf-15.py mode change 100644 => 100755 16-asides/tf-16.py diff --git a/01-monolith/tf-01.py b/01-monolith/tf-01.py old mode 100644 new mode 100755 index 2ebf15b..3c74362 --- a/01-monolith/tf-01.py +++ b/01-monolith/tf-01.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import sys, string # the global list of [word, frequency] pairs word_freqs = [] diff --git a/02-code-golf/tf-02.py b/02-code-golf/tf-02.py old mode 100644 new mode 100755 index 2151d19..91eba36 --- a/02-code-golf/tf-02.py +++ b/02-code-golf/tf-02.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import re, string, sys stops = set(open("../stop_words.txt").read().split(",") + list(string.ascii_lowercase)) diff --git a/03-cookbook/tf-03.py b/03-cookbook/tf-03.py old mode 100644 new mode 100755 index fa17574..2551f31 --- a/03-cookbook/tf-03.py +++ b/03-cookbook/tf-03.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import sys, string # The shared mutable data diff --git a/04-candy-factory/tf-04.py b/04-candy-factory/tf-04.py old mode 100644 new mode 100755 index 8c0f7cb..77057b9 --- a/04-candy-factory/tf-04.py +++ b/04-candy-factory/tf-04.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import sys, re, operator, string # diff --git a/04-candy-factory/tf-04.sh b/04-candy-factory/tf-04.sh old mode 100644 new mode 100755 diff --git a/05-kick-your-teammate-forward/tf-05.py b/05-kick-your-teammate-forward/tf-05.py old mode 100644 new mode 100755 index 9996495..bd06173 --- a/05-kick-your-teammate-forward/tf-05.py +++ b/05-kick-your-teammate-forward/tf-05.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import sys, re, operator, string # diff --git a/06-the-one/tf-06.py b/06-the-one/tf-06.py old mode 100644 new mode 100755 index c114141..61c9903 --- a/06-the-one/tf-06.py +++ b/06-the-one/tf-06.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import sys, re, operator, string # diff --git a/07-things/tf-07.py b/07-things/tf-07.py old mode 100644 new mode 100755 index 989c079..9c71e3e --- a/07-things/tf-07.py +++ b/07-things/tf-07.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import sys, re, operator, string from abc import ABCMeta diff --git a/08-letterbox/tf-08.py b/08-letterbox/tf-08.py old mode 100644 new mode 100755 index d0a37aa..38906b2 --- a/08-letterbox/tf-08.py +++ b/08-letterbox/tf-08.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import sys, re, operator, string class DataStorageManager(): diff --git a/09-kinds-of-things/tf-09.py b/09-kinds-of-things/tf-09.py old mode 100644 new mode 100755 index 0302fd4..5ada00f --- a/09-kinds-of-things/tf-09.py +++ b/09-kinds-of-things/tf-09.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import abc, sys, re, operator, string # diff --git a/10-hollywood/tf-10.py b/10-hollywood/tf-10.py old mode 100644 new mode 100755 index 6f65f08..56bfefb --- a/10-hollywood/tf-10.py +++ b/10-hollywood/tf-10.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import sys, re, operator, string # diff --git a/11-bulletin-board/tf-11.py b/11-bulletin-board/tf-11.py old mode 100644 new mode 100755 index 71be4b8..f04338c --- a/11-bulletin-board/tf-11.py +++ b/11-bulletin-board/tf-11.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import sys, re, operator, string # diff --git a/12-inverse-multiplexer/tf-12.py b/12-inverse-multiplexer/tf-12.py old mode 100644 new mode 100755 index 2cb097a..211932f --- a/12-inverse-multiplexer/tf-12.py +++ b/12-inverse-multiplexer/tf-12.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import sys, re, operator, string # diff --git a/13-double-inverse-multiplexer/tf-13.py b/13-double-inverse-multiplexer/tf-13.py old mode 100644 new mode 100755 index 56fff56..039fe2e --- a/13-double-inverse-multiplexer/tf-13.py +++ b/13-double-inverse-multiplexer/tf-13.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import sys, re, operator, string # diff --git a/14-tabular/tf-14.py b/14-tabular/tf-14.py old mode 100644 new mode 100755 index 4633eac..26fb439 --- a/14-tabular/tf-14.py +++ b/14-tabular/tf-14.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import sys, re, string, sqlite3 # diff --git a/15-restful/tf-15.py b/15-restful/tf-15.py old mode 100644 new mode 100755 index 0adc9a4..19e9b49 --- a/15-restful/tf-15.py +++ b/15-restful/tf-15.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import re, string, sys with open("../stop_words.txt") as f: diff --git a/16-asides/tf-16.py b/16-asides/tf-16.py old mode 100644 new mode 100755 index a92fca9..c8cba69 --- a/16-asides/tf-16.py +++ b/16-asides/tf-16.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + import sys, re, operator, string, time # diff --git a/test/test.sh b/test/test.sh index 318b648..ff7d1c9 100755 --- a/test/test.sh +++ b/test/test.sh @@ -11,17 +11,20 @@ files=$(echo *.txt) for dir in ../[0-9][0-9]-* ; do cd $dir for file in $files ; do - exe=$(echo tf-[0-9][0-9].py) - msg testing $(basename $dir)/$exe with $file - python $exe ../$file | diff -b - $mydir/$file - result=$? - total=$((total+1)) - if [ $result -ne 0 ]; then - failures=$(($failures+1)) - msg FAILED! - else - msg passed. - fi + for exe in * ; do + if [ -x $exe ]; then + msg testing $(basename $dir)/$exe with $file + ./$exe ../$file | diff -b - $mydir/$file + result=$? + total=$((total+1)) + if [ $result -ne 0 ]; then + failures=$(($failures+1)) + msg FAILED! + else + msg passed. + fi + fi + done done cd $mydir done