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
|
|
|
|
2013-10-05 19:52:25 +02:00
|
|
|
if os.system('svn up') != 0:
|
|
|
|
print 'svn up failed'
|
|
|
|
return []
|
|
|
|
|
|
|
|
# log command and output
|
|
|
|
# $ svn log -l10 --incremental -q
|
|
|
|
# ------------------------------------------------------------------------
|
|
|
|
# r9073 | arvidn | 2013-10-04 21:49:00 -0700 (Fri, 04 Oct 2013)
|
|
|
|
# ------------------------------------------------------------------------
|
|
|
|
# r9072 | arvidn | 2013-10-04 21:18:24 -0700 (Fri, 04 Oct 2013)
|
|
|
|
# ------------------------------------------------------------------------
|
|
|
|
# r9068 | arvidn | 2013-10-04 08:51:32 -0700 (Fri, 04 Oct 2013)
|
|
|
|
# ------------------------------------------------------------------------
|
|
|
|
# r9067 | arvidn | 2013-10-04 08:45:47 -0700 (Fri, 04 Oct 2013)
|
|
|
|
# ------------------------------------------------------------------------
|
|
|
|
|
|
|
|
p = subprocess.Popen(['svn', 'log', '-l10', '--incremental', '-q'], stdout=subprocess.PIPE)
|
2013-06-16 22:37:54 +02:00
|
|
|
|
|
|
|
revision = -1
|
|
|
|
|
|
|
|
output = ''
|
2013-10-05 19:52:25 +02:00
|
|
|
ret = []
|
2013-06-16 22:37:54 +02:00
|
|
|
for l in p.stdout:
|
2013-10-05 19:52:25 +02:00
|
|
|
if not l.startswith('r'): continue
|
|
|
|
rev = int(l.split(' ')[0][1:])
|
|
|
|
if rev == last_rev: break
|
|
|
|
ret.append(rev)
|
2013-06-16 22:37:54 +02:00
|
|
|
|
2013-10-05 19:52:25 +02:00
|
|
|
print 'svn up: ',
|
|
|
|
for r in ret: print '%d ' % r,
|
|
|
|
print ''
|
|
|
|
return ret
|
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-10-06 18:57:04 +02:00
|
|
|
print 'restoring last state from "%s"' % rev_file
|
|
|
|
|
|
|
|
try:
|
|
|
|
last_rev = int(open(rev_file, 'r').read())
|
|
|
|
except:
|
2013-06-17 07:50:53 +02:00
|
|
|
last_rev = run_tests.svn_info()[0] - 1
|
2013-10-06 18:57:04 +02:00
|
|
|
open(rev_file, 'w+').write('%d' % last_rev)
|
2013-06-17 04:53:52 +02:00
|
|
|
|
2013-10-05 19:52:25 +02:00
|
|
|
revs = []
|
|
|
|
|
2013-06-16 22:37:54 +02:00
|
|
|
while True:
|
2013-10-05 19:52:25 +02:00
|
|
|
new_revs = svn_fetch(last_rev)
|
2013-06-16 22:37:54 +02:00
|
|
|
|
2013-10-05 19:52:25 +02:00
|
|
|
if len(new_revs) > 0:
|
|
|
|
revs = new_revs + revs
|
2013-06-17 04:53:52 +02:00
|
|
|
|
2013-10-05 19:52:25 +02:00
|
|
|
# in skip mode, only ever run the latest version
|
|
|
|
if skip and len(revs): revs = revs[:1]
|
|
|
|
|
|
|
|
if revs == []:
|
|
|
|
time.sleep(300)
|
|
|
|
continue
|
|
|
|
|
|
|
|
print 'revs: ',
|
|
|
|
for r in revs: print '%d ' % r,
|
|
|
|
print ''
|
|
|
|
|
|
|
|
r = revs[0]
|
|
|
|
print '\n\nREVISION %d ===\n' % r
|
|
|
|
svn_up(r)
|
2013-06-16 22:37:54 +02:00
|
|
|
|
2014-03-30 22:13:42 +02:00
|
|
|
try:
|
|
|
|
run_tests.main(sys.argv[1:])
|
|
|
|
last_rev = r;
|
2013-10-05 19:52:25 +02:00
|
|
|
|
2014-03-30 22:13:42 +02:00
|
|
|
# pop the revision we just completed
|
|
|
|
revs = revs[1:]
|
2013-10-06 11:03:16 +02:00
|
|
|
|
2014-03-30 22:13:42 +02:00
|
|
|
open(rev_file, 'w+').write('%d' % last_rev)
|
|
|
|
except Exception, e:
|
|
|
|
print e
|
2013-06-16 22:37:54 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
loop()
|