Boost logo

Boost-Build :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-01-14 02:19:52


Hi Andre,

> it sometimes annoys me that I can't get a list of failing tests from
> test_all.py. I suggest that all tests should be run and their results
> reported, instead of stopping after the first failure. Here's a simple fix:
>
> Index: test_all.py
> ===================================================================
> RCS file: /cvsroot/boost/boost/tools/build/v2/test/test_all.py,v
> retrieving revision 1.74
> diff -r1.74 test_all.py
> 38c38
> < raise
> ---
>
> > continue
>
> Does that seem good enough or do we need a command line switch for that?

I don't think command like switch is needed. It's easy to terminate the tests
once you see 'fail'.

However, a bit more complex logic is required. First, we need to restore
current directory on failure, since failed test might have not done it.
Second, we need to make sure that 'test_result.txt' will contain the name of
the first failed test, so that that test will be executed first on the second
run.

I've comitted the following revised patch.

Thanks,
Volodya

 --Boundary-00=_Y2OBA1Sr9QLhJO0 Content-Type: text/x-diff;
charset="iso-8859-1";
name="test_all.py.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="test_all.py.diff"

Index: test_all.py
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/v2/test/test_all.py,v
retrieving revision 1.74
diff -u -r1.74 test_all.py
--- test_all.py 11 Dec 2003 14:12:02 -0000 1.74
+++ test_all.py 14 Jan 2004 07:19:08 -0000
@@ -26,21 +26,28 @@

invocation_dir = os.getcwd()

+ failures_count = 0
for i in all_tests:
print ("%-25s : " %(i)),
try:
__import__(i)
except:
print "FAILED"
- f = open(os.path.join(invocation_dir, 'test_results.txt'), 'w')
- f.write(i)
- f.close()
- raise
+ if failures_count == 0:
+ f = open(os.path.join(invocation_dir, 'test_results.txt'), 'w')
+ f.write(i)
+ f.close()
+ failures_count = failures_count + 1
+ # Restore the current directory, which might be changed by the
+ # test
+ os.chdir(invocation_dir)
+ continue
print "PASSED"
sys.stdout.flush() # makes testing under emacs more entertaining.

# Erase the file on success
- open('test_results.txt', 'w')
+ if failures_count == 0:
+ open('test_results.txt', 'w')

def last_failed_test():
 --Boundary-00=_Y2OBA1Sr9QLhJO0--


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk