xref: /aosp_15_r20/external/deqp/scripts/list_test_changes.py (revision 35238bce31c2a825756842865a792f8cf7f89930)
1#!/usr/bin/env python3
2
3# VK-GL-CTS log scrubber
4# ----------------------
5#
6# Copyright (c) 2019 The Khronos Group Inc.
7# Copyright (c) 2019 Google LLC
8#
9# Licensed under the Apache License, Version 2.0 (the "License");
10# you may not use this file except in compliance with the License.
11# You may obtain a copy of the License at
12#
13#      http://www.apache.org/licenses/LICENSE-2.0
14#
15# Unless required by applicable law or agreed to in writing, software
16# distributed under the License is distributed on an "AS IS" BASIS,
17# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18# See the License for the specific language governing permissions and
19# limitations under the License.
20
21# This script attempts to find out which tests have changed since a
22# certain time, release or changelist. The commit messages are scrubbed
23# for dEQP test names, and these are merged to find a suitable set.
24#
25# The changelists that claim to change all tests are ignored.
26
27import subprocess
28import sys
29import fnmatch
30import re
31
32assert sys.version_info >= (3, 0)
33
34if len(sys.argv) == 1:
35    print("""
36VK-GL-CTS log scrubber
37----------------------
38This script attempts to list changed tests since certain time or
39git revision. It does this by looking at git log.
40
41Caveat: git log messages are written by humans, so there may be
42errors. Overly broad changes are ignored (e.g, dEQP-VK.*).
43
44Usage: Give the git log parameters
45
46Examples:""")
47    print(sys.argv[0], '--since="two months ago"')
48    print(sys.argv[0], '--since="7.7.2019"')
49    print(sys.argv[0], 'vulkan-cts-1.1.3.1..HEAD')
50    quit()
51
52params = ""
53first = True
54for x in sys.argv[1:]:
55    if not first:
56        params = params + " "
57    params = params + x
58    first = False
59
60res = []
61
62rawlogoutput = subprocess.check_output(['git', 'log', params, '--pretty=format:"%B"'])
63logoutput = rawlogoutput.decode().split()
64for x in logoutput:
65    xs = x.strip()
66    # regexp matches various over-large test masks like "dEQP-*", "dEQP-VK*", "dEQP-VK.*",
67    # but not "dEQP-VK.a" or "dEQP-VK.*a"
68    if xs.startswith('dEQP-') and not re.search('dEQP-\w*\**\.*\**$',xs):
69        found = False
70        killlist = []
71        for y in res:
72            if fnmatch.fnmatch(xs, y):
73                found = True
74            if fnmatch.fnmatch(y, xs):
75                killlist.append(y)
76        for y in killlist:
77            res.remove(y)
78        if not found:
79            res.append(xs)
80for x in sorted(res):
81    print(x)
82print(len(res), 'total')
83