Index: src/tests/.expect/vector_test.txt
===================================================================
--- src/tests/.expect/vector_test.txt	(revision 245510f0a88c71b3f32e00d3269aee2caf927998)
+++ src/tests/.expect/vector_test.txt	(revision 3c1d702d920469dcdb821b08109a3587620e518f)
@@ -1,2 +1,5 @@
-make: *** No rule to make target `vector_int.c', needed by `vector_int.o'.  Stop.
-/bin/sh: ./vector_test: Is a directory
+enter N elements and C-d on a separate line:
+Array elements:
+1 2 3 4 5
+Array elements reversed:
+5 4 3 2 1
Index: src/tests/test.py
===================================================================
--- src/tests/test.py	(revision 245510f0a88c71b3f32e00d3269aee2caf927998)
+++ src/tests/test.py	(revision 3c1d702d920469dcdb821b08109a3587620e518f)
@@ -32,22 +32,28 @@
 #               running test functions
 ################################################################################
-def run_test_instance(test, dry_run):
-	sh("rm -f .out/%s.log" % test, dry_run)
+def run_test_instance(test, generate, dry_run):
+
+	out_file = (".out/%s.log" % test) if not generate else (".expect/%s.txt" % test)
+
+	sh("rm -f %s" % out_file, dry_run)
 	sh("rm -f %s > /dev/null 2>&1" % test, dry_run)
 
 	# build, skipping to next test on error
-	sh("make -j 1 %s >> .out/%s.log 2>&1" % (test, test), dry_run)
+	make_ret = sh("make -j 1 %s > %s 2>&1" % (test, out_file), dry_run)
 
-	# fetch optional input
-	stdinput = "< .in/%s.txt" % test if isfile(".in/%s.txt" % test) else ""
+	if make_ret == 0 :
+		# fetch optional input
+		stdinput = "< .in/%s.txt" % test if isfile(".in/%s.txt" % test) else ""
 
-	# run test
-	sh("./%s %s >> .out/%s.log 2>&1" % (test, stdinput, test), dry_run)
+		# run test
+		sh("./%s %s > %s 2>&1" % (test, stdinput, out_file), dry_run)
 
-	# touch expected files so empty output are supported by default
-	sh("touch .expect/%s.txt" % test, dry_run)
+	retcode = 0
+	if not generate :
+		# touch expected files so empty output are supported by default
+		sh("touch .expect/%s.txt" % test, dry_run)
 
-	# diff the output of the files
-	retcode = sh("diff .expect/%s.txt .out/%s.log" % (test, test), dry_run)
+		# diff the output of the files
+		retcode = sh("diff .expect/%s.txt .out/%s.log" % (test, test), dry_run)
 
 	# clean the executable
@@ -56,51 +62,29 @@
 	return retcode
 
-def run_tests(tests, dry_run) :
+def run_tests(tests, generate, dry_run) :
 	sh('make clean > /dev/null 2>&1', dry_run)
+	sh('mkdir -p .out .expect', dry_run)
+
+	if generate :
+		print( "Regenerate tests for: ", end="" )
+		print( ", ".join( tests ) )
 
 	failed = False;
 	for t in tests:
-		print("%10s  " % t, end="")
+		if not generate :
+			print("%20s  " % t, end="")
 		sys.stdout.flush()
-		test_failed = run_test_instance(t, dry_run)
+		test_failed = run_test_instance(t, generate, dry_run)
 		failed = test_failed or failed
-		print("FAILED" if test_failed else "PASSED")
+
+		if not generate :
+			print("FAILED" if test_failed else "PASSED")
 
 	sh('make clean > /dev/null 2>&1', dry_run)
 
+	if generate :
+		print( "Done" )
+
 	return 0 if failed else 1
-
-################################################################################
-#               generate expectation functions
-################################################################################
-def generate_test_expect(test):
-	sh("rm -f .out/%s.log" % test, False)
-	sh("rm -f %s > /dev/null 2>&1" % test, False)
-
-	# build, skipping to next test on error
-	sh("make -j 8 %s > .expect/%s.txt 2>&1" % (test, test), False)
-
-	# fetch optional input
-	stdinput = "< .in/%s.txt" % test if isfile(".in/%s.txt" % test) else ""
-
-	# run test
-	sh("./%s %s >> .expect/%s.txt 2>&1" % (test, stdinput, test), False)
-
-	# clean the executable
-	sh("rm -f %s > /dev/null 2>&1" % test, False)
-
-def generate_expect(tests) :
-	sh('make clean > /dev/null 2>&1', False)
-
-	print( "Regenerate tests for" )
-
-	print( ", ".join( tests ) )
-
-	for t in tests:
-		generate_test_expect( t )
-
-	print( "Done" )
-
-	sh('make clean > /dev/null 2>&1', False)
 
 ################################################################################
@@ -115,26 +99,10 @@
 options = parser.parse_args()
 
-tests = listTests()
+if len(options.tests) > 0 and options.all :
+	print('ERROR: must have option \'--all\' or non-empty test list', file=sys.stderr)
+	parser.print_help()
+	sys.exit(1)
 
-if options.all :
-	if len(options.tests) > 0 :
-		print('ERROR: cannot specify tests with \'--all\' option', file=sys.stderr)
-		sys.exit(1)
+tests = listTests() if options.all else options.tests
 
-	if options.generate_expected :
-		generate_expect( tests )
-	else :
-		sys.exit( run_tests(tests, options.dry_run) )
-
-else :
-	if len(options.tests) == 0 :
-		print('ERROR: must have option \'--all\' or non-empty test list', file=sys.stderr)
-		parser.print_help()
-		sys.exit(1)
-
-	if options.generate_expected :
-		generate_expect( options.tests )
-	else :
-		sys.exit( run_tests(options.tests, options.dry_run) )
-
-sys.exit(0)
+sys.exit( run_tests(tests, options.generate_expected, options.dry_run) )
