Skip to content

Commit 620f25c

Browse files
committed
[test] Transform you-should-be-using-LLVM_DEBUG to Python.
Avoids the usage of Bash `test` and it should be more portable to other platforms.
1 parent bfc2753 commit 620f25c

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed
Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
1-
// RUN: not test -d '%swift_src_root'/.git || not git -C '%swift_src_root' grep '\bDEBUG[(]' || (printf '\n*** The DE'B'UG(...) macro is being renamed to LLVM_DEBUG(...);\n*** please use that instead.\n' && false)
1+
#! /usr/bin/env python
2+
# -*- python -*-
3+
# RUN: %{python} %s '%swift_src_root'
24

3-
If you see a failure in this test, that means you introduced a use of the DEBUG
4-
macro from LLVM, which is being renamed to LLVM_DEBUG.
5+
import os.path
6+
import subprocess
7+
import sys
8+
9+
if len(sys.argv) < 2:
10+
print('Invalid number of arguments.')
11+
sys.exit(1)
12+
13+
swift_src_root = sys.argv[1]
14+
if not os.path.exists(os.path.join(swift_src_root, '.git')):
15+
# It is fine if the folder doesn't exist
16+
sys.exit(0)
17+
18+
returncode = subprocess.call(
19+
['git', '-C', swift_src_root, 'grep', r'\bDEBUG[(]'])
20+
if returncode == 0: # We found some DEBUG in there.
21+
print('\n'
22+
'*** The DEBUG'
23+
'(...) macro is being renamed to LLVM_DEBUG(...);\n'
24+
'*** please use that instead.')
25+
sys.exit(1)
26+
27+
# If you see a failure in this test, that means you introduced a use of the
28+
# DEBUG macro from LLVM, which is being renamed to LLVM_DEBUG.

0 commit comments

Comments
 (0)