#!/usr/bin/env python3 ############################################################################# ## ## Copyright (C) 2015 The Qt Company Ltd. ## Contact: http://www.qt.io/licensing/ ## ## This file is part of the release tools of the Qt Toolkit. ## ## $QT_BEGIN_LICENSE:LGPL21$ ## Commercial License Usage ## Licensees holding valid commercial Qt licenses may use this file in ## accordance with the commercial license agreement provided with the ## Software or, alternatively, in accordance with the terms contained in ## a written agreement between you and The Qt Company. For licensing terms ## and conditions see http://www.qt.io/terms-conditions. For further ## information use the contact form at http://www.qt.io/contact-us. ## ## GNU Lesser General Public License Usage ## Alternatively, this file may be used under the terms of the GNU Lesser ## General Public License version 2.1 or version 3 as published by the Free ## Software Foundation and appearing in the file LICENSE.LGPLv21 and ## LICENSE.LGPLv3 included in the packaging of this file. Please review the ## following information to ensure the GNU Lesser General Public License ## requirements will be met: https://www.gnu.org/licenses/lgpl.html and ## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ## ## As a special exception, The Qt Company gives you certain additional ## rights. These rights are described in The Qt Company LGPL Exception ## version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ## ## $QT_END_LICENSE$ ## ############################################################################# # Regenerate all tests' output. # # Usage: cd to the build directory corresponding to this script's # location; invoke this script; optionally pass the names of sub-dirs # to limit which tests to regenerate expected_* files for. import os import subprocess class Fail (Exception): pass class Cleaner (object): """Tool to clean up test output to make diff-ing runs useful. We care about whether tests pass or fail - if that changes, something that matters has happened - and we care about some changes to what they say when they do fail; but we don't care exactly what line of what file the failing line of code now occupies, nor do we care how many milliseconds each test took to run; and changes to the Qt version number mean nothing to us. Create one singleton instance; it'll do mildly expensive things once and you can use its .clean() method to tidy up your test output.""" def __init__(self, here, command): """Set up the details we need for later cleaning. Takes two parameters: here is $PWD and command is how this script was invoked, from which we'll work out where it is; in a shadow build, the former is the build tree's location corresponding to this last. Checks $PWD does look as expected in a build tree - raising Fail() if not - then invokes qmake to discover Qt version (saved as .version for the benefit of clients) and prepares the sequence of (regex, replace) pairs that .clean() needs to do its job.""" self.version, self.__replace = self.__getPatterns(here, command) import re @staticmethod def __getPatterns(here, command, patterns = ( # Timings: (r'( *', r'\1"0"/>'), # xml, lightxml (r'(Totals:.*,) *[0-9.]+ms', r'\1 0ms'), # txt # Benchmarks: (r'[0-9,.]+( (?:CPU ticks|msecs) per iteration \(total:) [0-9,.]+ ', r'0\1 0, '), # txt (r'(,"(?:CPUTicks|WalltimeMilliseconds)"),\d+,\d+,', r'\1,0,0,'), # csv (r'([^<]+', r'\1/>'), # xml, lightxml (r'()', r'\1\2'), # xunitxml # Line numbers in source files: (r'(Loc: \[[^[\]()]+)\(\d+\)', r'\1(0)'), # txt # (r'(\[Loc: [^[\]()]+)\(\d+\)', r'\1(0)'), # teamcity (r'(