2013-06-16 22:37:54 +02:00
|
|
|
#!/bin/python
|
|
|
|
|
2013-06-18 07:38:09 +02:00
|
|
|
# Copyright (c) 2013, Arvid Norberg
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions
|
|
|
|
# are met:
|
|
|
|
#
|
|
|
|
# * Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# * Redistributions in binary form must reproduce the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer in
|
|
|
|
# the documentation and/or other materials provided with the distribution.
|
|
|
|
# * Neither the name of the author nor the names of its
|
|
|
|
# contributors may be used to endorse or promote products derived
|
|
|
|
# from this software without specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2013-06-16 22:37:54 +02:00
|
|
|
import run_tests
|
|
|
|
import os
|
|
|
|
import time
|
2013-06-16 23:04:01 +02:00
|
|
|
import subprocess
|
|
|
|
import sys
|
2013-06-16 22:37:54 +02:00
|
|
|
|
2013-06-17 05:08:41 +02:00
|
|
|
def indent(s):
|
2013-06-18 17:45:50 +02:00
|
|
|
s = s.split('\n')
|
|
|
|
s = [(3 * ' ') + line.lstrip() for line in s]
|
|
|
|
s = '\n'.join(s)
|
2013-06-17 05:08:41 +02:00
|
|
|
return s
|
|
|
|
|
2013-06-16 22:37:54 +02:00
|
|
|
# returns a list of new revisions
|
2013-06-17 04:53:52 +02:00
|
|
|
def svn_fetch(last_rev):
|
2013-06-16 22:37:54 +02:00
|
|
|
|
|
|
|
p = subprocess.Popen(['svn', 'up'], stdout=subprocess.PIPE)
|
|
|
|
|
|
|
|
revision = -1
|
|
|
|
|
|
|
|
output = ''
|
|
|
|
for l in p.stdout:
|
|
|
|
if 'At revision ' in l:
|
2013-06-16 23:04:01 +02:00
|
|
|
revision = int(l.split('At revision')[1].strip()[0:-1])
|
2013-06-17 00:51:03 +02:00
|
|
|
if 'Updated to revision ' in l:
|
|
|
|
revision = int(l.split('Updated to revision')[1].strip()[0:-1])
|
2013-06-16 22:37:54 +02:00
|
|
|
output += l
|
|
|
|
|
|
|
|
if revision == -1:
|
2013-06-17 05:08:41 +02:00
|
|
|
print '\n\nsvn update failed\n\n%s' % indent(output)
|
|
|
|
return []
|
2013-06-16 22:37:54 +02:00
|
|
|
|
2013-06-17 04:53:52 +02:00
|
|
|
return range(last_rev + 1, revision + 1)
|
2013-06-16 22:37:54 +02:00
|
|
|
|
|
|
|
def svn_up(revision):
|
2013-06-18 07:38:09 +02:00
|
|
|
os.system('svn up -r %d' % revision)
|
2013-06-16 22:37:54 +02:00
|
|
|
|
|
|
|
def print_usage():
|
2013-06-17 03:30:45 +02:00
|
|
|
print '''usage: run_regression_tests.py [options] toolset [toolset...]
|
2013-06-16 22:37:54 +02:00
|
|
|
|
|
|
|
toolset are bjam toolsets. For instance clang, gcc, darwin, msvc etc.
|
2013-06-17 03:30:45 +02:00
|
|
|
The path "./regression_tests" is expected to be a shared folder
|
|
|
|
between all testsers.
|
2013-06-16 22:37:54 +02:00
|
|
|
|
|
|
|
options:
|
|
|
|
|
2013-09-03 03:57:43 +02:00
|
|
|
-j<n> use n parallel processes for running tests
|
|
|
|
-i build incrementally (i.e. don't clean between checkouts)
|
|
|
|
-valgrind run tests with valgrind (requires valgrind to be installed)
|
2013-09-22 15:47:33 +02:00
|
|
|
-s skip. always run tests on the latest version
|
2013-06-16 22:37:54 +02:00
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
def loop():
|
2013-06-16 23:04:01 +02:00
|
|
|
|
2013-06-17 08:54:00 +02:00
|
|
|
if len(sys.argv) < 2:
|
2013-06-16 23:04:01 +02:00
|
|
|
print_usage()
|
|
|
|
sys.exit(1)
|
|
|
|
|
2013-09-22 15:47:33 +02:00
|
|
|
skip = '-s' in sys.argv
|
2013-06-17 04:53:52 +02:00
|
|
|
|
2013-10-03 07:44:38 +02:00
|
|
|
rev_file = os.path.join(os.getcwd(), '.rev')
|
2013-09-22 15:47:33 +02:00
|
|
|
if skip:
|
|
|
|
sys.argv.remove('-s')
|
2013-06-17 07:50:53 +02:00
|
|
|
last_rev = run_tests.svn_info()[0] - 1
|
2013-09-22 15:47:33 +02:00
|
|
|
else:
|
|
|
|
print 'restoring last state from "%s"' % rev_file
|
|
|
|
|
|
|
|
try:
|
|
|
|
last_rev = int(open(rev_file, 'r').read())
|
|
|
|
except:
|
|
|
|
last_rev = run_tests.svn_info()[0] - 1
|
|
|
|
open(rev_file, 'w+').write('%d' % last_rev)
|
2013-06-17 04:53:52 +02:00
|
|
|
|
2013-06-16 22:37:54 +02:00
|
|
|
while True:
|
2013-06-17 04:53:52 +02:00
|
|
|
revs = svn_fetch(last_rev)
|
2013-09-22 15:47:33 +02:00
|
|
|
if skip and len(revs): revs = revs[-1:]
|
2013-06-16 22:37:54 +02:00
|
|
|
|
|
|
|
for r in revs:
|
|
|
|
print '\n\nREVISION %d ===\n' % r
|
|
|
|
svn_up(r)
|
|
|
|
|
2013-06-17 03:30:45 +02:00
|
|
|
run_tests.main(sys.argv[1:])
|
2013-06-17 04:53:52 +02:00
|
|
|
last_rev = r;
|
|
|
|
|
|
|
|
open(rev_file, 'w+').write('%d' % last_rev)
|
2013-06-16 22:37:54 +02:00
|
|
|
|
2013-06-23 03:34:19 +02:00
|
|
|
if revs == []: time.sleep(300)
|
2013-06-16 22:37:54 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
loop()
|