root/mail-onna-stick/trunk/support/buildbot/buildslave/bot_scripts/run-fitnesse.py

Revision 304, 1.9 kB (checked in by t, 11 years ago)

fixed fitnesse tests, hopefully.

  • Property svn:executable set to *
Line 
1 #! /usr/bin/env python2.3
2 import os, time, sys, random, socket
3
4 ### make sure that PATH_TO_JAVA is set appropriately for each platform;
5 ### also make sure that PYTHONPATH includes the text fixtures.
6
7 FITNESSE_JAVA_DIR=os.path.realpath(sys.argv[1])
8 PATH_TO_JAVA=os.path.realpath(sys.argv[2])
9 PATH_TO_TESTS=os.path.realpath(sys.argv[3])
10 TESTNAME=sys.argv[4]
11
12 TMPDIR=os.path.realpath('var/FitNesse')
13 try:
14     os.mkdir(TMPDIR)
15 except OSError:
16     pass
17
18 cwd = os.getcwd()
19 os.chdir(FITNESSE_JAVA_DIR)
20
21 sys.stdout.write('/bin/ln -fs %s/tests/MOS_FIT/MosAcceptanceTests FitNesseRoot/\n' % (cwd,))
22 os.system('/bin/ln -fs %s/tests/MOS_FIT/MosAcceptanceTests FitNesseRoot/' % (cwd,))
23
24 PATH_TO_TESTS = os.path.realpath(PATH_TO_TESTS)
25 assert os.path.isdir(PATH_TO_TESTS)
26 sys.path.insert(0, PATH_TO_TESTS)
27
28 print 'sys.path IS', sys.path
29
30 N_RETRIES=5
31
32 from fitnesse.FitServerImplementation import TestRunner
33
34 ###
35
36 # randomly select a port; doesn't matter what, as long as it's above 1023.
37 PORT=14321 + random.randint(0, 999)
38 PORT="%s" % (PORT,)
39
40 ###
41
42 #
43 # first, start the FitNesse server.
44 #
45
46 pid = os.fork()
47 if pid == 0:
48     print 'RUNNING FitNesse on port', PORT
49     os.execl(PATH_TO_JAVA, 'java', '-cp', 'fitnesse.jar', 'fitnesse.FitNesse', '-p', PORT)
50     sys.exit(0)                         # technically unnecessary ;)
51
52 time.sleep(2)
53
54 ###
55
56 # by default, fail.
57 success = False
58
59 #
60 # create test runner & execute.
61 #
62 try:
63     print 'Executing the test runner:'
64     runner = TestRunner()
65    
66     for i in range(0, N_RETRIES):
67         try:
68             success = runner.run(('TestRunner', '+vhrx',
69                                   '+o', TMPDIR,
70                                   'localhost',
71                                   PORT,
72                                  TESTNAME,))
73         except socket.error:
74             print 'FAILED to connect; try %d' % (i,)
75             time.sleep(1)
76        
77 finally:
78     os.kill(pid, 9)
79
80 assert success
Note: See TracBrowser for help on using the browser.