summaryrefslogtreecommitdiff
path: root/scripts/list_test_changes.py
blob: f79336cb8683520bd33d65f6862ce06173cd7eca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python3

# VK-GL-CTS log scrubber
# ----------------------
#
# Copyright (c) 2019 The Khronos Group Inc.
# Copyright (c) 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This script attempts to find out which tests have changed since a
# certain time, release or changelist. The commit messages are scrubbed
# for dEQP test names, and these are merged to find a suitable set.
#
# The changelists that claim to change all tests are ignored.

import subprocess
import sys
import fnmatch
import re

assert sys.version_info >= (3, 0)

if len(sys.argv) == 1:
	print("""
VK-GL-CTS log scrubber
----------------------
This script attempts to list changed tests since certain time or
git revision. It does this by looking at git log.

Caveat: git log messages are written by humans, so there may be
errors. Overly broad changes are ignored (e.g, dEQP-VK.*).

Usage: Give the git log parameters

Examples:""")
	print(sys.argv[0], '--since="two months ago"')
	print(sys.argv[0], '--since="7.7.2019"')
	print(sys.argv[0], 'vulkan-cts-1.1.3.1..HEAD')
	quit()

params = ""
first = True
for x in sys.argv[1:]:
	if not first:
		params = params + " "
	params = params + x
	first = False

res = []

rawlogoutput = subprocess.check_output(['git', 'log', params, '--pretty=format:"%B"'])
logoutput = rawlogoutput.decode().split()
for x in logoutput:
	xs = x.strip()
	# regexp matches various over-large test masks like "dEQP-*", "dEQP-VK*", "dEQP-VK.*",
	# but not "dEQP-VK.a" or "dEQP-VK.*a"
	if xs.startswith('dEQP-') and not re.search('dEQP-\w*\**\.*\**$',xs):
		found = False
		killlist = []
		for y in res:
			if fnmatch.fnmatch(xs, y):
				found = True
			if fnmatch.fnmatch(y, xs):
				killlist.append(y)
		for y in killlist:
			res.remove(y)
		if not found:
			res.append(xs)
for x in sorted(res):
	print(x)
print(len(res), 'total')