annotate tests/testlib/check-min-versions.py @ 6934:dd518437d4e0 stable

tests: introduce a compat-branches blacklist file The idea behind this file is to have an easy and obvious mechanism for skipping some tests on compatibility branches without modifying the test files themselves or touching .gitlab-ci.yml. Obviously, each compatibility branch can have different set of tests, and so the contents of this file can be different on different branches. This concept had actually existed in core for a long time, see tests/blacklists/ directory.
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 16 Nov 2024 17:59:53 +0400
parents 175bb63ba111
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5405
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
1 #!/usr/bin/env python
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
2 """
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
3 This script takes `minimumhgversion` and `testedwith` values from the first
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
4 file (e.g. hgext3rd/evolve/metadata.py) and mercurial package versions from the
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
5 second file (e.g. debian/control) and compares them using a set of rules to
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
6 find any issues.
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
7
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
8 Rules:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
9
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
10 - if `minimumhgversion` is a feature release, the first version from
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
11 `testedwith` should belong to that feature release
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
12
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
13 - if `minimumhgversion` is a bugfix release, the first version from
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
14 `testedwith` should be the same
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
15
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
16 - mercurial package versions (from both Depends and Build-Depends sections)
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
17 should match `minimumhgversion`
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
18
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
19 Usage: $0 MFILE CFILE where MFILE contains extension metadata and CFILE is a
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
20 debian/control file.
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
21 """
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
22
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
23 from __future__ import print_function
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
24
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
25 import argparse
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
26 import os
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
27 import re
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
28
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
29 def grepall(workdir, linere):
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
30 for root, dirs, files in os.walk(workdir):
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
31 for fname in files:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
32 if not fname.endswith('.py'):
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
33 continue
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
34 path = os.path.join(root, fname)
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
35 with open(path, 'r') as src:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
36 for line in src:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
37 for groups in linere.findall(line):
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
38 yield path, groups
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
39
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
40 def main():
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
41 ap = argparse.ArgumentParser()
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
42 ap.add_argument('mfile', help='.py file with `testedwith`')
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
43 ap.add_argument('cfile', help='debian/control file')
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
44
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
45 opts = ap.parse_args()
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
46
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
47 mre = re.compile(r"^minimumhgversion = b'([0-9.]+)'")
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
48 mtre = re.compile(r"^testedwith = b'([0-9.]+) ")
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
49 minversion = ''
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
50 mintestedversion = ''
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
51
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
52 with open(opts.mfile, 'r') as src:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
53 for line in src:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
54 if not minversion:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
55 groups = mre.findall(line)
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
56 if groups:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
57 minversion = groups[0]
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
58 if not mintestedversion:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
59 groups = mtre.findall(line)
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
60 if groups:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
61 mintestedversion = groups[0]
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
62
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
63 if not minversion:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
64 print('could not find `minimumhgversion` variable in %s' % opts.mfile)
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
65
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
66 if not mintestedversion:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
67 print('could not find `testedwith` variable in %s' % opts.mfile)
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
68
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
69 if minversion.count('.') > 1:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
70 # `minversion` is a bugfix release
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
71 if minversion != mintestedversion:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
72 print('`minimumhgversion` is a bugfix release, the first version '
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
73 'in `testedwith` should be the same: %s and %s'
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
74 % (minversion, mintestedversion))
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
75
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
76 else:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
77 # matching X.Y to determine the "feature release" version
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
78 frelre = re.compile(r"([0-9]+).([0-9]+)")
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
79
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
80 if frelre.findall(minversion) != frelre.findall(mintestedversion):
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
81 print('the first version in `testedwith` does not belong to the '
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
82 'same feature release as `minimumhgversion`: %s and %s'
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
83 % (mintestedversion, minversion))
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
84
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
85 cre = re.compile(r"^ mercurial \(>= ([0-9.]+)\)")
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
86 depversion = ''
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
87
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
88 with open(opts.cfile, 'r') as src:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
89 for line in src:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
90 groups = cre.findall(line)
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
91 if groups:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
92 depversion = groups[0]
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
93 if minversion != depversion:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
94 print('versions differ: %s from `minimumhgversion`, %s '
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
95 'from dependencies' % (minversion, depversion))
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
96
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
97 if not depversion:
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
98 print('could not find dependency on mercurial in %s' % opts.cfile)
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
99
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
100 if __name__ == '__main__':
175bb63ba111 tests: add a test that makes sure version metadata stays in sync
Anton Shestakov <av6@dwimlabs.net>
parents:
diff changeset
101 main()