Éric Araujo | a0e92a8 | 2011-07-26 18:01:08 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Brett Cannon | 70cb187 | 2017-06-24 16:51:23 -0700 | [diff] [blame] | 2 | """Check proposed changes for common issues.""" |
Georg Brandl | a9afb68 | 2010-10-21 12:49:28 +0000 | [diff] [blame] | 3 | import re |
| 4 | import sys |
| 5 | import shutil |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 6 | import os.path |
| 7 | import subprocess |
Éric Araujo | a3e072b | 2011-07-30 21:34:04 +0200 | [diff] [blame] | 8 | import sysconfig |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 9 | |
| 10 | import reindent |
Georg Brandl | a9afb68 | 2010-10-21 12:49:28 +0000 | [diff] [blame] | 11 | import untabify |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 12 | |
| 13 | |
Victor Stinner | 4a347ce | 2017-08-17 16:29:15 +0200 | [diff] [blame] | 14 | # Excluded directories which are copies of external libraries: |
| 15 | # don't check their coding style |
| 16 | EXCLUDE_DIRS = [os.path.join('Modules', '_ctypes', 'libffi_osx'), |
| 17 | os.path.join('Modules', '_ctypes', 'libffi_msvc'), |
| 18 | os.path.join('Modules', '_decimal', 'libmpdec'), |
| 19 | os.path.join('Modules', 'expat'), |
| 20 | os.path.join('Modules', 'zlib')] |
Éric Araujo | a3e072b | 2011-07-30 21:34:04 +0200 | [diff] [blame] | 21 | SRCDIR = sysconfig.get_config_var('srcdir') |
| 22 | |
Victor Stinner | 4a347ce | 2017-08-17 16:29:15 +0200 | [diff] [blame] | 23 | |
Brett Cannon | 058173e | 2010-07-04 22:05:34 +0000 | [diff] [blame] | 24 | def n_files_str(count): |
| 25 | """Return 'N file(s)' with the proper plurality on 'file'.""" |
| 26 | return "{} file{}".format(count, "s" if count != 1 else "") |
| 27 | |
Florent Xicluna | e4a3380 | 2010-08-09 12:24:20 +0000 | [diff] [blame] | 28 | |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 29 | def status(message, modal=False, info=None): |
| 30 | """Decorator to output status info to stdout.""" |
| 31 | def decorated_fxn(fxn): |
| 32 | def call_fxn(*args, **kwargs): |
| 33 | sys.stdout.write(message + ' ... ') |
| 34 | sys.stdout.flush() |
| 35 | result = fxn(*args, **kwargs) |
| 36 | if not modal and not info: |
| 37 | print("done") |
| 38 | elif info: |
| 39 | print(info(result)) |
| 40 | else: |
Florent Xicluna | e4a3380 | 2010-08-09 12:24:20 +0000 | [diff] [blame] | 41 | print("yes" if result else "NO") |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 42 | return result |
| 43 | return call_fxn |
| 44 | return decorated_fxn |
| 45 | |
Florent Xicluna | e4a3380 | 2010-08-09 12:24:20 +0000 | [diff] [blame] | 46 | |
Nick Coghlan | 482f7a2 | 2017-03-12 13:19:08 +1000 | [diff] [blame] | 47 | def get_git_branch(): |
| 48 | """Get the symbolic name for the current git branch""" |
| 49 | cmd = "git rev-parse --abbrev-ref HEAD".split() |
| 50 | try: |
Alexey Izbyshev | aa95bfb | 2018-10-20 03:49:41 +0300 | [diff] [blame] | 51 | return subprocess.check_output(cmd, |
| 52 | stderr=subprocess.DEVNULL, |
Miss Islington (bot) | 4cc8369 | 2021-05-10 11:58:42 -0700 | [diff] [blame] | 53 | cwd=SRCDIR, |
| 54 | encoding='UTF-8') |
Nick Coghlan | 482f7a2 | 2017-03-12 13:19:08 +1000 | [diff] [blame] | 55 | except subprocess.CalledProcessError: |
| 56 | return None |
| 57 | |
| 58 | |
| 59 | def get_git_upstream_remote(): |
| 60 | """Get the remote name to use for upstream branches |
| 61 | |
| 62 | Uses "upstream" if it exists, "origin" otherwise |
| 63 | """ |
| 64 | cmd = "git remote get-url upstream".split() |
| 65 | try: |
Alexey Izbyshev | aa95bfb | 2018-10-20 03:49:41 +0300 | [diff] [blame] | 66 | subprocess.check_output(cmd, |
| 67 | stderr=subprocess.DEVNULL, |
Miss Islington (bot) | 4cc8369 | 2021-05-10 11:58:42 -0700 | [diff] [blame] | 68 | cwd=SRCDIR, |
| 69 | encoding='UTF-8') |
Nick Coghlan | 482f7a2 | 2017-03-12 13:19:08 +1000 | [diff] [blame] | 70 | except subprocess.CalledProcessError: |
| 71 | return "origin" |
| 72 | return "upstream" |
| 73 | |
| 74 | |
Miss Islington (bot) | 4cc8369 | 2021-05-10 11:58:42 -0700 | [diff] [blame] | 75 | def get_git_remote_default_branch(remote_name): |
| 76 | """Get the name of the default branch for the given remote |
| 77 | |
| 78 | It is typically called 'main', but may differ |
| 79 | """ |
| 80 | cmd = "git remote show {}".format(remote_name).split() |
Miss Islington (bot) | 336dc52 | 2021-05-13 11:42:31 -0700 | [diff] [blame] | 81 | env = os.environ.copy() |
| 82 | env['LANG'] = 'C' |
Miss Islington (bot) | 4cc8369 | 2021-05-10 11:58:42 -0700 | [diff] [blame] | 83 | try: |
| 84 | remote_info = subprocess.check_output(cmd, |
| 85 | stderr=subprocess.DEVNULL, |
| 86 | cwd=SRCDIR, |
Miss Islington (bot) | 336dc52 | 2021-05-13 11:42:31 -0700 | [diff] [blame] | 87 | encoding='UTF-8', |
| 88 | env=env) |
Miss Islington (bot) | 4cc8369 | 2021-05-10 11:58:42 -0700 | [diff] [blame] | 89 | except subprocess.CalledProcessError: |
| 90 | return None |
| 91 | for line in remote_info.splitlines(): |
| 92 | if "HEAD branch:" in line: |
| 93 | base_branch = line.split(":")[1].strip() |
| 94 | return base_branch |
| 95 | return None |
| 96 | |
| 97 | |
Nick Coghlan | 482f7a2 | 2017-03-12 13:19:08 +1000 | [diff] [blame] | 98 | @status("Getting base branch for PR", |
| 99 | info=lambda x: x if x is not None else "not a PR branch") |
| 100 | def get_base_branch(): |
Nick Coghlan | 2abfdf5 | 2017-04-09 18:33:03 +1000 | [diff] [blame] | 101 | if not os.path.exists(os.path.join(SRCDIR, '.git')): |
Nick Coghlan | 482f7a2 | 2017-03-12 13:19:08 +1000 | [diff] [blame] | 102 | # Not a git checkout, so there's no base branch |
| 103 | return None |
Miss Islington (bot) | 4cc8369 | 2021-05-10 11:58:42 -0700 | [diff] [blame] | 104 | upstream_remote = get_git_upstream_remote() |
Nick Coghlan | 482f7a2 | 2017-03-12 13:19:08 +1000 | [diff] [blame] | 105 | version = sys.version_info |
| 106 | if version.releaselevel == 'alpha': |
Miss Islington (bot) | 4cc8369 | 2021-05-10 11:58:42 -0700 | [diff] [blame] | 107 | base_branch = get_git_remote_default_branch(upstream_remote) |
Nick Coghlan | 482f7a2 | 2017-03-12 13:19:08 +1000 | [diff] [blame] | 108 | else: |
| 109 | base_branch = "{0.major}.{0.minor}".format(version) |
| 110 | this_branch = get_git_branch() |
| 111 | if this_branch is None or this_branch == base_branch: |
| 112 | # Not on a git PR branch, so there's no base branch |
| 113 | return None |
Nick Coghlan | 482f7a2 | 2017-03-12 13:19:08 +1000 | [diff] [blame] | 114 | return upstream_remote + "/" + base_branch |
| 115 | |
| 116 | |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 117 | @status("Getting the list of files that have been added/changed", |
Georg Brandl | a9afb68 | 2010-10-21 12:49:28 +0000 | [diff] [blame] | 118 | info=lambda x: n_files_str(len(x))) |
Nick Coghlan | 482f7a2 | 2017-03-12 13:19:08 +1000 | [diff] [blame] | 119 | def changed_files(base_branch=None): |
Benjamin Peterson | b8c0845 | 2018-06-05 22:40:12 -0700 | [diff] [blame] | 120 | """Get the list of changed or added files from git.""" |
| 121 | if os.path.exists(os.path.join(SRCDIR, '.git')): |
Nick Coghlan | 6a6d090 | 2017-03-12 19:37:09 +1000 | [diff] [blame] | 122 | # We just use an existence check here as: |
| 123 | # directory = normal git checkout/clone |
| 124 | # file = git worktree directory |
Nick Coghlan | 482f7a2 | 2017-03-12 13:19:08 +1000 | [diff] [blame] | 125 | if base_branch: |
| 126 | cmd = 'git diff --name-status ' + base_branch |
| 127 | else: |
| 128 | cmd = 'git status --porcelain' |
Christian Heimes | d98c677 | 2015-04-23 11:24:14 +0200 | [diff] [blame] | 129 | filenames = [] |
Alexey Izbyshev | aa95bfb | 2018-10-20 03:49:41 +0300 | [diff] [blame] | 130 | with subprocess.Popen(cmd.split(), |
| 131 | stdout=subprocess.PIPE, |
| 132 | cwd=SRCDIR) as st: |
Christian Heimes | d98c677 | 2015-04-23 11:24:14 +0200 | [diff] [blame] | 133 | for line in st.stdout: |
| 134 | line = line.decode().rstrip() |
Nick Coghlan | 482f7a2 | 2017-03-12 13:19:08 +1000 | [diff] [blame] | 135 | status_text, filename = line.split(maxsplit=1) |
| 136 | status = set(status_text) |
Christian Heimes | d98c677 | 2015-04-23 11:24:14 +0200 | [diff] [blame] | 137 | # modified, added or unmerged files |
| 138 | if not status.intersection('MAU'): |
| 139 | continue |
Christian Heimes | d98c677 | 2015-04-23 11:24:14 +0200 | [diff] [blame] | 140 | if ' -> ' in filename: |
| 141 | # file is renamed |
| 142 | filename = filename.split(' -> ', 2)[1].strip() |
| 143 | filenames.append(filename) |
Christian Heimes | d98c677 | 2015-04-23 11:24:14 +0200 | [diff] [blame] | 144 | else: |
Benjamin Peterson | b8c0845 | 2018-06-05 22:40:12 -0700 | [diff] [blame] | 145 | sys.exit('need a git checkout to get modified files') |
Florent Xicluna | e4a3380 | 2010-08-09 12:24:20 +0000 | [diff] [blame] | 146 | |
Victor Stinner | 4a347ce | 2017-08-17 16:29:15 +0200 | [diff] [blame] | 147 | filenames2 = [] |
| 148 | for filename in filenames: |
| 149 | # Normalize the path to be able to match using .startswith() |
| 150 | filename = os.path.normpath(filename) |
| 151 | if any(filename.startswith(path) for path in EXCLUDE_DIRS): |
| 152 | # Exclude the file |
| 153 | continue |
| 154 | filenames2.append(filename) |
| 155 | |
| 156 | return filenames2 |
| 157 | |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 158 | |
Brett Cannon | 058173e | 2010-07-04 22:05:34 +0000 | [diff] [blame] | 159 | def report_modified_files(file_paths): |
| 160 | count = len(file_paths) |
| 161 | if count == 0: |
| 162 | return n_files_str(count) |
| 163 | else: |
| 164 | lines = ["{}:".format(n_files_str(count))] |
| 165 | for path in file_paths: |
| 166 | lines.append(" {}".format(path)) |
| 167 | return "\n".join(lines) |
| 168 | |
Florent Xicluna | e4a3380 | 2010-08-09 12:24:20 +0000 | [diff] [blame] | 169 | |
Brett Cannon | 70cb187 | 2017-06-24 16:51:23 -0700 | [diff] [blame] | 170 | @status("Fixing Python file whitespace", info=report_modified_files) |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 171 | def normalize_whitespace(file_paths): |
| 172 | """Make sure that the whitespace for .py files have been normalized.""" |
| 173 | reindent.makebackup = False # No need to create backups. |
Benjamin Peterson | 4177eff | 2011-06-27 18:25:06 -0500 | [diff] [blame] | 174 | fixed = [path for path in file_paths if path.endswith('.py') and |
Éric Araujo | ad548b8 | 2011-07-31 18:33:00 +0200 | [diff] [blame] | 175 | reindent.check(os.path.join(SRCDIR, path))] |
Brett Cannon | 058173e | 2010-07-04 22:05:34 +0000 | [diff] [blame] | 176 | return fixed |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 177 | |
Florent Xicluna | e4a3380 | 2010-08-09 12:24:20 +0000 | [diff] [blame] | 178 | |
Georg Brandl | a9afb68 | 2010-10-21 12:49:28 +0000 | [diff] [blame] | 179 | @status("Fixing C file whitespace", info=report_modified_files) |
| 180 | def normalize_c_whitespace(file_paths): |
| 181 | """Report if any C files """ |
| 182 | fixed = [] |
| 183 | for path in file_paths: |
Éric Araujo | a3e072b | 2011-07-30 21:34:04 +0200 | [diff] [blame] | 184 | abspath = os.path.join(SRCDIR, path) |
| 185 | with open(abspath, 'r') as f: |
Georg Brandl | a9afb68 | 2010-10-21 12:49:28 +0000 | [diff] [blame] | 186 | if '\t' not in f.read(): |
| 187 | continue |
Éric Araujo | a3e072b | 2011-07-30 21:34:04 +0200 | [diff] [blame] | 188 | untabify.process(abspath, 8, verbose=False) |
Georg Brandl | a9afb68 | 2010-10-21 12:49:28 +0000 | [diff] [blame] | 189 | fixed.append(path) |
| 190 | return fixed |
| 191 | |
| 192 | |
| 193 | ws_re = re.compile(br'\s+(\r?\n)$') |
| 194 | |
| 195 | @status("Fixing docs whitespace", info=report_modified_files) |
| 196 | def normalize_docs_whitespace(file_paths): |
| 197 | fixed = [] |
| 198 | for path in file_paths: |
Éric Araujo | a3e072b | 2011-07-30 21:34:04 +0200 | [diff] [blame] | 199 | abspath = os.path.join(SRCDIR, path) |
Georg Brandl | a9afb68 | 2010-10-21 12:49:28 +0000 | [diff] [blame] | 200 | try: |
Éric Araujo | a3e072b | 2011-07-30 21:34:04 +0200 | [diff] [blame] | 201 | with open(abspath, 'rb') as f: |
Georg Brandl | a9afb68 | 2010-10-21 12:49:28 +0000 | [diff] [blame] | 202 | lines = f.readlines() |
| 203 | new_lines = [ws_re.sub(br'\1', line) for line in lines] |
| 204 | if new_lines != lines: |
Éric Araujo | a3e072b | 2011-07-30 21:34:04 +0200 | [diff] [blame] | 205 | shutil.copyfile(abspath, abspath + '.bak') |
| 206 | with open(abspath, 'wb') as f: |
Georg Brandl | a9afb68 | 2010-10-21 12:49:28 +0000 | [diff] [blame] | 207 | f.writelines(new_lines) |
| 208 | fixed.append(path) |
| 209 | except Exception as err: |
| 210 | print('Cannot fix %s: %s' % (path, err)) |
| 211 | return fixed |
| 212 | |
| 213 | |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 214 | @status("Docs modified", modal=True) |
| 215 | def docs_modified(file_paths): |
Brett Cannon | 058173e | 2010-07-04 22:05:34 +0000 | [diff] [blame] | 216 | """Report if any file in the Doc directory has been changed.""" |
| 217 | return bool(file_paths) |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 218 | |
Florent Xicluna | e4a3380 | 2010-08-09 12:24:20 +0000 | [diff] [blame] | 219 | |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 220 | @status("Misc/ACKS updated", modal=True) |
| 221 | def credit_given(file_paths): |
| 222 | """Check if Misc/ACKS has been changed.""" |
Terry Jan Reedy | 6e2711b | 2013-07-21 20:57:44 -0400 | [diff] [blame] | 223 | return os.path.join('Misc', 'ACKS') in file_paths |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 224 | |
Florent Xicluna | e4a3380 | 2010-08-09 12:24:20 +0000 | [diff] [blame] | 225 | |
Antoine Pitrou | 1ba9469 | 2017-06-25 03:21:49 +0200 | [diff] [blame] | 226 | @status("Misc/NEWS.d updated with `blurb`", modal=True) |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 227 | def reported_news(file_paths): |
Antoine Pitrou | 1ba9469 | 2017-06-25 03:21:49 +0200 | [diff] [blame] | 228 | """Check if Misc/NEWS.d has been changed.""" |
| 229 | return any(p.startswith(os.path.join('Misc', 'NEWS.d', 'next')) |
| 230 | for p in file_paths) |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 231 | |
Ross Lagerwall | 6c52c57 | 2012-03-11 19:21:07 +0200 | [diff] [blame] | 232 | @status("configure regenerated", modal=True, info=str) |
| 233 | def regenerated_configure(file_paths): |
| 234 | """Check if configure has been regenerated.""" |
Matthias Klose | 5ce31cc | 2012-03-14 23:17:31 +0100 | [diff] [blame] | 235 | if 'configure.ac' in file_paths: |
Ross Lagerwall | 6c52c57 | 2012-03-11 19:21:07 +0200 | [diff] [blame] | 236 | return "yes" if 'configure' in file_paths else "no" |
| 237 | else: |
| 238 | return "not needed" |
| 239 | |
| 240 | @status("pyconfig.h.in regenerated", modal=True, info=str) |
| 241 | def regenerated_pyconfig_h_in(file_paths): |
| 242 | """Check if pyconfig.h.in has been regenerated.""" |
Matthias Klose | 5ce31cc | 2012-03-14 23:17:31 +0100 | [diff] [blame] | 243 | if 'configure.ac' in file_paths: |
Ross Lagerwall | 6c52c57 | 2012-03-11 19:21:07 +0200 | [diff] [blame] | 244 | return "yes" if 'pyconfig.h.in' in file_paths else "no" |
| 245 | else: |
| 246 | return "not needed" |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 247 | |
Brett Cannon | 70cb187 | 2017-06-24 16:51:23 -0700 | [diff] [blame] | 248 | def travis(pull_request): |
| 249 | if pull_request == 'false': |
| 250 | print('Not a pull request; skipping') |
| 251 | return |
| 252 | base_branch = get_base_branch() |
| 253 | file_paths = changed_files(base_branch) |
| 254 | python_files = [fn for fn in file_paths if fn.endswith('.py')] |
| 255 | c_files = [fn for fn in file_paths if fn.endswith(('.c', '.h'))] |
| 256 | doc_files = [fn for fn in file_paths if fn.startswith('Doc') and |
| 257 | fn.endswith(('.rst', '.inc'))] |
| 258 | fixed = [] |
| 259 | fixed.extend(normalize_whitespace(python_files)) |
| 260 | fixed.extend(normalize_c_whitespace(c_files)) |
| 261 | fixed.extend(normalize_docs_whitespace(doc_files)) |
| 262 | if not fixed: |
| 263 | print('No whitespace issues found') |
| 264 | else: |
| 265 | print(f'Please fix the {len(fixed)} file(s) with whitespace issues') |
| 266 | print('(on UNIX you can run `make patchcheck` to make the fixes)') |
| 267 | sys.exit(1) |
| 268 | |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 269 | def main(): |
Nick Coghlan | 482f7a2 | 2017-03-12 13:19:08 +1000 | [diff] [blame] | 270 | base_branch = get_base_branch() |
| 271 | file_paths = changed_files(base_branch) |
Brett Cannon | 058173e | 2010-07-04 22:05:34 +0000 | [diff] [blame] | 272 | python_files = [fn for fn in file_paths if fn.endswith('.py')] |
| 273 | c_files = [fn for fn in file_paths if fn.endswith(('.c', '.h'))] |
Georg Brandl | 24f0717 | 2014-10-19 11:54:08 +0200 | [diff] [blame] | 274 | doc_files = [fn for fn in file_paths if fn.startswith('Doc') and |
| 275 | fn.endswith(('.rst', '.inc'))] |
Antoine Pitrou | 1ba9469 | 2017-06-25 03:21:49 +0200 | [diff] [blame] | 276 | misc_files = {p for p in file_paths if p.startswith('Misc')} |
Brett Cannon | 058173e | 2010-07-04 22:05:34 +0000 | [diff] [blame] | 277 | # PEP 8 whitespace rules enforcement. |
| 278 | normalize_whitespace(python_files) |
Georg Brandl | a9afb68 | 2010-10-21 12:49:28 +0000 | [diff] [blame] | 279 | # C rules enforcement. |
| 280 | normalize_c_whitespace(c_files) |
| 281 | # Doc whitespace enforcement. |
| 282 | normalize_docs_whitespace(doc_files) |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 283 | # Docs updated. |
Georg Brandl | a9afb68 | 2010-10-21 12:49:28 +0000 | [diff] [blame] | 284 | docs_modified(doc_files) |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 285 | # Misc/ACKS changed. |
Terry Jan Reedy | 6e2711b | 2013-07-21 20:57:44 -0400 | [diff] [blame] | 286 | credit_given(misc_files) |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 287 | # Misc/NEWS changed. |
Terry Jan Reedy | 6e2711b | 2013-07-21 20:57:44 -0400 | [diff] [blame] | 288 | reported_news(misc_files) |
Ross Lagerwall | 6c52c57 | 2012-03-11 19:21:07 +0200 | [diff] [blame] | 289 | # Regenerated configure, if necessary. |
| 290 | regenerated_configure(file_paths) |
| 291 | # Regenerated pyconfig.h.in, if necessary. |
| 292 | regenerated_pyconfig_h_in(file_paths) |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 293 | |
| 294 | # Test suite run and passed. |
Éric Araujo | fbc5ff6 | 2011-08-12 17:50:08 +0200 | [diff] [blame] | 295 | if python_files or c_files: |
Ezio Melotti | 5e12bb7 | 2013-01-11 14:07:47 +0200 | [diff] [blame] | 296 | end = " and check for refleaks?" if c_files else "?" |
Éric Araujo | fbc5ff6 | 2011-08-12 17:50:08 +0200 | [diff] [blame] | 297 | print() |
Ezio Melotti | 5e12bb7 | 2013-01-11 14:07:47 +0200 | [diff] [blame] | 298 | print("Did you run the test suite" + end) |
Christian Heimes | ada8c3b | 2008-03-18 18:26:33 +0000 | [diff] [blame] | 299 | |
| 300 | |
| 301 | if __name__ == '__main__': |
Brett Cannon | 70cb187 | 2017-06-24 16:51:23 -0700 | [diff] [blame] | 302 | import argparse |
| 303 | parser = argparse.ArgumentParser(description=__doc__) |
| 304 | parser.add_argument('--travis', |
| 305 | help='Perform pass/fail checks') |
| 306 | args = parser.parse_args() |
| 307 | if args.travis: |
| 308 | travis(args.travis) |
| 309 | else: |
| 310 | main() |